com.ibm.icu.charset

Class CharsetEncoderICU

public abstract class CharsetEncoderICU extends CharsetEncoder

An abstract class that provides framework methods of decoding operations for concrete subclasses. In the future this class will contain API that will implement converter sematics of ICU4C.

UNKNOWN: ICU 3.6 This API might change or be removed in a future release.

Method Summary
booleancanEncode(int codepoint)
Ascertains if a given Unicode code point (32bit value for handling surrogates) can be converted to the target encoding.
protected CoderResultencodeLoop(CharBuffer in, ByteBuffer out)
Encodes one or more chars.
protected CoderResultimplFlush(ByteBuffer out)
Flushes any characters saved in the converter's internal buffer and resets the converter.
protected voidimplOnMalformedInput(CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encountered
protected voidimplOnUnmappableCharacter(CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encountered
protected voidimplReset()
Resets the from Unicode mode of converter
booleanisLegalReplacement(byte[] repl)
Overrides super class method

Method Detail

canEncode

public boolean canEncode(int codepoint)
Ascertains if a given Unicode code point (32bit value for handling surrogates) can be converted to the target encoding. If the caller wants to test if a surrogate pair can be converted to target encoding then the responsibility of assembling the int value lies with the caller. For assembling a code point the caller can use UTF16 class of ICU4J and do something like:
 while(i
 or
 
 String src = new String(mySource);
 int i,codepoint;
 boolean passed = false;
 while(i0xfff)? 2:1;
	if(!(CharsetEncoderICU) myConv).canEncode(codepoint)){
	    passed = false;
	}
 }
 

Parameters: codepoint Unicode code point as int value

Returns: true if a character can be converted

UNKNOWN: ICU 3.6 This API might change or be removed in a future release.

encodeLoop

protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out)
Encodes one or more chars. The default behaviour of the converter is stop and report if an error in input stream is encountered. To set different behaviour use @see CharsetEncoder.onMalformedInput()

Parameters: in buffer to decode out buffer to populate with decoded result

Returns: result of decoding action. Returns CoderResult.UNDERFLOW if the decoding action succeeds or more input is needed for completing the decoding action.

UNKNOWN: ICU 3.6

implFlush

protected CoderResult implFlush(ByteBuffer out)
Flushes any characters saved in the converter's internal buffer and resets the converter.

Parameters: out action to be taken

Returns: result of flushing action and completes the decoding all input. Returns CoderResult.UNDERFLOW if the action succeeds.

UNKNOWN: ICU 3.6

implOnMalformedInput

protected void implOnMalformedInput(CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encountered

Parameters: newAction action to be taken

Throws: IllegalArgumentException

UNKNOWN: ICU 3.6

implOnUnmappableCharacter

protected void implOnUnmappableCharacter(CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encountered

Parameters: newAction action to be taken

Throws: IllegalArgumentException

UNKNOWN: ICU 3.6

implReset

protected void implReset()
Resets the from Unicode mode of converter

UNKNOWN: ICU 3.6

isLegalReplacement

public boolean isLegalReplacement(byte[] repl)
Overrides super class method

UNKNOWN: ICU 3.6

Copyright (c) 2007 IBM Corporation and others.