Package com.ibm.icu.charset
Class CharsetDecoderICU
- java.lang.Object
-
- java.nio.charset.CharsetDecoder
-
- com.ibm.icu.charset.CharsetDecoderICU
-
- Direct Known Subclasses:
CharsetASCII.CharsetDecoderASCII
,CharsetBOCU1.CharsetDecoderBOCU
,CharsetCompoundText.CharsetDecoderCompoundText
,CharsetHZ.CharsetDecoderHZ
,CharsetISCII.CharsetDecoderISCII
,CharsetISO2022.CharsetDecoderISO2022CN
,CharsetISO2022.CharsetDecoderISO2022JP
,CharsetISO2022.CharsetDecoderISO2022KR
,CharsetLMBCS.CharsetDecoderLMBCS
,CharsetMBCS.CharsetDecoderMBCS
,CharsetSCSU.CharsetDecoderSCSU
,CharsetUTF16.CharsetDecoderUTF16
,CharsetUTF32.CharsetDecoderUTF32
,CharsetUTF7.CharsetDecoderUTF7
,CharsetUTF8.CharsetDecoderUTF8
public abstract class CharsetDecoderICU extends java.nio.charset.CharsetDecoder
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 semantics of ICU4C.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) char[]
charErrorBufferArray
(package private) int
charErrorBufferBegin
(package private) int
charErrorBufferLength
private java.nio.ByteBuffer
EMPTY
protected static int
EXT_MAX_BYTES
Deprecated.This API is ICU internal only.(package private) char[]
invalidCharBuffer
(package private) int
invalidCharLength
private boolean
malformedInputCalled
(package private) int
mode
private CharsetCallback.Decoder
onMalformedInput
private CharsetCallback.Decoder
onUnmappableCharacter
(package private) byte[]
preToUArray
(package private) int
preToUBegin
(package private) int
preToUFirstLength
(package private) int
preToULength
(package private) CharsetCallback.Decoder
toCharErrorBehaviour
(package private) byte[]
toUBytesArray
(package private) int
toUBytesBegin
(package private) java.lang.Object
toUContext
(package private) int
toULength
(package private) int
toUnicodeStatus
private boolean
unmappableCharacterCalled
-
Constructor Summary
Constructors Constructor Description CharsetDecoderICU(CharsetICU cs)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
copy(byte[] src, int srcOffset, char[] dst, int dstOffset, int length)
(package private) java.nio.charset.CoderResult
decode(java.nio.ByteBuffer source, java.nio.CharBuffer target, java.nio.IntBuffer offsets, boolean flush)
protected java.nio.charset.CoderResult
decodeLoop(java.nio.ByteBuffer in, java.nio.CharBuffer out)
Decodes one or more bytes.(package private) abstract java.nio.charset.CoderResult
decodeLoop(java.nio.ByteBuffer in, java.nio.CharBuffer out, java.nio.IntBuffer offsets, boolean flush)
private static CharsetCallback.Decoder
getCallback(java.nio.charset.CodingErrorAction action)
protected java.nio.charset.CoderResult
implFlush(java.nio.CharBuffer 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 encounteredprotected void
implOnUnmappableCharacter(java.nio.charset.CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encounteredprotected void
implReset()
Resets the to Unicode mode of converter(package private) boolean
isFallbackUsed()
(package private) static boolean
isToUUseFallback()
Fallback is currently always used by icu4j decoders.(package private) static boolean
isToUUseFallback(boolean iUseFallback)
Fallback is currently always used by icu4j decoders.float
maxBytesPerChar()
Returns the maxBytesPerChar value for the Charset that created this decoder.void
setToUCallback(java.nio.charset.CoderResult err, CharsetCallback.Decoder newCallback, java.lang.Object newContext)
Sets the callback encoder method and context to be used if an illegal sequence is encountered.(package private) int
toUCountPending()
(package private) java.nio.charset.CoderResult
toUnicodeWithCallback(java.nio.ByteBuffer source, java.nio.CharBuffer target, java.nio.IntBuffer offsets, boolean flush)
(package private) static java.nio.charset.CoderResult
toUWriteUChars(CharsetDecoderICU cnv, char[] ucharsArray, int ucharsBegin, int length, java.nio.CharBuffer target, java.nio.IntBuffer offsets, int sourceIndex)
-
Methods inherited from class java.nio.charset.CharsetDecoder
averageCharsPerByte, charset, decode, decode, detectedCharset, flush, implReplaceWith, isAutoDetecting, isCharsetDetected, malformedInputAction, maxCharsPerByte, onMalformedInput, onUnmappableCharacter, replacement, replaceWith, reset, unmappableCharacterAction
-
-
-
-
Field Detail
-
toUnicodeStatus
int toUnicodeStatus
-
toUBytesArray
byte[] toUBytesArray
-
toUBytesBegin
int toUBytesBegin
-
toULength
int toULength
-
charErrorBufferArray
char[] charErrorBufferArray
-
charErrorBufferLength
int charErrorBufferLength
-
charErrorBufferBegin
int charErrorBufferBegin
-
invalidCharBuffer
char[] invalidCharBuffer
-
invalidCharLength
int invalidCharLength
-
EXT_MAX_BYTES
@Deprecated protected static final int EXT_MAX_BYTES
Deprecated.This API is ICU internal only.Maximum number of indexed bytes- See Also:
- Constant Field Values
-
preToUArray
byte[] preToUArray
-
preToUBegin
int preToUBegin
-
preToULength
int preToULength
-
preToUFirstLength
int preToUFirstLength
-
mode
int mode
-
toUContext
java.lang.Object toUContext
-
onUnmappableCharacter
private CharsetCallback.Decoder onUnmappableCharacter
-
onMalformedInput
private CharsetCallback.Decoder onMalformedInput
-
toCharErrorBehaviour
CharsetCallback.Decoder toCharErrorBehaviour
-
malformedInputCalled
private boolean malformedInputCalled
-
unmappableCharacterCalled
private boolean unmappableCharacterCalled
-
EMPTY
private final java.nio.ByteBuffer EMPTY
-
-
Constructor Detail
-
CharsetDecoderICU
CharsetDecoderICU(CharsetICU cs)
-
-
Method Detail
-
isFallbackUsed
final boolean isFallbackUsed()
-
isToUUseFallback
static final boolean isToUUseFallback()
Fallback is currently always used by icu4j decoders.
-
isToUUseFallback
static final boolean isToUUseFallback(boolean iUseFallback)
Fallback is currently always used by icu4j decoders.
-
implOnMalformedInput
protected final void implOnMalformedInput(java.nio.charset.CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encountered- Overrides:
implOnMalformedInput
in classjava.nio.charset.CharsetDecoder
- Parameters:
newAction
- action to be taken- Throws:
java.lang.IllegalArgumentException
-
implOnUnmappableCharacter
protected final void implOnUnmappableCharacter(java.nio.charset.CodingErrorAction newAction)
Sets the action to be taken if an illegal sequence is encountered- Overrides:
implOnUnmappableCharacter
in classjava.nio.charset.CharsetDecoder
- Parameters:
newAction
- action to be taken- Throws:
java.lang.IllegalArgumentException
-
setToUCallback
public final void setToUCallback(java.nio.charset.CoderResult err, CharsetCallback.Decoder newCallback, java.lang.Object newContext)
Sets the callback encoder method and context to be used if an illegal sequence is encountered. You would normally call this twice to set both the malform and unmappable error. In this case, newContext should remain the same since using a different newContext each time will negate the last one used.- Parameters:
err
- CoderResultnewCallback
- CharsetCallback.EncodernewContext
- Object
-
getCallback
private static CharsetCallback.Decoder getCallback(java.nio.charset.CodingErrorAction action)
-
implFlush
protected final java.nio.charset.CoderResult implFlush(java.nio.CharBuffer out)
Flushes any characters saved in the converter's internal buffer and resets the converter.- Overrides:
implFlush
in classjava.nio.charset.CharsetDecoder
- 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 to Unicode mode of converter- Overrides:
implReset
in classjava.nio.charset.CharsetDecoder
-
decodeLoop
protected java.nio.charset.CoderResult decodeLoop(java.nio.ByteBuffer in, java.nio.CharBuffer out)
Decodes one or more bytes. The default behaviour of the converter is stop and report if an error in input stream is encountered. To set different behaviour use @see CharsetDecoder.onMalformedInput() 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.- Specified by:
decodeLoop
in classjava.nio.charset.CharsetDecoder
- Parameters:
in
- buffer to decodeout
- 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.
-
decodeLoop
abstract java.nio.charset.CoderResult decodeLoop(java.nio.ByteBuffer in, java.nio.CharBuffer out, java.nio.IntBuffer offsets, boolean flush)
-
decode
final java.nio.charset.CoderResult decode(java.nio.ByteBuffer source, java.nio.CharBuffer target, java.nio.IntBuffer offsets, boolean flush)
-
toUnicodeWithCallback
final java.nio.charset.CoderResult toUnicodeWithCallback(java.nio.ByteBuffer source, java.nio.CharBuffer target, java.nio.IntBuffer offsets, boolean flush)
-
toUCountPending
int toUCountPending()
-
copy
private void copy(byte[] src, int srcOffset, char[] dst, int dstOffset, int length)
-
toUWriteUChars
static final java.nio.charset.CoderResult toUWriteUChars(CharsetDecoderICU cnv, char[] ucharsArray, int ucharsBegin, int length, java.nio.CharBuffer target, java.nio.IntBuffer offsets, int sourceIndex)
-
maxBytesPerChar
public final float maxBytesPerChar()
Returns the maxBytesPerChar value for the Charset that created this decoder.- Returns:
- maxBytesPerChar
-
-