Class TextProcessor
Processing of the string is done by breaking it down into segments that are specified by a set of user provided delimiters. Directional punctuation characters are injected into the string in order to ensure the string retains its semantic meaning and conforms with the Unicode BiDi algorithm within each segment.
- Since:
- 3.2
- Restriction:
- This class is not intended to be subclassed by clients.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Removes directional marker characters in the given string that were inserted by utilizing theprocess(String)
orprocess(String, String)
methods.static String
Return the string containing all the default delimiter characters to be used to segment a given string.static String
Process the given text and return a string with the appropriate substitution based on the locale.static String
Process a string that has a particular semantic meaning to render on BiDi locales in way that maintains the semantic meaning of the text, but differs from the Unicode BiDi algorithm.
-
Method Details
-
process
Process the given text and return a string with the appropriate substitution based on the locale. This is equivalent to callingprocess(String, String)
with the default set of delimiters.- Parameters:
text
- the text to be processed- Returns:
- the manipulated string
- See Also:
-
process
Process a string that has a particular semantic meaning to render on BiDi locales in way that maintains the semantic meaning of the text, but differs from the Unicode BiDi algorithm. The text is segmented according to the provided delimiters. Each segment has the Unicode BiDi algorithm applied to it, but as a whole, the string is oriented left to right.For example a file path such as
d:\myFolder\FOLDER\MYFILE.java
(where capital letters indicate RTL text) should render asd:\myFolder\REDLOF\ELIFYM.java
when using the Unicode BiDi algorithm and segmenting the string according to the specified delimiter set.The following algorithm is used:
- Scan the string to locate the delimiters.
- While scanning, note the direction of the last strong character scanned. Strong characters are characters which have a BiDi classification of L, R or AL as defined in the Unicode standard.
- If the last strong character before a separator is of class R or AL, add a LRM before the separator. Since LRM itself is a strong L character, following separators do not need an LRM until a strong R or AL character is found.
- If the component where the pattern is displayed has a RTL basic direction, add a LRE at the beginning of the pattern and a PDF at its end. The string is considered to have RTL direction if it contains RTL characters and the runtime locale is BiDi. There is no need to add LRE/PDF if the string begins with an LTR letter, contains no RTL letter, and ends with either a LTR letter or a digit.
NOTE: this method will change the shape of the original string passed in by inserting punctuation characters into the text in order to make it render to correctly reflect the semantic meaning of the text. Methods like
String.equals(String)
andString.length()
called on the resulting string will not return the same values as would be returned for the original string.- Parameters:
str
- the text to process, ifnull
return the string as it was passed indelimiter
- delimiters by which the string will be segmented, ifnull
the default delimiters are used- Returns:
- the processed string
-
deprocess
Removes directional marker characters in the given string that were inserted by utilizing theprocess(String)
orprocess(String, String)
methods.- Parameters:
str
- string with directional markers to remove- Returns:
- string with no directional markers
- Since:
- 3.3
- See Also:
-
getDefaultDelimiters
Return the string containing all the default delimiter characters to be used to segment a given string.- Returns:
- delimiter string
-