When using information that is in a bidirectional language script,
it might be necessary to transform the format of the data. This is a step-by-step
example of the coding that transforms string-type data.
Before you begin
For IBM® WebSphere® Process Server, version 6.0.0,
make sure that all the classes that contain the bi-di engine implementation
are installed on the server on which you are developing your modules. If you
are using JDK 1.4.1 for Windows® , AIX® or Linux® operating systems, you will not
have to install these classes.
Why and when to perform this task
The module requires that string information is transformed from one
bidirectional format to another.
Steps for this task
- Include all bi-di classes that contain the
bi-di engine implementation.
import com.ibm.bidiTools.bdlayout.*;
- Define the strings to contain the data object to transform, and
the input and output format values.
The input format is the
bi-di format in which the string object is currently stored. The output format
is the bi-di format in which you want to store the string object.
String strIn = new String("Hello world");
String formatIn = "ILYNN";
String formatOut = "VLYNN";
- Call the BidiStringTransformation function.
String strOut = BiDiStringTransformation(strIn, formatIn, formatOut);
String BiDiStringTransformation(String strIn, String formatIn, String formatOut) {
- Test if input string is null.
if (strIn == null) return null;
- Perform transformation
BidiFlagSet flagsIn;
BidiFlagSet flagsOut;
formatIn = formatIn.toUpperCase();
formatOut = formatOut.toUpperCase();
if (formatIn != null)
flagsIn = new BidiFlagSet(formatIn.toCharArray());
else
flagsIn = new BidiFlagSet();
if (formatOut != null)
flagsOut = new BidiFlagSet(formatOut.toCharArray());
else
flagsOut = new BidiFlagSet();
if (flagsIn.equals(flagsOut)) return strIn;
String strOut = BiDiStringTransformation(strIn, flagsIn, flagsOut);
return strOut;
}