org.eclipse.osgi.util
Class TextProcessor

public class TextProcessor
This class is used to process strings that have special semantic meaning (such as file paths) in RTL-oriented locales so that they render in a way that does not corrupt the semantic meaning of the string but also maintains compliance with the Unicode Bidi algorithm of rendering Bidirectional text.

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.

Since3.2
VersionNot specified.
AuthorNot specified.
Wiki javadoc Use textile entry format.
Add your comments here.
Method Summary
String getDefaultDelimiters()
Return the string containing all the default delimiter characters to be used to segment a given string.
String process( String text )
Process the given text and return a string with the appropriate substitution based on the locale.
String process( String str, String delimiter )
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 algoritm.
getDefaultDelimiters
public String getDefaultDelimiters ( )
Return the string containing all the default delimiter characters to be used to segment a given string.
Wiki javadoc Use textile entry format.
Add your comments here.
process
public String process ( String text )
Process the given text and return a string with the appropriate substitution based on the locale. This is equivalent to calling process(String, String) with the default set of delimiters.
Parameters
TypeNameDescription
String text the text to be processed
Wiki javadoc Use textile entry format.
Add your comments here.
process
public String process ( String str, String delimiter )
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 algoritm. 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 as d:\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:

  1. Scan the string to locate the separators and the tokens.
  2. 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.
  3. 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.
  4. 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.

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) and String.length() called on the resulting string will not return the same values as would be returned for the original string.

Parameters
TypeNameDescription
String str the text to process, if null return the string as it was passed in
String delimiter delimiters by which the string will be segmented, if null the default delimiters are used
Wiki javadoc Use textile entry format.
Add your comments here.