com.ibm.as400.access
Class AS400BidiTransform

java.lang.Object
  |
  +--com.ibm.as400.access.AS400BidiTransform

public class AS400BidiTransform
extends java.lang.Object

The AS400BidiTransform class provides layout transformations that allow the conversion of Bidi text in AS/400 format (after its conversion to Unicode) to Bidi text in Java format, or vice-versa.

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 AS/400 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 example illustrate how to transform bidi text:

  // Java data to AS/400 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 AS/400 data to Java layout: abt.setJavaStringType(BidiStringType.ST6); // Imp RTL // String dst = abt.toJavaLayout("some bidi string");


Constructor Summary
AS400BidiTransform(int as400Ccsid)
          Constructs an AS400BidiTransform object assuming that the AS/400 Bidi text conforms to a given CCSID.
 
Method Summary
 int getAS400Ccsid()
          Returns the current CCSID of AS/400 data.
 int getAS400StringType()
          Returns the current string type of AS/400 data.
 int getJavaStringType()
          Returns the current string type of Java data.
static int getStringType(int ccsid)
           
static boolean isBidiCcsid(int ccsid)
          Indicates if a given CCSID may apply to Bidi data.
 void setAS400Ccsid(int as400Ccsid)
          Sets the CCSID.
 void setAS400StringType(int as400Type)
          Set the explicit string type for AS/400 data.
 void setJavaStringType(int javaType)
          Set the explicit string type for Java data.
 java.lang.String toAS400Layout(java.lang.String javaText)
          Convert data from the Java layout to the AS/400 layout.
 java.lang.String toJavaLayout(java.lang.String as400Text)
          Convert data from the AS/400 layout to the Java layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AS400BidiTransform

public AS400BidiTransform(int as400Ccsid)
Constructs an AS400BidiTransform object assuming that the AS/400 Bidi text conforms to a given CCSID. Typically this will be the CCSID of the system.

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 AS/400 data layout and the Java data layout.

Parameters:
as400Ccsid - The CCSID of the AS/400 data.
Method Detail

isBidiCcsid

public static boolean isBidiCcsid(int ccsid)
Indicates if a given CCSID may apply to Bidi data. This is the case for Arabic and Hebrew CCSIDs, and for Unicode (which can encode anything).

If a CCSID is not Bidi, there is no need to perform layout transformations when converting AS/400 data to Java data and vice-versa.

Parameters:
ccsid - the CCSID to check.
Returns:
true if the given CCSID may apply to Bidi data, false otherwse.

setAS400Ccsid

public void setAS400Ccsid(int as400Ccsid)
Sets the CCSID.

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 AS/400 data layout and the Java data layout.

Parameters:
as400Ccsid - The CCSID of the AS/400 data.

getAS400Ccsid

public int getAS400Ccsid()
Returns the current CCSID of AS/400 data.
Returns:
The CCSID for the AS/400 data.

setAS400StringType

public void setAS400StringType(int as400Type)
Set the explicit string type for AS/400 data. Each CCSID has a default CDRA string type, which defines a set of Bidi flags. This method may be used to specify Bidi flags different from those implied by the CCSID.

The orientation implied by the new given string type is applied to both the AS/400 data layout and the Java data layout. The new string type is applied to the Java data layout by calling setJavaStringType(as400Type).

Parameters:
as400Type - The string type to apply to AS/400 data. The parameter string type should always be one of the constants defined in BidiStringType.
See Also:
BidiStringType

getAS400StringType

public int getAS400StringType()
Returns the current string type of AS/400 data.
Returns:
The string type of the AS/400 data.

setJavaStringType

public void setJavaStringType(int javaType)
Set the explicit string type for Java data. The parameter string type should always be one of the following defined in BidiStringType: ST5 (LTR), ST6 (RTL), ST10 (Contextual LTR), or ST11 (Contextual RTL). In fact, only the orientation of the given string type is used to modify the Bidi flags to apply to the Java data. The other Bidi flags of the Java data always conform to the Unicode standard.
Parameters:
javaType - The string type to apply to Java data.
See Also:
BidiStringType

getJavaStringType

public int getJavaStringType()
Returns the current string type of Java data.
Returns:
The string type of the Java data.

toJavaLayout

public java.lang.String toJavaLayout(java.lang.String as400Text)
Convert data from the AS/400 layout to the Java layout.
Parameters:
as400Text - The AS/400 string to convert.
Returns:
The same text in standard Java Bidi layout.

toAS400Layout

public java.lang.String toAS400Layout(java.lang.String javaText)
Convert data from the Java layout to the AS/400 layout.
Parameters:
javaText - The Java string to convert.
Returns:
The same text in AS/400 Bidi layout.

getStringType

public static int getStringType(int ccsid)