com.ibm.icu.charset
Class CharsetEncoderICU

java.lang.Object
  extended by java.nio.charset.CharsetEncoder
      extended by com.ibm.icu.charset.CharsetEncoderICU

public abstract class CharsetEncoderICU
extends java.nio.charset.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.


Method Summary
 boolean canEncode(int codepoint)
          Ascertains if a given Unicode code point (32bit value for handling surrogates) can be converted to the target encoding.
protected  java.nio.charset.CoderResult encodeLoop(java.nio.CharBuffer in, java.nio.ByteBuffer out)
          Encodes one or more chars.
protected  java.nio.charset.CoderResult implFlush(java.nio.ByteBuffer out)
          Flushes any characters saved in the converter's internal buffer and resets the converter.
protected  void implOnMalformedInput(java.nio.charset.CodingErrorAction newAction)
          Sets the action to be taken if an illegal sequence is encountered
protected  void implOnUnmappableCharacter(java.nio.charset.CodingErrorAction newAction)
          Sets the action to be taken if an illegal sequence is encountered
protected  void implReset()
          Resets the from Unicode mode of converter
 boolean isLegalReplacement(byte[] repl)
          Overrides super class method
 
Methods inherited from class java.nio.charset.CharsetEncoder
averageBytesPerChar, canEncode, canEncode, charset, encode, encode, flush, implReplaceWith, malformedInputAction, maxBytesPerChar, onMalformedInput, onUnmappableCharacter, replacement, replaceWith, reset, unmappableCharacterAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

implOnMalformedInput

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

Overrides:
implOnMalformedInput in class java.nio.charset.CharsetEncoder
Parameters:
newAction - action to be taken
Throws:
java.lang.IllegalArgumentException

implOnUnmappableCharacter

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

Overrides:
implOnUnmappableCharacter in class java.nio.charset.CharsetEncoder
Parameters:
newAction - action to be taken
Throws:
java.lang.IllegalArgumentException

implFlush

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

Overrides:
implFlush in class java.nio.charset.CharsetEncoder
Parameters:
out - action to be taken
Returns:
result of flushing action and completes the decoding all input. Returns CoderResult.UNDERFLOW if the action succeeds.

implReset

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

Overrides:
implReset in class java.nio.charset.CharsetEncoder

encodeLoop

protected java.nio.charset.CoderResult encodeLoop(java.nio.CharBuffer in,
                                                  java.nio.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()

Specified by:
encodeLoop in class java.nio.charset.CharsetEncoder
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.

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

isLegalReplacement

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

Overrides:
isLegalReplacement in class java.nio.charset.CharsetEncoder


Copyright (c) 2007 IBM Corporation and others.