| com.ibm.icu.charset.CharsetEncoderICU
CharsetEncoderICU | abstract public class CharsetEncoderICU extends CharsetEncoder (Code) | | 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 | |
public boolean | canEncode(int codepoint) Ascertains if a given Unicode code point (32bit value for handling surrogates)
can be converted to the target encoding. | CoderResult | cbFromUWriteSub(CharsetEncoderICU encoder, CharBuffer source, ByteBuffer target, IntBuffer offsets) Write the codepage substitution character. | final CoderResult | encode(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) Implements ICU semantics for encoding the buffer
Parameters: source - The input character buffer Parameters: target - The output byte buffer Parameters: offsets - Parameters: flush - true if, and only if, the invoker can provide noadditional input bytes beyond those in the given buffer. | protected CoderResult | encodeLoop(CharBuffer in, ByteBuffer out) Encodes one or more chars. | abstract CoderResult | encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) | int | fromUCountPending() Returns the number of chars held in the converter's internal state
because more input is needed for completing the conversion. | final static CoderResult | fromUWriteBytes(CharsetEncoderICU cnv, byte[] bytesArray, int bytesBegin, int bytesLength, ByteBuffer out, IntBuffer offsets, int sourceIndex) Writes out the specified output bytes to the target byte buffer or to converter internal buffers. | final CoderResult | fromUnicodeWithCallback(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) Implementation note for m:n conversions
While collecting source units to find the longest match for m:n conversion,
some source units may need to be stored for a partial match. | 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 result of flushing action and completes the decoding all input. | protected void | implOnMalformedInput(CodingErrorAction newAction) | protected void | implOnUnmappableCharacter(CodingErrorAction newAction) | protected void | implReset() | public boolean | isLegalReplacement(byte[] repl) |
errorBuffer | byte[] errorBuffer(Code) | | |
errorBufferLength | int errorBufferLength(Code) | | |
fromUChar32 | int fromUChar32(Code) | | |
fromUnicodeStatus | int fromUnicodeStatus(Code) | | these are for encodeLoopICU
|
invalidUCharBuffer | char[] invalidUCharBuffer(Code) | | |
invalidUCharLength | int invalidUCharLength(Code) | | |
preFromUArray | char[] preFromUArray(Code) | | |
preFromUBegin | int preFromUBegin(Code) | | |
preFromUFirstCP | int preFromUFirstCP(Code) | | |
preFromULength | int preFromULength(Code) | | |
useSubChar1 | boolean useSubChar1(Code) | | |
CharsetEncoderICU | CharsetEncoderICU(CharsetICU cs, byte[] replacement)(Code) | | Construcs a new encoder for the given charset
Parameters: cs - for which the decoder is created Parameters: replacement - the substitution bytes |
canEncode | public boolean canEncode(int codepoint)(Code) | | 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 true if a character can be converted |
cbFromUWriteSub | CoderResult cbFromUWriteSub(CharsetEncoderICU encoder, CharBuffer source, ByteBuffer target, IntBuffer offsets)(Code) | | Write the codepage substitution character.
Subclasses to override this method.
For stateful converters, it is typically necessary to handle this
specificially for the converter in order to properly maintain the state.
Parameters: source - The input character buffer Parameters: target - The output byte buffer Parameters: offsets - A CoderResult object that contains the error result when an error occurs. |
encode | final CoderResult encode(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush)(Code) | | Implements ICU semantics for encoding the buffer
Parameters: source - The input character buffer Parameters: target - The output byte buffer Parameters: offsets - Parameters: flush - true if, and only if, the invoker can provide noadditional input bytes beyond those in the given buffer. A CoderResult object that contains the error result when an error occurs. |
encodeLoop | protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out)(Code) | | 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 Parameters: out - buffer to populate with decoded result result of decoding action. Returns CoderResult.UNDERFLOW if the decodingaction succeeds or more input is needed for completing the decoding action. |
encodeLoop | abstract CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush)(Code) | | Implements ICU semantics of buffer management
Parameters: source - Parameters: target - Parameters: offsets - A CoderResult object that contains the error result when an error occurs. |
fromUCountPending | int fromUCountPending()(Code) | | Returns the number of chars held in the converter's internal state
because more input is needed for completing the conversion. This function is
useful for mapping semantics of ICU's converter interface to those of iconv,
and this information is not needed for normal conversion.
The number of chars in the state. -1 if an error is encountered. |
fromUWriteBytes | final static CoderResult fromUWriteBytes(CharsetEncoderICU cnv, byte[] bytesArray, int bytesBegin, int bytesLength, ByteBuffer out, IntBuffer offsets, int sourceIndex)(Code) | | Writes out the specified output bytes to the target byte buffer or to converter internal buffers.
Parameters: cnv - Parameters: bytesArray - Parameters: bytesBegin - Parameters: bytesLength - Parameters: out - Parameters: offsets - Parameters: sourceIndex - A CoderResult object that contains the error result when an error occurs. |
fromUnicodeWithCallback | final CoderResult fromUnicodeWithCallback(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush)(Code) | | Implementation note for m:n conversions
While collecting source units to find the longest match for m:n conversion,
some source units may need to be stored for a partial match.
When a second buffer does not yield a match on all of the previously stored
source units, then they must be "replayed", i.e., fed back into the converter.
The code relies on the fact that replaying will not nest -
converting a replay buffer will not result in a replay.
This is because a replay is necessary only after the _continuation_ of a
partial match failed, but a replay buffer is converted as a whole.
It may result in some of its units being stored again for a partial match,
but there will not be a continuation _during_ the replay which could fail.
It is conceivable that a callback function could call the converter
recursively in a way that causes another replay to be stored, but that
would be an error in the callback function.
Such violations will cause assertion failures in a debug build,
and wrong output, but they will not cause a crash.
|
implFlush | protected CoderResult implFlush(ByteBuffer out)(Code) | | Flushes any characters saved in the converter's internal buffer and
resets the converter.
Parameters: out - action to be taken result of flushing action and completes the decoding all input. Returns CoderResult.UNDERFLOW if the action succeeds. |
implOnMalformedInput | protected void implOnMalformedInput(CodingErrorAction newAction)(Code) | | Sets the action to be taken if an illegal sequence is encountered
Parameters: newAction - action to be taken exception: IllegalArgumentException - |
implOnUnmappableCharacter | protected void implOnUnmappableCharacter(CodingErrorAction newAction)(Code) | | Sets the action to be taken if an illegal sequence is encountered
Parameters: newAction - action to be taken exception: IllegalArgumentException - |
implReset | protected void implReset()(Code) | | Resets the from Unicode mode of converter
|
isLegalReplacement | public boolean isLegalReplacement(byte[] repl)(Code) | | Overrides super class method
|
|
|