com.ibm.as400.access
Class CharConverter

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

public class CharConverter
extends java.lang.Object
implements java.io.Serializable

A character set converter between Java String objects and AS/400 native code pages.

See Also:
Serialized Form

Constructor Summary
CharConverter()
          Deprecated. Replaced by CharConverter(int, AS400). Any CharConverter object that is created without specifying an AS400 system object on its constructor may not behave as expected in certain environments.
CharConverter(int ccsid)
          Deprecated. Replaced by CharConverter(int, AS400). Any CharConverter object that is created without specifying an AS400 system object on its constructor may not behave as expected in certain environments.
CharConverter(int ccsid, AS400 system)
          Gets a CharConverter object from the pool using the specified ccsid and system.
CharConverter(java.lang.String encoding)
          Deprecated. Replaced by CharConverter(int, AS400). Any CharConverter object that is created without specifying an AS400 system object on its constructor may not behave as expected in certain environments.
 
Method Summary
static java.lang.String byteArrayToString(AS400 system, byte[] source)
          Converts the specified bytes into a String.
 java.lang.String byteArrayToString(byte[] source)
          Converts the specified bytes into a String.
 java.lang.String byteArrayToString(byte[] source, int offset)
          Converts the specified bytes into a String.
 java.lang.String byteArrayToString(byte[] source, int offset, int length)
          Converts the specified bytes into a String.
 java.lang.String byteArrayToString(byte[] source, int offset, int length, int type)
          Converts the specified bytes into a String.
static java.lang.String byteArrayToString(int ccsid, AS400 system, byte[] source)
          Converts the specified bytes into a String.
 int getCcsid()
          Returns the ccsid of this conversion object.
 java.lang.String getEncoding()
          Returns the encoding of this conversion object.
static boolean isFaultTolerantConversion()
          Indicates if conversion is fault tolerant.
static void setFaultTolerantConversion(boolean faultTolerantConversion)
          Enables fault tolerant conversion.
static byte[] stringToByteArray(AS400 system, java.lang.String source)
          Converts the specified String into bytes.
static byte[] stringToByteArray(int ccsid, AS400 system, java.lang.String source)
          Converts the specified String into bytes.
 byte[] stringToByteArray(java.lang.String source)
          Converts the specified String into bytes.
 void stringToByteArray(java.lang.String source, byte[] destination)
          Converts the specified String into bytes.
 void stringToByteArray(java.lang.String source, byte[] destination, int offset)
          Converts the specified String into bytes.
 void stringToByteArray(java.lang.String source, byte[] destination, int offset, int length)
          Converts the specified String into bytes.
 void stringToByteArray(java.lang.String source, byte[] destination, int offset, int length, int type)
          Converts the specified String into bytes.
 byte[] stringToByteArray(java.lang.String source, int type)
          Converts the specified String into bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharConverter

public CharConverter()
Deprecated. Replaced by CharConverter(int, AS400). Any CharConverter object that is created without specifying an AS400 system object on its constructor may not behave as expected in certain environments.

Gets a CharConverter object from the pool using a "best guess" based on the default Locale.

CharConverter

public CharConverter(java.lang.String encoding)
              throws java.io.UnsupportedEncodingException
Deprecated. Replaced by CharConverter(int, AS400). Any CharConverter object that is created without specifying an AS400 system object on its constructor may not behave as expected in certain environments.

Gets a CharConverter object from the pool using the specified character encoding.
Parameters:
encoding - the name of a character encoding.
Throws:
java.io.UnsupportedEncodingException - If the encoding is not supported.

CharConverter

public CharConverter(int ccsid)
              throws java.io.UnsupportedEncodingException
Deprecated. Replaced by CharConverter(int, AS400). Any CharConverter object that is created without specifying an AS400 system object on its constructor may not behave as expected in certain environments.

Gets a CharConverter object from the pool using the specified ccsid.
Parameters:
ccsid - the CCSID of the AS/400 text.
Throws:
java.io.UnsupportedEncodingException - If the ccsid is not supported.

CharConverter

public CharConverter(int ccsid,
                     AS400 system)
              throws java.io.UnsupportedEncodingException
Gets a CharConverter object from the pool using the specified ccsid and system.
Parameters:
ccsid - the CCSID of the AS/400 text.
system - the 400 to go to for table
Throws:
java.io.UnsupportedEncodingException - If the ccsid is not supported.
Method Detail

byteArrayToString

public java.lang.String byteArrayToString(byte[] source)
Converts the specified bytes into a String.
Parameters:
source - the bytes to convert.
Returns:
the resultant String.

byteArrayToString

public java.lang.String byteArrayToString(byte[] source,
                                          int offset)
Converts the specified bytes into a String.
Parameters:
source - the bytes to convert.
offset - the offset into the source array for the start of the data.
Returns:
the resultant String.

byteArrayToString

public java.lang.String byteArrayToString(byte[] source,
                                          int offset,
                                          int length)
Converts the specified bytes into a String.
Parameters:
source - the bytes to convert.
offset - the offset into the source array for the start of the data.
length - the number of bytes of data to read from the array.
Returns:
the resultant String.

byteArrayToString

public java.lang.String byteArrayToString(byte[] source,
                                          int offset,
                                          int length,
                                          int type)
Converts the specified bytes into a String.
Parameters:
source - the bytes to convert.
offset - the offset into the source array for the start of the data.
length - the number of bytes of data to read from the array.
type - The bidi string type, as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Returns:
the resultant String.
See Also:
BidiStringType

byteArrayToString

public static java.lang.String byteArrayToString(AS400 system,
                                                 byte[] source)
Converts the specified bytes into a String.
Parameters:
system - the 400 to go to for table
source - the bytes to convert.
Returns:
the resultant String.

byteArrayToString

public static java.lang.String byteArrayToString(int ccsid,
                                                 AS400 system,
                                                 byte[] source)
                                          throws java.io.UnsupportedEncodingException
Converts the specified bytes into a String.
Parameters:
ccsid - the CCSID of the AS/400 text.
system - the 400 to go to for table
source - the bytes to convert.
Returns:
the resultant String.
Throws:
java.io.UnsupportedEncodingException - If the ccsid is not supported.

getCcsid

public int getCcsid()
Returns the ccsid of this conversion object.
Returns:
the ccsid.

getEncoding

public java.lang.String getEncoding()
Returns the encoding of this conversion object.
Returns:
the encoding.

isFaultTolerantConversion

public static boolean isFaultTolerantConversion()
Indicates if conversion is fault tolerant.
Returns:
true if conversion is fault tolerant, false otherwise.

setFaultTolerantConversion

public static void setFaultTolerantConversion(boolean faultTolerantConversion)
Enables fault tolerant conversion. Fault tolerant conversion allows incomplete EBCDIC character data to be converted without throwing an exception. This is a static setting and affects all subsequent character conversion. Fault tolerant conversion may adversly affect performance and memory usage during character conversion. The default is false.
Parameters:
faultTolerantConversion - true to enable fault tolerant conversion, false otherwise.

stringToByteArray

public byte[] stringToByteArray(java.lang.String source)
Converts the specified String into bytes.
Parameters:
source - the String to convert.
Returns:
the resultant byte array.

stringToByteArray

public byte[] stringToByteArray(java.lang.String source,
                                int type)
Converts the specified String into bytes.
Parameters:
source - the String to convert.
type - the output string type as defined by the CDRA (Character Data Respresentation Architecture). One of the following constants defined in BidiStringType: ST5 (LTR), ST6 (RTL), ST10 (Contextual LTR), or ST11 (Contextual RTL).
Returns:
the resultant byte array.
See Also:
BidiStringType

stringToByteArray

public void stringToByteArray(java.lang.String source,
                              byte[] destination)
                       throws java.io.CharConversionException
Converts the specified String into bytes.
Parameters:
source - the String to convert.
destination - the destination byte array.
Throws:
java.io.CharConversionException - If destination is not large enough to hold the converted string.

stringToByteArray

public void stringToByteArray(java.lang.String source,
                              byte[] destination,
                              int offset)
                       throws java.io.CharConversionException
Converts the specified String into bytes.
Parameters:
source - the String to convert.
destination - the destination byte array.
offset - the offset into the destination array for the start of the data.
Throws:
java.io.CharConversionException - If destination is not large enough to hold the converted string.

stringToByteArray

public void stringToByteArray(java.lang.String source,
                              byte[] destination,
                              int offset,
                              int length)
                       throws java.io.CharConversionException
Converts the specified String into bytes.
Parameters:
source - the String to convert.
destination - the destination byte array.
offset - the offset into the destination array for the start of the data.
length - the number of bytes of data to write into the array.
Throws:
java.io.CharConversionException - If destination is not large enough to hold the converted string.

stringToByteArray

public void stringToByteArray(java.lang.String source,
                              byte[] destination,
                              int offset,
                              int length,
                              int type)
                       throws java.io.CharConversionException
Converts the specified String into bytes.
Parameters:
source - the String to convert.
destination - the destination byte array.
offset - the offset into the destination array for the start of the data.
length - the number of bytes of data to write into the array.
type - The bidi string type, as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Throws:
java.io.CharConversionException - If destination is not large enough to hold the converted string.
See Also:
BidiStringType

stringToByteArray

public static byte[] stringToByteArray(AS400 system,
                                       java.lang.String source)
Converts the specified String into bytes.
Parameters:
system - the 400 to go to for table
source - the String to convert.
Returns:
the destination byte array.

stringToByteArray

public static byte[] stringToByteArray(int ccsid,
                                       AS400 system,
                                       java.lang.String source)
                                throws java.io.UnsupportedEncodingException
Converts the specified String into bytes.
Parameters:
ccsid - the CCSID of the AS/400 text.
system - the 400 to go to for table
source - the String to convert.
Returns:
the destination byte array.
Throws:
java.io.UnsupportedEncodingException - If the ccsid is not supported.