sun.io
Class CharToByteDoubleByte
java.lang.Object
sun.io.CharToByteConverter
sun.io.CharToByteDoubleByte
- Direct Known Subclasses:
- CharToByteBig5, CharToByteEUC_CN, CharToByteEUC_KR, CharToByteGBK, CharToByteJIS0208, CharToByteJohab
public abstract class CharToByteDoubleByte
- extends CharToByteConverter
|
Method Summary |
boolean |
canConvert(char ch)
Return whether a character is mappable or not |
int |
convert(char[] input,
int inOff,
int inEnd,
byte[] output,
int outOff,
int outEnd)
Converts characters to sequences of bytes. |
protected int |
convSingleByte(char inputChar,
byte[] outputByte)
|
int |
flush(byte[] output,
int outStart,
int outEnd)
Writes any remaining output to the output buffer and resets the
converter to its initial state. |
int |
getMaxBytesPerChar()
the maximum number of bytes needed to hold a converted char |
protected int |
getNative(char ch)
|
void |
reset()
Resets the converter. |
| Methods inherited from class sun.io.CharToByteConverter |
convertAll, convertAny, flushAny, getBadInputLength, getCharacterEncoding, getConverter, getDefault, nextByteIndex, nextCharIndex, setSubstitutionBytes, setSubstitutionMode, toString |
index1
protected short[] index1
index2
protected String[] index2
badInputLength
protected int badInputLength
highHalfZoneCode
protected char highHalfZoneCode
CharToByteDoubleByte
public CharToByteDoubleByte()
flush
public int flush(byte[] output,
int outStart,
int outEnd)
throws MalformedInputException,
ConversionBufferFullException
- Description copied from class:
CharToByteConverter
- Writes any remaining output to the output buffer and resets the
converter to its initial state.
- Specified by:
flush in class CharToByteConverter
- Parameters:
output - byte array to receive flushed output.outStart - start writing to output array at this offset.outEnd - stop writing to output array at this offset (exclusive).
- Throws:
MalformedInputException - if the output to be flushed contained
a partial or invalid multibyte character sequence. Will occur if the
input buffer on the last call to convert ended with the first character
of a surrogate pair. flush will write what it can to the output buffer
and reset the converter before throwing this exception. An additional
call to flush is not required.
ConversionBufferFullException - if output array is filled
before all the output can be flushed. flush will write what it can
to the output buffer and remember its state. An additional call to
flush with a new output buffer will conclude the operation.
convert
public int convert(char[] input,
int inOff,
int inEnd,
byte[] output,
int outOff,
int outEnd)
throws MalformedInputException,
UnknownCharacterException,
ConversionBufferFullException
- Converts characters to sequences of bytes.
Conversions that result in Exceptions can be restarted by calling
convert again, with appropriately modified parameters.
- Specified by:
convert in class CharToByteConverter
- Parameters:
input - char array containing text in UnicodeinStart - offset in input arrayinEnd - offset of last byte to be convertedoutput - byte array to receive conversion resultoutStart - starting offsetoutEnd - offset of last byte to be written to
- Returns:
- the characters written to output.
- Throws:
MalformedInputException - if the input buffer contains any
sequence of chars that is illegal in Unicode (principally unpaired
surrogates and ? or ?). After this exception is thrown,
the method nextCharIndex can be called to obtain the index of the
first invalid input character. The MalformedInputException can
be queried for the length of the invalid input.
UnknownCharacterException - for any character that
that cannot be converted to the external character encoding. Thrown
only when converter is not in substitution mode.
ConversionBufferFullException - if output array is filled prior
to converting all the input.
getMaxBytesPerChar
public int getMaxBytesPerChar()
- the maximum number of bytes needed to hold a converted char
- Specified by:
getMaxBytesPerChar in class CharToByteConverter
reset
public void reset()
- Resets the converter.
Call this method to reset the converter to its initial state
- Specified by:
reset in class CharToByteConverter
canConvert
public boolean canConvert(char ch)
- Return whether a character is mappable or not
- Overrides:
canConvert in class CharToByteConverter
- Parameters:
ch - character to test
- Returns:
- true if a character is mappable
convSingleByte
protected int convSingleByte(char inputChar,
byte[] outputByte)
getNative
protected int getNative(char ch)