Class StructuredTextImpl
- All Implemented Interfaces:
IStructuredTextExpert
-
Field Summary
Modifier and TypeFieldDescriptionprotected final StructuredTextEnvironment
The environment associated with the expert.protected final StructuredTextTypeHandler
The structured text handler utilized by this expert.protected final boolean
Flag which is true if the expert is stateful.protected Object
Last state value set bysetState(java.lang.Object)
orclearState()
.Fields inherited from interface org.eclipse.equinox.bidi.advanced.IStructuredTextExpert
DIR_LTR, DIR_RTL
-
Constructor Summary
ConstructorDescriptionStructuredTextImpl
(StructuredTextTypeHandler structuredTextHandler, StructuredTextEnvironment environment, boolean shared) Constructor used inStructuredTextExpertFactory
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Resets 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 thisIStructuredTextExpert
instance.getState()
Gets the state established by the last text processing call.int
getTextDirection
(String text) Get the base direction of a structured text.Obtains the structured type handler associated with thisIStructuredTextExpert
instance.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_LTR
and the structured text has a RTL base direction,leanToFullText
adds RLE+RLM at the head of the full text and RLM+PDF at its end.static void
processSeparator
(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int separLocation) void
Sets 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:IStructuredTextExpert
Obtains the structured type handler associated with thisIStructuredTextExpert
instance.- Specified by:
getTypeHandler
in interfaceIStructuredTextExpert
- Returns:
- the type handler instance.
-
getEnvironment
Description copied from interface:IStructuredTextExpert
Obtains the environment associated with thisIStructuredTextExpert
instance.- Specified by:
getEnvironment
in interfaceIStructuredTextExpert
- Returns:
- the environment instance.
-
getTextDirection
Description copied from interface:IStructuredTextExpert
Get 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:
getTextDirection
in interfaceIStructuredTextExpert
- Parameters:
text
- is the structured text string.- Returns:
- the base direction of the structured text,
IStructuredTextExpert.DIR_LTR
orIStructuredTextExpert.DIR_RTL
-
clearState
public void clearState()Description copied from interface:IStructuredTextExpert
Resets the state to initial. This method does nothing if the expert instance is not a stateful one.- Specified by:
clearState
in interfaceIStructuredTextExpert
-
setState
Description copied from interface:IStructuredTextExpert
Sets the state for the next text processing call. This method does nothing if the expert instance is not a stateful one.- Specified by:
setState
in interfaceIStructuredTextExpert
- Parameters:
newState
- an object returned by a previous call toIStructuredTextExpert.getState()
.
-
getState
Description copied from interface:IStructuredTextExpert
Gets the state established by the last text processing call. This isnull
if 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:
getState
in interfaceIStructuredTextExpert
- Returns:
- the last established state.
-
processSeparator
public static void processSeparator(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int separLocation) -
leanToFullText
When the orientation isORIENT_LTR
and the structured text has a RTL base direction,leanToFullText
adds RLE+RLM at the head of the full text and RLM+PDF at its end.When the orientation is
ORIENT_RTL
and the structured text has a LTR base direction,leanToFullText
adds LRE+LRM at the head of the full text and LRM+PDF at its end.When the orientation is
ORIENT_CONTEXTUAL_LTR
orORIENT_CONTEXTUAL_RTL
and the data content would resolve to a RTL orientation while the structured text has a LTR base direction,leanToFullText
adds LRM at the head of the full text.When the orientation is
ORIENT_CONTEXTUAL_LTR
orORIENT_CONTEXTUAL_RTL
and the data content would resolve to a LTR orientation while the structured text has a RTL base direction,leanToFullText
adds RLM at the head of the full text.When the orientation is
ORIENT_UNKNOWN
and the structured text has a LTR base direction,leanToFullText
adds LRE+LRM at the head of the full text and LRM+PDF at its end.When the orientation is
ORIENT_UNKNOWN
and the structured text has a RTL base direction,leanToFullText
adds RLE+RLM at the head of the full text and RLM+PDF at its end.When the orientation is
ORIENT_IGNORE
,leanToFullText
does not add any directional formatting characters as either prefix or suffix of the full text.- Specified by:
leanToFullText
in 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:IStructuredTextExpert
Given a lean string, computes the positions of each of its characters within the corresponding full string.- Specified by:
leanToFullMap
in interfaceIStructuredTextExpert
- Parameters:
text
- is the structured text string.- Returns:
- an array of integers with one element for each of the characters in
the
text
argument, equal to the offset of the corresponding character in the full string.
-
leanBidiCharOffsets
Description copied from interface:IStructuredTextExpert
Given 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
orientation
of the GUI component used for display are not reflected in this method.- Specified by:
leanBidiCharOffsets
in interfaceIStructuredTextExpert
- Parameters:
text
- is the structured text string- Returns:
- an array of offsets to the characters in the
text
argument before which directional marks must be added to ensure correct presentation. The offsets are sorted in ascending order.
-
fullToLeanText
Description copied from interface:IStructuredTextExpert
Removes directional formatting characters which were added to a structured text string to ensure correct presentation.- Specified by:
fullToLeanText
in 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:IStructuredTextExpert
Given a full string, computes the positions of each of its characters within the corresponding lean string.- Specified by:
fullToLeanMap
in 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
text
argument, 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:IStructuredTextExpert
Given 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
orientation
of the GUI component used for display.- Specified by:
fullBidiCharOffsets
in interfaceIStructuredTextExpert
- Parameters:
full
- is the structured text string including directional formatting characters- Returns:
- an array of offsets to the characters in the
text
argument which are directional formatting characters added to ensure correct presentation. The offsets are sorted in ascending order.
-
insertMarks
Description copied from interface:IStructuredTextExpert
Adds 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
affix
argument.- 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:
insertMarks
in interfaceIStructuredTextExpert
- Parameters:
text
- the structured text stringoffsets
- an array of offsets to characters intext
before which an LRM or RLM will be inserted. The array must be sorted in ascending order without duplicates. This argument may benull
if 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
text
with 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
-