public class AS400BidiTransform
extends java.lang.Object
Bidi text is a combination of a sequence of characters and a set of Bidi flags. That text (Arabic or Hebrew) has characters which are read from right to left. That text might also be mixed with numbers which are read from left to right, and possibly also mixed with Latin characters. Conversion support is needed to display text properly with the correct order and shape.
Bidi text from an IBM i system may be represented by a combination of a String (the characters) and a CCSID (which implies a set of Bidi flags specific to that CCSID).
Multi-threading considerations: Different threads may use the same AS400BidiTransform object if they have the same transformation needs, as follows:
Otherwise, each thread must use its own instances of this class.
The following examples illustrate how to transform bidi text:
A more simplified method is to use// Java data to IBM i layout: AS400BidiTransform abt; abt = new AS400BidiTransform(424); String dst = abt.toAS400Layout("some bidi string"); // Specifying a new CCSID for an existing AS400BidiTransform object: abt.setAS400Ccsid(62234); // 420 RTL // String dst = abt.toAS400Layout("some bidi string"); // Specifying a non-default string type for a given CCSID: abt.setAS400StringType(BidiStringType.ST4); // Vis LTR // String dst = abt.toAS400Layout("some bidi string"); // Specifying a non-default string type for Java data: abt.setJavaStringType(BidiStringType.ST11); // Imp Context LTR // String dst = abt.toAS400Layout("some bidi string"); // How to transform IBM i data to Java layout: abt.setJavaStringType(BidiStringType.ST6); // Imp RTL // String dst = abt.toJavaLayout("some bidi string");
bidiTransform()
. The following example illustrates how to use it:
String src = "some bidi string"; String result = AS400BidiTransform.bidiTransform(src, BidiStringType.ST4, BidiStringType.ST6); // from visual LTR to Implicit RTL //
Constructor and Description |
---|
AS400BidiTransform(int as400Ccsid)
Constructs an AS400BidiTransform object assuming that the IBM i Bidi text conforms to a given CCSID.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
bidiTransform(java.lang.String str,
int inFormat,
int outFormat)
Bidi-HCG
Perform Bidi layout transformation by given Bidi string types.
|
int |
getAS400Ccsid()
Returns the current CCSID of IBM i data.
|
int |
getAS400StringType()
Returns the current string type of the IBM i data.
|
BidiConversionProperties |
getBidiConversionProperties()
Returns the bidi conversion properties.
|
int |
getJavaStringType()
Returns the current string type of Java data.
|
static int |
getStringType(int ccsid)
Returns Bidi string type defined for CCSID
|
static int |
getStringTypeX(int ccsid,
AS400 as400) |
static boolean |
isBidiCcsid(int ccsid)
Indicates if a given CCSID may apply to Bidi data.
|
static boolean |
isVisual(int ccsid)
Indicates if a given CCSID has a visual string type.
|
static java.lang.String |
meta_data_reordering(java.lang.String value_,
int inFormat,
int outFormat) |
void |
setAS400Ccsid(int as400Ccsid)
Sets the CCSID.
|
void |
setAS400StringType(int as400Type)
Set the explicit string type for the IBM i data.
|
void |
setBidiConversionProperties(BidiConversionProperties properties)
Sets the bidi conversion properties.
|
void |
setJavaStringType(int javaType)
Set the explicit string type for Java data.
|
static java.lang.String |
SQL_statement_reordering(java.lang.String value_,
int inFormat,
int outFormat)
Bidi-HCG
Perform Bidi layout transformation of a data into SQL statement.
|
char[] |
toAS400Layout(char[] javaText) |
java.lang.String |
toAS400Layout(java.lang.String javaText)
Convert data from the Java layout to the IBM i layout.
|
char[] |
toJavaLayout(char[] as400Text) |
java.lang.String |
toJavaLayout(java.lang.String as400Text)
Convert data from the IBM i layout to the Java layout.
|
public AS400BidiTransform(int as400Ccsid)
The given CCSID has a default string type which defines a set of Bidi flags. The orientation implied by this string type is applied to both the IBM i data layout and the Java data layout.
as400Ccsid
- The CCSID of the IBM i data.public static boolean isBidiCcsid(int ccsid)
If a CCSID is not Bidi, there is no need to perform layout transformations when converting IBM i data to Java data and vice-versa.
ccsid
- The CCSID to check.public static boolean isVisual(int ccsid)
ccsid
- The CCSID to check.public void setAS400Ccsid(int as400Ccsid)
The given CCSID has a default string type which defines a set of Bidi flags. The orientation implied by this string type is applied to both the IBM i data layout and the Java data layout.
as400Ccsid
- The CCSID of the IBM i data.public int getAS400Ccsid()
public void setAS400StringType(int as400Type)
as400Type
- The string type to apply to the IBM i data. The parameter string type should always be one of the constants defined in BidiStringType.BidiStringType
public int getAS400StringType()
public void setJavaStringType(int javaType)
javaType
- The string type to apply to Java data.BidiStringType
public int getJavaStringType()
public void setBidiConversionProperties(BidiConversionProperties properties)
properties
- The bidi conversion properties.public BidiConversionProperties getBidiConversionProperties()
public java.lang.String toJavaLayout(java.lang.String as400Text)
as400Text
- The IBM i string to convert.public char[] toJavaLayout(char[] as400Text)
public java.lang.String toAS400Layout(java.lang.String javaText)
javaText
- The Java string to convert.public char[] toAS400Layout(char[] javaText)
public static int getStringType(int ccsid)
ccsid
- input CCSIDpublic static int getStringTypeX(int ccsid, AS400 as400)
public static java.lang.String bidiTransform(java.lang.String str, int inFormat, int outFormat)
str
- The Java string to convert.inFormat
- Input format.outFormat
- Output format.public static java.lang.String SQL_statement_reordering(java.lang.String value_, int inFormat, int outFormat)
value_
- Given SQL statement.inFormat
- Input format.outFormat
- Output format.public static java.lang.String meta_data_reordering(java.lang.String value_, int inFormat, int outFormat)