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.
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 bidirectional classes that contain
the bidirectional 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
bidirectional format in which the string object is currently stored. The output
format is the bidirectional 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;
}
Last updated: Thu 26 Oct 2006 10:30:05
(c) Copyright IBM Corporation 2005, 2006.
This information center is powered by Eclipse technology (http://www.eclipse.org)