public class QueryUtil
extends java.lang.Object
Constructor and Description |
---|
QueryUtil() |
Modifier and Type | Method and Description |
---|---|
TextFragment |
createNewFragmentWithCodes(java.lang.String plainText)
Appends the codes stored apart using
separateCodesFromText(TextFragment) at the end of a given plain
text. |
java.lang.String |
fromCodedHTML(java.lang.String htmlText,
TextFragment fragment,
boolean addMissingCodes)
Converts back a coded HTML to a coded text.
|
java.lang.String |
fromCodedHTML(java.lang.String htmlText,
TextFragment fragment,
boolean addMissingCodes,
boolean removeSpans)
Converts back a coded HTML to a coded text.
|
TextFragment |
fromCodedHTMLToFragment(java.lang.String text,
TextFragment fragment)
Converts an HTML string created with
toCodedHTML(TextFragment) back into a text fragment,
but with empty inline codes. |
TextFragment |
fromXLIFF(org.w3c.dom.Element elem,
TextFragment original)
Converts back an XLIFF text contained in a given element into a TextFragment.
|
boolean |
hasCode()
Indicates if the last text fragment passed to
separateCodesFromText(TextFragment) has codes or not. |
static java.util.ArrayList<QueryResult> |
removeDuplicates(java.util.List<QueryResult> queryResults)
Removes duplicates based on the Equals method of
QueryResult . |
java.lang.String |
separateCodesFromText(TextFragment frag)
Separate and store codes of a given text fragment.
|
java.util.List<java.lang.String> |
toCodedHTML(java.util.List<TextFragment> frags)
Converts from coded texts to coded HTML.
|
java.lang.String |
toCodedHTML(TextFragment fragment)
Converts from coded text to coded HTML.
|
java.lang.String |
toXLIFF(TextFragment fragment)
Converts from coded text to XLIFF.
|
public boolean hasCode()
separateCodesFromText(TextFragment)
has codes or not.public java.lang.String separateCodesFromText(TextFragment frag)
frag
- the fragment to process. Use createNewFragmentWithCodes(String)
to
reconstruct the text back with its codes at the end.public TextFragment createNewFragmentWithCodes(java.lang.String plainText)
separateCodesFromText(TextFragment)
at the end of a given plain
text. The text fragment provided must be the same and without code modifications, as the one used for the
splitting.plainText
- new text to use (must be plain)public java.util.List<java.lang.String> toCodedHTML(java.util.List<TextFragment> frags)
frags
- the fragments to convert.public java.lang.String toCodedHTML(TextFragment fragment)
fragment
- the fragment to convert.public TextFragment fromCodedHTMLToFragment(java.lang.String text, TextFragment fragment)
toCodedHTML(TextFragment)
back into a text fragment,
but with empty inline codes.text
- the HTML string to convert.fragment
- an optional text fragment where to place the converted content. Any existing codes will be
replaced or removed by the codes coming from the HTML string. Use null to create a new fragment.public java.lang.String fromCodedHTML(java.lang.String htmlText, TextFragment fragment, boolean addMissingCodes)
htmlText
- the coded HTML to convert back.fragment
- the original text fragment.addMissingCodes
- true to added codes that are in the original fragment but not in the HTML string.public java.lang.String fromCodedHTML(java.lang.String htmlText, TextFragment fragment, boolean addMissingCodes, boolean removeSpans)
htmlText
- the coded HTML to convert back.fragment
- the original text fragment.addMissingCodes
- true to added codes that are in the original fragment but not in the HTML string.removeSpans
- true to remove extra span HTML codes.public java.lang.String toXLIFF(TextFragment fragment)
fragment
- the fragment to convert.fromXLIFF(Element, TextFragment)
public TextFragment fromXLIFF(org.w3c.dom.Element elem, TextFragment original)
elem
- The element containing the XLIFF data.original
- the original TextFragment (cannot be null).toXLIFF(TextFragment)
public static java.util.ArrayList<QueryResult> removeDuplicates(java.util.List<QueryResult> queryResults)
QueryResult
.
Preserve the highest ranked query results.
For example, duplicate results with the newest creation date are always retained.queryResults
- the list of QueryResults to process.Copyright © 2022. All rights reserved.