public class GenericContent extends Object
| Constructor and Description |
|---|
GenericContent() |
GenericContent(TextFragment content) |
| Modifier and Type | Method and Description |
|---|---|
static String |
fromFragmentToLetterCoded(TextFragment fragment)
Deprecated.
|
static String |
fromFragmentToLetterCoded(TextFragment fragment,
boolean encodeExistingLetterCodes)
Converts a text fragment into a letter-coded text, optionally escaping
tags that will interfere with conversion back to a fragment.
|
static TextFragment |
fromLetterCodedToFragment(String text,
TextFragment fragment,
boolean reuseCodes)
Deprecated.
|
static TextFragment |
fromLetterCodedToFragment(String text,
TextFragment fragment,
boolean reuseCodes,
boolean decodeEncodedLetterCodes)
Converts a letter-coded text to a fragment.
|
Range |
getCodedTextPosition(Range position)
Gets the matching position in the coded text string of a given
position in the generic text output.
|
String |
printMarkerIndexes()
Generates a coded string containing code indexes in place of two-char code markers.
|
String |
printSegmentedContent(TextContainer container,
boolean showSegments)
Prints a generic string representation of a given segmented text, with optional
markers to indicate the segments boundaries.
|
String |
printSegmentedContent(TextContainer container,
boolean showSegments,
boolean normalText)
Prints a string representation of a given segmented text, with optional
markers to indicate the segments boundaries.
|
GenericContent |
setContent(TextFragment content) |
String |
toString()
Generates an generic coded string from the content.
|
String |
toString(boolean normalText)
Generates a generic coded string or an normal output from the content.
|
static void |
updateFragment(String genericText,
TextFragment fragment,
boolean allowCodeDeletion)
Updates a text fragment from a generic representation.
|
public GenericContent()
public GenericContent(TextFragment content)
public GenericContent setContent(TextFragment content)
public String printSegmentedContent(TextContainer container, boolean showSegments)
container - The container to output.showSegments - True if segment boundaries should be shown.public String printSegmentedContent(TextContainer container, boolean showSegments, boolean normalText)
container - the container to output.showSegments - true if segment boundaries should be shown.normalText - true to show in-line real data instead of generic codes.public String printMarkerIndexes()
public String toString()
public String toString(boolean normalText)
normalText - True to show in-line real data instead of generic codes.public Range getCodedTextPosition(Range position)
position - Generic text position to convert to coded text position.public static void updateFragment(String genericText, TextFragment fragment, boolean allowCodeDeletion)
genericText - The generic text to use to update the fragment.fragment - The text fragment to update.allowCodeDeletion - True when missing in-line codes in the generic text
means the corresponding codes should be deleted from the fragment.InvalidContentException - When the generic text is not valid, or does
not correspond to the existing codes.@Deprecated public static TextFragment fromLetterCodedToFragment(String text, TextFragment fragment, boolean reuseCodes)
A letter-coded text is like "<g1>text<x2/></g1><b3/>".
text - the text to convert.fragment - optional existing fragment where to set the converted data, or null to create a new fragment.
If an existing fragment is provided, no existing code is preserved: all codes are coming from the parsing
of the input text, except if reuseCodes is set to true.reuseCodes - true to re-use the codes of the provided text fragment. If a code is not found in the
provided text fragment, one is created for the output.public static TextFragment fromLetterCodedToFragment(String text, TextFragment fragment, boolean reuseCodes, boolean decodeEncodedLetterCodes)
A letter-coded text is like "<g1>text<x2/></g1><b3/>".
text - the text to convert.fragment - optional existing fragment where to set the converted data, or null to create a new fragment.
If an existing fragment is provided, no existing code is preserved: all codes are coming from the parsing
of the input text, except if reuseCodes is set to true.reuseCodes - true to re-use the codes of the provided text fragment. If a code is not found in the
provided text fragment, one is created for the output.decodeEncodedLetterCodes - true to reverse previous tag escaping, this should match the value of encodeExistingLetterCodes when the text was tag encoded@Deprecated public static String fromFragmentToLetterCoded(TextFragment fragment)
fromLetterCodedToFragment(String, TextFragment, boolean) to convert back to a fragment.fragment - the fragment to convert.public static String fromFragmentToLetterCoded(TextFragment fragment, boolean encodeExistingLetterCodes)
fromLetterCodedToFragment(String, TextFragment, boolean, boolean) to
convert back to a fragment.fragment - the fragment to convert.encodeExistingLetterCodes - escape the tags.Copyright © 2021. All rights reserved.