com.ibm.icu4jni.converters
Class NativeConverter

java.lang.Object
  |
  +--com.ibm.icu4jni.converters.NativeConverter

public final class NativeConverter
extends java.lang.Object

Class for accessing the underlying JNI methods

Status:
Internal. This API is Internal Only and can change at any time.

Field Summary
static int SKIP_CALLBACK
           
static int STOP_CALLBACK
           
static int SUBSTITUTE_CALLBACK
           
 
Constructor Summary
NativeConverter()
           
 
Method Summary
static boolean canDecode(long converterHandle, byte[] bytes)
          Ascertains if a given a byte sequence can be converted to Unicode
static boolean canEncode(long converterHandle, int codeUnit)
          Ascertains if a given Unicode code unit can be converted to the target encoding
static void closeConverter(long converterHandle)
          Closes the specified converter and releases the resources
static int convertByteToChar(long converterHandle, byte[] input, int inEnd, char[] output, int outEnd, int[] data, boolean flush)
          Converts an array of bytes containing characters in an external encoding into an array of Unicode characters.
static int convertCharToByte(long converterHandle, char[] input, int inEnd, byte[] output, int outEnd, int[] data, boolean flush)
          Converts an array of Unicode chars containing characters in an external encoding into an array of bytes.
static int countAliases(java.lang.String enc)
          Gets the number of aliases for a converter name
static int countAvailable()
          Gets the number of converters installed in the current installation of ICU
static int countInvalidBytes(long converterHandle, int[] length)
          Gets the numnber of invalid bytes in the specified converter object for the last error that has occured
static int countInvalidChars(long converterHandle, int[] length)
          Gets the numnber of invalid chars in the specified converter object for the last error that has occured
static int decode(long converterHandle, byte[] input, int inEnd, char[] output, int outEnd, int[] data, boolean flush)
          Converts an array of bytes containing characters in an external encoding into an array of Unicode characters.
static int encode(long converterHandle, char[] input, int inEnd, byte[] output, int outEnd, int[] data, boolean flush)
          Converts an array of Unicode chars containing characters in an external encoding into an array of bytes.
static int flushByteToChar(long converterHandle, char[] output, int outEnd, int[] data)
          Writes any remaining output to the output buffer and resets the converter to its initial state.
static int flushCharToByte(long converterHandle, byte[] output, int outEnd, int[] data)
          Writes any remaining output to the output buffer and resets the converter to its initial state.
static java.lang.String[] getAliases(java.lang.String enc)
          Gets the aliases associated with the converter name
static java.lang.String[] getAvailable()
          Gets the canonical names of available converters
static float getAveBytesPerChar(long converterHandle)
          Gets the average numnber of bytes needed for converting a char
static float getAveCharsPerByte(long converterHandle)
          Gets the average numnber of chars needed for converting a byte
static java.lang.String getCanonicalName(java.lang.String enc)
          Gets the canonical name of the converter
static int getMaxBytesPerChar(long converterHandle)
          Gets the number of bytes needed for converting a char
static int getMaxCharsPerByte(long converterHandle)
          Gets the number of chars needed for converting a byte
static java.lang.String getSubstitutionBytes(long converterHandle)
           
static int openConverter(long[] converterHandle, java.lang.String encoding)
          Open the converter with the specified encoding
static void resetByteToChar(long converterHandle)
          Resets the ByteToChar (toUnicode) state of specified converter
static void resetCharToByte(long converterHandle)
          Resets the CharToByte (fromUnicode) state of specified converter
static int safeClone(long converterHandle, long[] handleArr)
          Returns a thread safe clone of the converter
static int setCallbackDecode(long converterHandle, int mode, boolean stopOnIllegal)
          Sets the callback to Unicode for ICU conveter.
static int setCallbackEncode(long converterHandle, int mode, boolean stopOnIllegal)
          Sets the callback from Unicode for ICU conveter.
static int setSubstitutionBytes(long converterHandle, byte[] subChars, int length)
          Sets the substitution bytes of the specified converter used by decoder
static int setSubstitutionChars(long converterHandle, char[] subChars, int length)
          Sets the substitution Unicode chars of the specified converter used by encoder
static int setSubstitutionModeCharToByte(long converterHandle, boolean mode)
          Sets the substitution mode of CharToByte(fromUnicode) for the specified converter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STOP_CALLBACK

public static final int STOP_CALLBACK
See Also:
Constant Field Values
Status:
Internal. This API is Internal Only and can change at any time.

SKIP_CALLBACK

public static final int SKIP_CALLBACK
See Also:
Constant Field Values
Status:
Internal. This API is Internal Only and can change at any time.

SUBSTITUTE_CALLBACK

public static final int SUBSTITUTE_CALLBACK
See Also:
Constant Field Values
Status:
Internal. This API is Internal Only and can change at any time.
Constructor Detail

NativeConverter

public NativeConverter()
Method Detail

convertByteToChar

public static final int convertByteToChar(long converterHandle,
                                          byte[] input,
                                          int inEnd,
                                          char[] output,
                                          int outEnd,
                                          int[] data,
                                          boolean flush)
Converts an array of bytes containing characters in an external encoding into an array of Unicode characters. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. Among other things, this means multibyte input sequences can be split between calls. If a call to convert results in an Error, the conversion may be continued by calling convert again with suitably modified parameters. All conversions should be finished with a call to the flush method.

Parameters:
converterHandle - Address of converter object created by C code
input - byte array containing text to be converted.
inEnd - stop conversion at this offset in input array (exclusive).
output - character array to receive conversion result.
outEnd - stop writing to output array at this offset (exclusive).
data - integer array containing the following data data[0] = inputOffset data[1] = outputOffset
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

decode

public static final int decode(long converterHandle,
                               byte[] input,
                               int inEnd,
                               char[] output,
                               int outEnd,
                               int[] data,
                               boolean flush)
Converts an array of bytes containing characters in an external encoding into an array of Unicode characters. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. Among other things, this means multibyte input sequences can be split between calls. If a call to convert results in an Error, the conversion may be continued by calling convert again with suitably modified parameters. All conversions should be finished with a call to the flush method.

Parameters:
converterHandle - Address of converter object created by C code
input - byte array containing text to be converted.
inEnd - stop conversion at this offset in input array (exclusive).
output - character array to receive conversion result.
outEnd - stop writing to output array at this offset (exclusive).
data - integer array containing the following data data[0] = inputOffset data[1] = outputOffset
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

convertCharToByte

public static final int convertCharToByte(long converterHandle,
                                          char[] input,
                                          int inEnd,
                                          byte[] output,
                                          int outEnd,
                                          int[] data,
                                          boolean flush)
Converts an array of Unicode chars containing characters in an external encoding into an array of bytes. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. Among other things, this means multibyte input sequences can be split between calls. If a call to convert results in an Error, the conversion may be continued by calling convert again with suitably modified parameters. All conversions should be finished with a call to the flush method.

Parameters:
converterHandle - Address of converter object created by C code
input - char array containing text to be converted.
inEnd - stop conversion at this offset in input array (exclusive).
output - byte array to receive conversion result.
outEnd - stop writing to output array at this offset (exclusive).
data - integer array containing the following data data[0] = inputOffset data[1] = outputOffset
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

encode

public static final int encode(long converterHandle,
                               char[] input,
                               int inEnd,
                               byte[] output,
                               int outEnd,
                               int[] data,
                               boolean flush)
Converts an array of Unicode chars containing characters in an external encoding into an array of bytes. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. Among other things, this means multibyte input sequences can be split between calls. If a call to convert results in an Error, the conversion may be continued by calling convert again with suitably modified parameters. All conversions should be finished with a call to the flush method.

Parameters:
converterHandle - Address of converter object created by C code
input - char array containing text to be converted.
inEnd - stop conversion at this offset in input array (exclusive).
output - byte array to receive conversion result.
outEnd - stop writing to output array at this offset (exclusive).
data - integer array containing the following data data[0] = inputOffset data[1] = outputOffset
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

flushCharToByte

public static final int flushCharToByte(long converterHandle,
                                        byte[] output,
                                        int outEnd,
                                        int[] data)
Writes any remaining output to the output buffer and resets the converter to its initial state.

Parameters:
converterHandle - Address of converter object created by C code
output - byte array to receive flushed output.
outEnd - stop writing to output array at this offset (exclusive).
data - integer array containing the following data data[0] = inputOffset data[1] = outputOffset
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

flushByteToChar

public static final int flushByteToChar(long converterHandle,
                                        char[] output,
                                        int outEnd,
                                        int[] data)
Writes any remaining output to the output buffer and resets the converter to its initial state.

Parameters:
converterHandle - Address of converter object created by the native code
output - char array to receive flushed output.
outEnd - stop writing to output array at this offset (exclusive).
data - integer array containing the following data data[0] = inputOffset data[1] = outputOffset
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

openConverter

public static final int openConverter(long[] converterHandle,
                                      java.lang.String encoding)
Open the converter with the specified encoding

Parameters:
converterHandle - long array for recieving the adress of converter object created by the native code
encoding - string representing encoding
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

resetByteToChar

public static final void resetByteToChar(long converterHandle)
Resets the ByteToChar (toUnicode) state of specified converter

Parameters:
converterHandle - Address of converter object created by the native code
Status:
Internal. This API is Internal Only and can change at any time.

resetCharToByte

public static final void resetCharToByte(long converterHandle)
Resets the CharToByte (fromUnicode) state of specified converter

Parameters:
converterHandle - Address of converter object created by the native code
Status:
Internal. This API is Internal Only and can change at any time.

closeConverter

public static final void closeConverter(long converterHandle)
Closes the specified converter and releases the resources

Parameters:
converterHandle - Address of converter object created by the native code
Status:
Internal. This API is Internal Only and can change at any time.

setSubstitutionChars

public static final int setSubstitutionChars(long converterHandle,
                                             char[] subChars,
                                             int length)
Sets the substitution Unicode chars of the specified converter used by encoder

Parameters:
converterHandle - Address of converter object created by the native code
subChars - array of chars to used for substitution
length - length of the array
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

setSubstitutionBytes

public static final int setSubstitutionBytes(long converterHandle,
                                             byte[] subChars,
                                             int length)
Sets the substitution bytes of the specified converter used by decoder

Parameters:
converterHandle - Address of converter object created by the native code
subChars - array of bytes to used for substitution
length - length of the array
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

setSubstitutionModeCharToByte

public static final int setSubstitutionModeCharToByte(long converterHandle,
                                                      boolean mode)
Sets the substitution mode of CharToByte(fromUnicode) for the specified converter

Parameters:
converterHandle - Address of converter object created by the native code
mode - to set the true/false
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

countInvalidBytes

public static final int countInvalidBytes(long converterHandle,
                                          int[] length)
Gets the numnber of invalid bytes in the specified converter object for the last error that has occured

Parameters:
converterHandle - Address of converter object created by the native code
length - array of int to recieve length of the array
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

countInvalidChars

public static final int countInvalidChars(long converterHandle,
                                          int[] length)
Gets the numnber of invalid chars in the specified converter object for the last error that has occured

Parameters:
converterHandle - Address of converter object created by the native code
length - array of int to recieve length of the array
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

getMaxBytesPerChar

public static final int getMaxBytesPerChar(long converterHandle)
Gets the number of bytes needed for converting a char

Parameters:
converterHandle - Address of converter object created by the native code
Returns:
number of bytes needed
Status:
Internal. This API is Internal Only and can change at any time.

getAveBytesPerChar

public static final float getAveBytesPerChar(long converterHandle)
Gets the average numnber of bytes needed for converting a char

Parameters:
converterHandle - Address of converter object created by the native code
Returns:
number of bytes needed
Status:
Internal. This API is Internal Only and can change at any time.

getMaxCharsPerByte

public static final int getMaxCharsPerByte(long converterHandle)
Gets the number of chars needed for converting a byte

Parameters:
converterHandle - Address of converter object created by the native code
Returns:
number of bytes needed
Status:
Internal. This API is Internal Only and can change at any time.

getAveCharsPerByte

public static final float getAveCharsPerByte(long converterHandle)
Gets the average numnber of chars needed for converting a byte

Parameters:
converterHandle - Address of converter object created by the native code
Returns:
number of bytes needed
Status:
Internal. This API is Internal Only and can change at any time.

getSubstitutionBytes

public static final java.lang.String getSubstitutionBytes(long converterHandle)

canEncode

public static final boolean canEncode(long converterHandle,
                                      int codeUnit)
Ascertains if a given Unicode code unit can be converted to the target encoding

Parameters:
converterHandle - Address of converter object created by the native code
Returns:
true if a character can be converted
Status:
Internal. This API is Internal Only and can change at any time.

canDecode

public static final boolean canDecode(long converterHandle,
                                      byte[] bytes)
Ascertains if a given a byte sequence can be converted to Unicode

Parameters:
converterHandle - Address of converter object created by the native code
Returns:
true if a character can be converted
Status:
Internal. This API is Internal Only and can change at any time.

countAvailable

public static final int countAvailable()
Gets the number of converters installed in the current installation of ICU

Returns:
int number of converters installed
Status:
Internal. This API is Internal Only and can change at any time.

getAvailable

public static final java.lang.String[] getAvailable()
Gets the canonical names of available converters

Returns:
Object[] names as an object array
Status:
Internal. This API is Internal Only and can change at any time.

countAliases

public static final int countAliases(java.lang.String enc)
Gets the number of aliases for a converter name

Returns:
number of aliases for the converter
Status:
Internal. This API is Internal Only and can change at any time.

getAliases

public static final java.lang.String[] getAliases(java.lang.String enc)
Gets the aliases associated with the converter name

Returns:
converter names as elements in an object array
Status:
Internal. This API is Internal Only and can change at any time.

getCanonicalName

public static final java.lang.String getCanonicalName(java.lang.String enc)
Gets the canonical name of the converter

Returns:
canonical name of the converter
Status:
Internal. This API is Internal Only and can change at any time.

setCallbackDecode

public static final int setCallbackDecode(long converterHandle,
                                          int mode,
                                          boolean stopOnIllegal)
Sets the callback to Unicode for ICU conveter. The default behaviour of ICU callback is to call the specified callback function for both illegal and unmapped sequences.

Parameters:
converterHandle - Adress of the converter object created by native code
mode - call back mode to set. This is either STOP_CALLBACK, SKIP_CALLBACK or SUBSTITUE_CALLBACK The converter performs the specified callback when an error occurs
stopOnIllegal - If true sets the alerts the converter callback to stop on an illegal sequence
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

setCallbackEncode

public static final int setCallbackEncode(long converterHandle,
                                          int mode,
                                          boolean stopOnIllegal)
Sets the callback from Unicode for ICU conveter. The default behaviour of ICU callback is to call the specified callback function for both illegal and unmapped sequences.

Parameters:
converterHandle - Adress of the converter object created by native code
mode - call back mode to set. This is either STOP_CALLBACK, SKIP_CALLBACK or SUBSTITUE_CALLBACK The converter performs the specified callback when an error occurs
stopOnIllegal - If true sets the alerts the converter callback to stop on an illegal sequence
Returns:
int error code returned by ICU
Status:
Internal. This API is Internal Only and can change at any time.

safeClone

public static final int safeClone(long converterHandle,
                                  long[] handleArr)
Returns a thread safe clone of the converter

Status:
Internal. This API is Internal Only and can change at any time.