Class StructuredTextImpl
- All Implemented Interfaces:
IStructuredTextExpert
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StructuredTextEnvironmentThe environment associated with the expert.protected final StructuredTextTypeHandlerThe structured text handler utilized by this expert.protected final booleanFlag which is true if the expert is stateful.protected ObjectLast state value set bysetState(java.lang.Object)orclearState().Fields inherited from interface org.eclipse.equinox.bidi.advanced.IStructuredTextExpert
DIR_LTR, DIR_RTL -
Constructor Summary
ConstructorsConstructorDescriptionStructuredTextImpl(StructuredTextTypeHandler structuredTextHandler, StructuredTextEnvironment environment, boolean shared) Constructor used inStructuredTextExpertFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidResets the state to initial.int[]fullBidiCharOffsets(String full) Given a full string, returns the offsets of characters which are directional formatting characters that have been added in order to ensure correct presentation.int[]fullToLeanMap(String full) Given a full string, computes the positions of each of its characters within the corresponding lean string.fullToLeanText(String full) Removes directional formatting characters which were added to a structured text string to ensure correct presentation.Obtains the environment associated with thisIStructuredTextExpertinstance.getState()Gets the state established by the last text processing call.intgetTextDirection(String text) Get the base direction of a structured text.Obtains the structured type handler associated with thisIStructuredTextExpertinstance.insertMarks(String text, int[] offsets, int direction, int affixLength) Adds directional marks to the given text before the characters specified in the given array of offsets.int[]leanBidiCharOffsets(String text) Given a lean string, computes the offsets of characters before which directional formatting characters must be added in order to ensure correct presentation.int[]leanToFullMap(String text) Given a lean string, computes the positions of each of its characters within the corresponding full string.leanToFullText(String text) When the orientation isORIENT_LTRand the structured text has a RTL base direction,leanToFullTextadds RLE+RLM at the head of the full text and RLM+PDF at its end.static voidprocessSeparator(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int separLocation) voidSets the state for the next text processing call.toString()
-
Field Details
-
handler
The structured text handler utilized by this expert. -
environment
The environment associated with the expert. -
state
Last state value set bysetState(java.lang.Object)orclearState().
-
-
Constructor Details
-
StructuredTextImpl
public StructuredTextImpl(StructuredTextTypeHandler structuredTextHandler, StructuredTextEnvironment environment, boolean shared) Constructor used inStructuredTextExpertFactory.- Parameters:
structuredTextHandler- the structured text handler used by this expert.environment- the environment associated with this expert.shared- flag which is true if the expert is stateful.
-
-
Method Details
-
getTypeHandler
Description copied from interface:IStructuredTextExpertObtains the structured type handler associated with thisIStructuredTextExpertinstance.- Specified by:
getTypeHandlerin interfaceIStructuredTextExpert- Returns:
- the type handler instance.
-
getEnvironment
Description copied from interface:IStructuredTextExpertObtains the environment associated with thisIStructuredTextExpertinstance.- Specified by:
getEnvironmentin interfaceIStructuredTextExpert- Returns:
- the environment instance.
-
getTextDirection
Description copied from interface:IStructuredTextExpertGet the base direction of a structured text. This base direction may depend on whether the text contains Arabic or Hebrew words. If the text contains both, the first Arabic or Hebrew letter in the text determines which is the governing script.- Specified by:
getTextDirectionin interfaceIStructuredTextExpert- Parameters:
text- is the structured text string.- Returns:
- the base direction of the structured text,
IStructuredTextExpert.DIR_LTRorIStructuredTextExpert.DIR_RTL
-
clearState
public void clearState()Description copied from interface:IStructuredTextExpertResets the state to initial. This method does nothing if the expert instance is not a stateful one.- Specified by:
clearStatein interfaceIStructuredTextExpert
-
setState
Description copied from interface:IStructuredTextExpertSets the state for the next text processing call. This method does nothing if the expert instance is not a stateful one.- Specified by:
setStatein interfaceIStructuredTextExpert- Parameters:
newState- an object returned by a previous call toIStructuredTextExpert.getState().
-
getState
Description copied from interface:IStructuredTextExpertGets the state established by the last text processing call. This isnullif the expert instance is not a stateful one, or if the last text processing call had nothing to pass to the next call.- Specified by:
getStatein interfaceIStructuredTextExpert- Returns:
- the last established state.
-
processSeparator
public static void processSeparator(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int separLocation) - See Also:
-
leanToFullText
When the orientation isORIENT_LTRand the structured text has a RTL base direction,leanToFullTextadds RLE+RLM at the head of the full text and RLM+PDF at its end.When the orientation is
ORIENT_RTLand the structured text has a LTR base direction,leanToFullTextadds LRE+LRM at the head of the full text and LRM+PDF at its end.When the orientation is
ORIENT_CONTEXTUAL_LTRorORIENT_CONTEXTUAL_RTLand the data content would resolve to a RTL orientation while the structured text has a LTR base direction,leanToFullTextadds LRM at the head of the full text.When the orientation is
ORIENT_CONTEXTUAL_LTRorORIENT_CONTEXTUAL_RTLand the data content would resolve to a LTR orientation while the structured text has a RTL base direction,leanToFullTextadds RLM at the head of the full text.When the orientation is
ORIENT_UNKNOWNand the structured text has a LTR base direction,leanToFullTextadds LRE+LRM at the head of the full text and LRM+PDF at its end.When the orientation is
ORIENT_UNKNOWNand the structured text has a RTL base direction,leanToFullTextadds RLE+RLM at the head of the full text and RLM+PDF at its end.When the orientation is
ORIENT_IGNORE,leanToFullTextdoes not add any directional formatting characters as either prefix or suffix of the full text.- Specified by:
leanToFullTextin interfaceIStructuredTextExpert- Parameters:
text- is the structured text string- Returns:
- the structured text with directional formatting characters added to ensure correct presentation.
-
leanToFullMap
Description copied from interface:IStructuredTextExpertGiven a lean string, computes the positions of each of its characters within the corresponding full string.- Specified by:
leanToFullMapin interfaceIStructuredTextExpert- Parameters:
text- is the structured text string.- Returns:
- an array of integers with one element for each of the characters in
the
textargument, equal to the offset of the corresponding character in the full string.
-
leanBidiCharOffsets
Description copied from interface:IStructuredTextExpertGiven a lean string, computes the offsets of characters before which directional formatting characters must be added in order to ensure correct presentation.Only LRMs (for a string with LTR base direction) and RLMs (for a string with RTL base direction) are considered. Leading and trailing LRE, RLE and PDF which might be prefixed or suffixed depending on the
orientationof the GUI component used for display are not reflected in this method.- Specified by:
leanBidiCharOffsetsin interfaceIStructuredTextExpert- Parameters:
text- is the structured text string- Returns:
- an array of offsets to the characters in the
textargument before which directional marks must be added to ensure correct presentation. The offsets are sorted in ascending order.
-
fullToLeanText
Description copied from interface:IStructuredTextExpertRemoves directional formatting characters which were added to a structured text string to ensure correct presentation.- Specified by:
fullToLeanTextin interfaceIStructuredTextExpert- Parameters:
full- is the structured text string including directional formatting characters.- Returns:
- the structured text string without directional formatting characters
which might have been added by processing it with
IStructuredTextExpert.leanToFullText(java.lang.String).
-
fullToLeanMap
Description copied from interface:IStructuredTextExpertGiven a full string, computes the positions of each of its characters within the corresponding lean string.- Specified by:
fullToLeanMapin interfaceIStructuredTextExpert- Parameters:
full- is the structured text string including directional formatting characters.- Returns:
- an array of integers with one element for each of the characters in
the
textargument, equal to the offset of the corresponding character in the lean string. If there is no corresponding character in the lean string (because the specified character is a directional formatting character added when invokingIStructuredTextExpert.leanToFullText(java.lang.String)), the value returned for this character is -1.
-
fullBidiCharOffsets
Description copied from interface:IStructuredTextExpertGiven a full string, returns the offsets of characters which are directional formatting characters that have been added in order to ensure correct presentation.LRMs (for a string with LTR base direction), RLMs (for a string with RTL base direction) are considered as well as leading and trailing LRE, RLE and PDF which might be prefixed or suffixed depending on the
orientationof the GUI component used for display.- Specified by:
fullBidiCharOffsetsin interfaceIStructuredTextExpert- Parameters:
full- is the structured text string including directional formatting characters- Returns:
- an array of offsets to the characters in the
textargument which are directional formatting characters added to ensure correct presentation. The offsets are sorted in ascending order.
-
insertMarks
Description copied from interface:IStructuredTextExpertAdds directional marks to the given text before the characters specified in the given array of offsets. It can be used to add a prefix and/or a suffix of directional formatting characters.The directional marks will be LRMs for structured text strings with LTR base direction and RLMs for strings with RTL base direction.
If necessary, leading and trailing directional formatting characters (LRE, RLE and PDF) can be added depending on the value of the
affixargument.- A value of 1 means that one LRM or RLM must be prefixed, depending on the direction. This is useful when the GUI component presenting this text has a contextual orientation.
- A value of 2 means that LRE+LRM or RLE+RLM must be prefixed, depending on the direction, and LRM+PDF or RLM+PDF must be suffixed, depending on the direction. This is useful if the GUI component presenting this text needs to have the text orientation explicitly specified.
- A value of 0 means that no prefix or suffix are needed.
- Specified by:
insertMarksin interfaceIStructuredTextExpert- Parameters:
text- the structured text stringoffsets- an array of offsets to characters intextbefore which an LRM or RLM will be inserted. The array must be sorted in ascending order without duplicates. This argument may benullif there are no marks to add.direction- the base direction of the structured text. It must be one of the valuesIStructuredTextExpert.DIR_LTR, orIStructuredTextExpert.DIR_RTL.affixLength- specifies the length of prefix and suffix which should be added to the result.
0 means no prefix or suffix
1 means one LRM or RLM as prefix and no suffix
2 means 2 characters in both prefix and suffix.- Returns:
- a string corresponding to the source
textwith directional marks (LRMs or RLMs) added at the specified offsets, and directional formatting characters (LRE, RLE, PDF) added as prefix and suffix if so required. - See Also:
-
toString
-