Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.util
Class ISeriesCodepageConverter

java.lang.Object
  extended by com.ibm.etools.iseries.util.ISeriesCodepageConverter

public class ISeriesCodepageConverter
extends Object

Clients should not instantiate this class


Field Summary
static int CCSID_ISO88591
           
static int CCSID_NO_CONVERSION
           
static int CCSID_UTF8
           
static String Copyright
           
static byte EBCDIC_SPACE
           
static String ENCODING_UTF8
           
static byte SHIFT_IN
           
static byte SHIFT_OUT
           
 
Constructor Summary
ISeriesCodepageConverter(AS400 as400)
          Constructor for ISeriesCodepageConverter
ISeriesCodepageConverter(AS400 as400, boolean leaveVisual)
          Create a code page converter which will optionally convert to logical or not as specified if the CCSID is bidirectional.
ISeriesCodepageConverter(int ccsid, AS400 as400)
          Constructor for ISeriesCodepageConverter
ISeriesCodepageConverter(int ccsid, AS400 as400, boolean leaveVisual)
          Create a code page converter which will optionally convert to logical or not as specified if the CCSID is bidirectional.
 
Method Summary
 byte[] convClientBytesToHostBytes(byte[] source, int offset, int length)
          Deprecated. this method only works if the CCSID is supported on the locale, its recommended to use either: convClientBytesToHostBytesUTF8(byte[] source, int offset, int length) or convClientBytesToHostBytes(byte[] source, int offset, int length, String encoding)
 byte[] convClientBytesToHostBytes(byte[] source, int offset, int length, String encoding)
          Converts the specified source byte array into the destination byte array.
 byte[] convClientBytesToHostBytes(int targetCCSID, byte[] source)
          Converts the specified source byte array into the destination byte array.
 byte[] convClientBytesToHostBytes(int targetCCSID, byte[] source, String encoding)
          Converts the specified source byte array into the destination byte array.
 byte[] convClientBytesToHostBytesUTF8(byte[] source, int offset, int length)
          Converts the specified source byte array into the destination byte array.
 byte[] convClientBytesToHostBytesUTF8(int targetCCSID, byte[] source)
          Converts the specified source byte array into the destination byte array.
 byte[] convClientStringToHostBytes(int targetCCSID, String source)
          Converts the specified Java source string into a byte array.
static byte[] convertContiguousShiftInShiftOutToSpaces(byte[] input)
          Scan the input byte array and convert any sequence of SHIFT IN (0x0F) immediately followed by a SHIFT OUT (0x0E) to two spaces (0x40 0x40).
static String convertHostBytesToClientString(byte[] ebcdicBytes, int offset, int textLength, AS400 as400)
          Convert from host bytes to Java String If bidi, uses proper transform to create smart logical format with directional marks
 byte[] convHostBytesToClientBytes(byte[] source, int offset, int length)
          Converts the specified source byte array from the host into a destination byte array.
 byte[] convHostBytesToClientBytes(byte[] source, int offset, int length, String encoding)
          Converts the specified source byte array into a destination byte array.
 byte[] convHostBytesToClientBytes(int sourceCCSID, byte[] source)
          Deprecated. this will only work if the local encoding supports this CCSID, use convHostBytesToClientBytes(int sourceCCSID, byte[] source, String encoding) or convHostBytesToClientBytesUTF8(int sourceCCSID, byte[] source)
 byte[] convHostBytesToClientBytes(int sourceCCSID, byte[] source, String encoding)
          Converts the specified source byte array into a destination byte array.
 byte[] convHostBytesToClientBytesUTF8(byte[] source, int offset, int length)
          Converts the specified source byte array from the host into a destination byte array.
 byte[] convHostBytesToClientBytesUTF8(int sourceCCSID, byte[] source)
          Converts the specified source byte array from the host into a destination byte array.
 String convHostBytesToClientString(byte[] source, int offset, int length)
          Converts the specified bytes into a Java string.
 String convHostBytesToClientString(int sourceCCSID, byte[] source)
          Converts the specified bytes into a Java string.
 AS400 getAS400Object()
          Returns the AS400 object
static String getEncoding(int ccsidVal)
          Returns the encoding given the CCSID
 void setAS400Object(AS400 as400)
          Set the AS400 object
 String xlateNameToHostEquiv(String name)
          Updates all special characters (including variant) in the string to return the equivalent name on the server.
 String xlateNameToVisualEquiv(String equivNameOnServer)
          Gets the visual equivalent of the name given the server equivalent of that name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Copyright

public static final String Copyright
See Also:
Constant Field Values

CCSID_NO_CONVERSION

public static final int CCSID_NO_CONVERSION
See Also:
Constant Field Values

SHIFT_IN

public static final byte SHIFT_IN
See Also:
Constant Field Values

SHIFT_OUT

public static final byte SHIFT_OUT
See Also:
Constant Field Values

EBCDIC_SPACE

public static final byte EBCDIC_SPACE
See Also:
Constant Field Values

CCSID_UTF8

public static final int CCSID_UTF8
See Also:
Constant Field Values

ENCODING_UTF8

public static final String ENCODING_UTF8
See Also:
Constant Field Values

CCSID_ISO88591

public static final int CCSID_ISO88591
See Also:
Constant Field Values
Constructor Detail

ISeriesCodepageConverter

public ISeriesCodepageConverter(AS400 as400)
Constructor for ISeriesCodepageConverter


ISeriesCodepageConverter

public ISeriesCodepageConverter(AS400 as400,
                                boolean leaveVisual)
Create a code page converter which will optionally convert to logical or not as specified if the CCSID is bidirectional.

Parameters:
as400 - The iSeries to connect to
leaveVisual - true if you don't want to convert to logical, false if you want to convert from visual to logical and back.
Since:
6.0.1

ISeriesCodepageConverter

public ISeriesCodepageConverter(int ccsid,
                                AS400 as400,
                                boolean leaveVisual)
                         throws UnsupportedEncodingException
Create a code page converter which will optionally convert to logical or not as specified if the CCSID is bidirectional.

Parameters:
ccsid - The CCSID to user for conversion
as400 - The iSeries to connect to
leaveVisual - true if you don't want to convert to logical, false if you want to convert from visual to logical and back.
Throws:
UnsupportedEncodingException - Thrown when the CCSID is not supported on the specified iSeries.
Since:
6.0.1

ISeriesCodepageConverter

public ISeriesCodepageConverter(int ccsid,
                                AS400 as400)
                         throws UnsupportedEncodingException
Constructor for ISeriesCodepageConverter

Throws:
UnsupportedEncodingException
Method Detail

getAS400Object

public AS400 getAS400Object()
Returns the AS400 object


setAS400Object

public void setAS400Object(AS400 as400)
Set the AS400 object


convHostBytesToClientString

public String convHostBytesToClientString(int sourceCCSID,
                                          byte[] source)
                                   throws UnsupportedEncodingException
Converts the specified bytes into a Java string. The CCSID to be passed in is the CCSID of the source. The string uses the default encoding that the JVM determines. This method can be called either on the client or on the host.

Parameters:
the - source CCSID
the - source bytes
Returns:
the client string
Throws:
UnsupportedEncodingException

convHostBytesToClientString

public String convHostBytesToClientString(byte[] source,
                                          int offset,
                                          int length)
Converts the specified bytes into a Java string. The string uses the default encoding that the JVM determines. This method can be called either on the client or on the host.

Parameters:
the - source bytes
the - offset in the byte array
the - number of bytes of the array to convert starting at the offset
Returns:
the client string

convHostBytesToClientBytes

public byte[] convHostBytesToClientBytes(int sourceCCSID,
                                         byte[] source)
                                  throws UnsupportedEncodingException
Deprecated. this will only work if the local encoding supports this CCSID, use convHostBytesToClientBytes(int sourceCCSID, byte[] source, String encoding) or convHostBytesToClientBytesUTF8(int sourceCCSID, byte[] source)

Converts the specified source byte array from the host into a destination byte array. The CCSID to be passed in is the CCSID of the source. This method converts the source byte array to a Java string, and then uses the default encoding (which the JVM determines) to convert that string to the destination byte array. This method should only be called if it is used on the client, as the encoding of the client workstation and the host may not be the same (although it very often is).

Parameters:
the - source CCSID
the - source bytes
Returns:
the client byte array
Throws:
UnsupportedEncodingException

convHostBytesToClientBytes

public byte[] convHostBytesToClientBytes(byte[] source,
                                         int offset,
                                         int length)
                                  throws UnsupportedEncodingException
Converts the specified source byte array from the host into a destination byte array. This method converts the source byte array to a Java string, and then uses the default encoding (which the JVM determines) to convert that string to the destination byte array. This method should only be called if it is used on the client, as the encoding of the client workstation and the host may not be the same (although it very often is).

Parameters:
the - source CCSID
the - source bytes
the - offset in the byte array
the - number of bytes of the array to convert starting at the offset
Returns:
the client byte array
Throws:
UnsupportedEncodingException

convHostBytesToClientBytesUTF8

public byte[] convHostBytesToClientBytesUTF8(int sourceCCSID,
                                             byte[] source)
                                      throws UnsupportedEncodingException
Converts the specified source byte array from the host into a destination byte array. The CCSID to be passed in is the CCSID of the source. This method converts the source byte array to a Java string, and then uses UTF-8 encoding to convert that string to the destination byte array. This method can be called on the client or on the host.

Parameters:
the - source CCSID
the - source bytes
Returns:
the client byte array
Throws:
UnsupportedEncodingException

convHostBytesToClientBytesUTF8

public byte[] convHostBytesToClientBytesUTF8(byte[] source,
                                             int offset,
                                             int length)
                                      throws UnsupportedEncodingException
Converts the specified source byte array from the host into a destination byte array. This method converts the source byte array to a Java string, and then uses UTF-8 encoding to convert that string to the destination byte array. This method can be called on the client or on the host.

Parameters:
the - source CCSID
the - source bytes
the - offset in the byte array
the - number of bytes of the array to convert starting at the offset
Returns:
the client byte array
Throws:
UnsupportedEncodingException

convHostBytesToClientBytes

public byte[] convHostBytesToClientBytes(int sourceCCSID,
                                         byte[] source,
                                         String encoding)
                                  throws UnsupportedEncodingException
Converts the specified source byte array into a destination byte array. The CCSID to be passed in is the CCSID of the source. This method converts the source byte array to a Java string, and then uses the passed in encoding to convert that string to the destination byte array. This method can be called on the client or on the host.

Parameters:
the - source CCSID
the - source bytes
the - encoding to be used for the target bytes
Returns:
the client byte array
Throws:
UnsupportedEncodingException

convHostBytesToClientBytes

public byte[] convHostBytesToClientBytes(byte[] source,
                                         int offset,
                                         int length,
                                         String encoding)
                                  throws UnsupportedEncodingException
Converts the specified source byte array into a destination byte array. The CCSID to be passed in is the CCSID of the source. This method converts the source byte array to a Java string, and then uses the passed in encoding to convert that string to the destination byte array. This method can be called on the client or on the host.

Parameters:
the - source bytes
the - offset in the byte array
the - number of bytes of the array to convert starting at the offset
the - encoding to be used for the target bytes
Returns:
the client byte array
Throws:
UnsupportedEncodingException

convClientStringToHostBytes

public byte[] convClientStringToHostBytes(int targetCCSID,
                                          String source)
                                   throws UnsupportedEncodingException
Converts the specified Java source string into a byte array. The target CCSID is used to convert to the correct byte array. This method should only be used if the conversion is done on the client, since it assumes that the String has the default encoding as detemined by the JVM.

Parameters:
the - target CCSID
the - source string
Returns:
the host bytes
Throws:
UnsupportedEncodingException

convClientBytesToHostBytes

public byte[] convClientBytesToHostBytes(int targetCCSID,
                                         byte[] source)
                                  throws UnsupportedEncodingException
Converts the specified source byte array into the destination byte array. The default encoding is assumed to convert the source byte array into a string, and then the target CCSID value is used to convert the string to the destination byte array. This method should only be used on the client.

Parameters:
the - target CCSID
the - source bytes
Returns:
the host bytes
Throws:
UnsupportedEncodingException

convClientBytesToHostBytes

public byte[] convClientBytesToHostBytes(byte[] source,
                                         int offset,
                                         int length)
                                  throws UnsupportedEncodingException
Deprecated. this method only works if the CCSID is supported on the locale, its recommended to use either: convClientBytesToHostBytesUTF8(byte[] source, int offset, int length) or convClientBytesToHostBytes(byte[] source, int offset, int length, String encoding)

Converts the specified source byte array into the destination byte array. The default encoding is assumed to convert the source byte array into a string, and CCSID of the object is used to convert the string to the destination byte array. This method should only be used on the client.

Parameters:
the - source bytes
the - offset of the byte array
the - number of bytes to convert from the byte array starting at the offset
Returns:
the host bytes
Throws:
UnsupportedEncodingException

convClientBytesToHostBytesUTF8

public byte[] convClientBytesToHostBytesUTF8(int targetCCSID,
                                             byte[] source)
                                      throws UnsupportedEncodingException
Converts the specified source byte array into the destination byte array. UTF-8 encoding is used to convert the source byte array into a string, and then the target CCSID value is used to convert the string to the destination byte array. This method can be used on the client or on the host.

Parameters:
the - target CCSID
the - source bytes
Returns:
the host bytes
Throws:
UnsupportedEncodingException

convClientBytesToHostBytesUTF8

public byte[] convClientBytesToHostBytesUTF8(byte[] source,
                                             int offset,
                                             int length)
                                      throws UnsupportedEncodingException
Converts the specified source byte array into the destination byte array. UTF-8 encoding is used to convert the source byte array into a string, and then the CCSID of the object is used to convert the string to the destination byte array. This method can be used on the client or on the host.

Parameters:
the - source bytes
the - offset in the byte array
the - number of bytes to convert from the source array starting at the offset
Returns:
the host bytes
Throws:
UnsupportedEncodingException

convClientBytesToHostBytes

public byte[] convClientBytesToHostBytes(int targetCCSID,
                                         byte[] source,
                                         String encoding)
                                  throws UnsupportedEncodingException
Converts the specified source byte array into the destination byte array. The encoding passed in is used to convert the source byte array into a string, and then the target CCSID value is used to convert the string to the destination byte array. This method should only be used on the client.

Parameters:
the - target CCSID
the - source bytes
the - encoding to be used to read in the source bytes
Returns:
the host bytes
Throws:
UnsupportedEncodingException

convClientBytesToHostBytes

public byte[] convClientBytesToHostBytes(byte[] source,
                                         int offset,
                                         int length,
                                         String encoding)
                                  throws UnsupportedEncodingException
Converts the specified source byte array into the destination byte array. The given encoding is used to convert the source byte array into a string, and then the CCSID of the object is used to convert the string to the destination byte array. This method can be used on the client or on the host.

Parameters:
the - source bytes
the - offset in the byte array
the - number of bytes to convert from the source array starting at the offset
the - encoding to be used to read in the source bytes
Returns:
the host bytes
Throws:
UnsupportedEncodingException

xlateNameToHostEquiv

public String xlateNameToHostEquiv(String name)
                            throws UnsupportedEncodingException
Updates all special characters (including variant) in the string to return the equivalent name on the server.

Parameters:
the - name
Returns:
the equivalent string using CCSID 37
Throws:
UnsupportedEncodingException

xlateNameToVisualEquiv

public String xlateNameToVisualEquiv(String equivNameOnServer)
                              throws UnsupportedEncodingException
Gets the visual equivalent of the name given the server equivalent of that name. Can be different only if variant characters are included in the string. Does the exact opposite of xlateNameToHostEquiv().

Parameters:
the - host equivalent name
Returns:
the equivalent string in the system CCSID
Throws:
UnsupportedEncodingException

getEncoding

public static String getEncoding(int ccsidVal)
                          throws UnsupportedEncodingException
Returns the encoding given the CCSID

Returns:
the encoding
Throws:
UnsupportedEncodingException

convertContiguousShiftInShiftOutToSpaces

public static byte[] convertContiguousShiftInShiftOutToSpaces(byte[] input)
Scan the input byte array and convert any sequence of SHIFT IN (0x0F) immediately followed by a SHIFT OUT (0x0E) to two spaces (0x40 0x40). This is required by DBCS in order to preserve spacing, otherwise the back to back shift in / out characters are lost during the round trip translation from EBCDIC -> UNICODE -> EBCDIC. Source: Masahiro Mikami/Japan/IBM@IBMJP (in a note to Edmund Reinhardt) I think we need to support DBCS string . Some Japanese customers may be coding DBCS string to in the fixed field of DDS. It is thought that a small number of customer has such DDS sauce. In this case, the shift code is treated like the space which divides a string. In order that the blank on appearance is lost by conversion of a string, the problem of screen display occurs on these customers. And it is required that the blank is contained on DDS sauce downloaded to PC, like 'D D'. Thank you for your consideration. Masahiro Mikami Techline No.3 Technical Support-Japan Phone: 81-3-5572-2359 (1803-2359)


convertHostBytesToClientString

public static String convertHostBytesToClientString(byte[] ebcdicBytes,
                                                    int offset,
                                                    int textLength,
                                                    AS400 as400)
Convert from host bytes to Java String If bidi, uses proper transform to create smart logical format with directional marks

Parameters:
ebcdicBytes - - array of EBCDIC host data
offset - - offset into host array
textLength - - number of bytes to convert
as400 - - toolbox reference to host
Returns:

Rational Developer for Power Systems Software
V7.6

Copyright © 2011 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.