com.ibm.icu4jni.converters
Class NativeConverter

java.lang.Object
  extended bycom.ibm.icu4jni.converters.NativeConverter

public final class NativeConverter
extends java.lang.Object

Class for accessing the underlying JNI methods

Status:
Internal. This API is ICU internal only.

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 boolean contains(long converterHandle1, long converterHandle2)
          Determines whether charset1 contains charset2.
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 java.lang.String getICUCanonicalName(java.lang.String enc)
          Gets the canonical name of the converter as defined by Java
static java.lang.String getJavaCanonicalName(java.lang.String icuCanonicalName)
          Gets the canonical name of the converter as defined by Java
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 int getMinBytesPerChar(long converterHandle)
          Gets the number of bytes needed for converting a char
static byte[] 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 onMalformedInput, int onUnmappableInput, char[] subChars, int length)
          Sets the callback to Unicode for ICU conveter.
static int setCallbackEncode(long converterHandle, int onMalformedInput, int onUnmappableInput, byte[] subBytes, int length)
          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 setSubstitutionModeByteToChar(long converterHandle, boolean mode)
          Sets the substitution mode of CharToByte(fromUnicode) for the specified converter
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 ICU internal only.

SKIP_CALLBACK

public static final int SKIP_CALLBACK
See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

SUBSTITUTE_CALLBACK

public static final int SUBSTITUTE_CALLBACK
See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.
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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

setSubstitutionModeByteToChar

public static final int setSubstitutionModeByteToChar(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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

getMinBytesPerChar

public static final int getMinBytesPerChar(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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

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 ICU internal only.

contains

public static final boolean contains(long converterHandle1,
                                     long converterHandle2)
Determines whether charset1 contains charset2.


getSubstitutionBytes

public static final byte[] 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
codeUnit - the character to be converted
Returns:
true if a character can be converted
Status:
Internal. This API is ICU internal only.

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
bytes - the bytes to be converted
Returns:
true if a character can be converted
Status:
Internal. This API is ICU internal only.

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 ICU internal only.

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 ICU internal only.

countAliases

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

Parameters:
enc - encoding name
Returns:
number of aliases for the converter
Status:
Internal. This API is ICU internal only.

getAliases

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

Parameters:
enc - converter name
Returns:
converter names as elements in an object array
Status:
Internal. This API is ICU internal only.

getCanonicalName

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

Parameters:
enc - converter name
Returns:
canonical name of the converter
Status:
Internal. This API is ICU internal only.

getICUCanonicalName

public static final java.lang.String getICUCanonicalName(java.lang.String enc)
Gets the canonical name of the converter as defined by Java

Parameters:
enc - converter name
Returns:
canonical name of the converter
Status:
Internal. This API is ICU internal only.

getJavaCanonicalName

public static final java.lang.String getJavaCanonicalName(java.lang.String icuCanonicalName)
Gets the canonical name of the converter as defined by Java

Parameters:
icuCanonicalName - converter name
Returns:
canonical name of the converter
Status:
Internal. This API is ICU internal only.

setCallbackDecode

public static final int setCallbackDecode(long converterHandle,
                                          int onMalformedInput,
                                          int onUnmappableInput,
                                          char[] subChars,
                                          int length)
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
Returns:
int error code returned by ICU
Status:
Internal. This API is ICU internal only.

setCallbackEncode

public static final int setCallbackEncode(long converterHandle,
                                          int onMalformedInput,
                                          int onUnmappableInput,
                                          byte[] subBytes,
                                          int length)
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
Returns:
int error code returned by ICU
Status:
Internal. This API is ICU internal only.

safeClone

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

Status:
Internal. This API is ICU internal only.