| java.lang.Object sun.io.ByteToCharConverter
All known Subclasses: sun.io.ByteToCharISO8859_1, sun.io.ByteToCharDBCS_ASCII, sun.io.ByteToCharSingleByte, sun.io.ByteToCharASCII, sun.io.ByteToCharCp33722, sun.io.ByteToCharDBCS_EBCDIC, sun.io.ByteToCharISO2022, sun.io.ByteToCharDoubleByte, sun.io.ByteToCharEUC, sun.io.ByteToCharUnicode, sun.io.ByteToCharUTF8, sun.io.ByteToCharEUC_TW, sun.io.ByteToCharJISAutoDetect, sun.io.ByteToCharCp964,
ByteToCharConverter | abstract public class ByteToCharConverter (Code) | | An abstract base class for subclasses which convert character data
in an external encoding into Unicode characters.
author: Asmus Freytag author: Lloyd Honomichl |
Method Summary | |
abstract public int | convert(byte[] input, int inStart, int inEnd, char[] output, int outStart, int outEnd) Converts an array of bytes containing characters in an external
encoding into an array of Unicode characters. | public char[] | convertAll(byte input) Converts an array of bytes containing characters in an external
encoding into an array of Unicode characters. | abstract public int | flush(char[] output, int outStart, int outEnd) Writes any remaining output to the output buffer and resets the
converter to its initial state. | public int | getBadInputLength() Returns the length, in bytes, of the input which caused a
MalformedInputException. | abstract public String | getCharacterEncoding() | public static ByteToCharConverter | getConverter(String encoding) Returns appropriate ByteToCharConverter subclass instance. | public static ByteToCharConverter | getDefault() Create an instance of the default ByteToCharConverter subclass. | public int | getMaxCharsPerByte() Returns the maximum number of characters needed to convert a byte. | public int | nextByteIndex() Returns the index of the byte just past the last byte successfully
converted by the previous call to convert. | public int | nextCharIndex() Returns the index of the character just past the last character
written by the previous call to convert. | abstract public void | reset() Resets converter to its initial state. | public void | setSubstitutionChars(char[] c) | public void | setSubstitutionMode(boolean doSub) Sets converter into substitution mode. | public String | toString() |
badInputLength | protected int badInputLength(Code) | | |
byteOff | protected int byteOff(Code) | | |
charOff | protected int charOff(Code) | | |
subChars | protected char[] subChars(Code) | | |
subMode | protected boolean subMode(Code) | | |
convert | abstract public int convert(byte[] input, int inStart, int inEnd, char[] output, int outStart, int outEnd) throws MalformedInputException, UnknownCharacterException, ConversionBufferFullException(Code) | | Converts an array of bytes containing characters in an external
encoding into an array of Unicode characters. 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 exception, 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.
the number of bytes written to output. Parameters: input - byte array containing text to be converted. Parameters: inStart - begin conversion at this offset in input array. Parameters: inEnd - stop conversion at this offset in input array (exclusive). Parameters: output - character array to receive conversion result. Parameters: outStart - start writing to output array at this offset. Parameters: outEnd - stop writing to output array at this offset (exclusive). exception: MalformedInputException - if the input buffer contains anysequence of bytes that is illegal for the input character set. exception: UnknownCharacterException - for any character thatthat cannot be converted to Unicode. Thrown only when converter is not in substitution mode. exception: ConversionBufferFullException - if output array is filled priorto converting all the input. |
convertAll | public char[] convertAll(byte input) throws MalformedInputException(Code) | | Converts an array of bytes containing characters in an external
encoding into an array of Unicode characters. Unlike convert,
this method does not do incremental conversion. It assumes that
the given input array contains all the characters to be
converted. The state of the converter is reset at the beginning
of this method and is left in the reset state on successful
termination. The converter is not reset if an exception is
thrown. This allows the caller to determine where the bad input
was encountered by calling nextByteIndex.
This method uses substitution mode when performing the
conversion. The method setSubstitutionChars may be used to
determine what characters are substituted. Even though substitution
mode is used, the state of the converter's substitution mode is
not changed at the end of this method.
an array of chars containing the converted characters. Parameters: input - array containing Unicode characters to be converted. exception: MalformedInputException - if the input buffer contains anysequence of chars that is illegal in the input character encoding.After this exception is thrown,the method nextByteIndex can be called to obtain the index of thefirst invalid input byte and getBadInputLength can be calledto determine the length of the invalid input. See Also: ByteToCharConverter.nextByteIndex See Also: ByteToCharConverter.setSubstitutionMode See Also: sun.io.CharToByteConverter.setSubstitutionBytes(byte[]) See Also: ByteToCharConverter.getBadInputLength |
flush | abstract public int flush(char[] output, int outStart, int outEnd) throws MalformedInputException, ConversionBufferFullException(Code) | | Writes any remaining output to the output buffer and resets the
converter to its initial state.
Parameters: output - char array to receive flushed output. Parameters: outStart - start writing to output array at this offset. Parameters: outEnd - stop writing to output array at this offset (exclusive). exception: MalformedInputException - if the output to be flushed containeda partial or invalid multibyte character sequence. flush willwrite what it can to the output buffer and reset the converter beforethrowing this exception. An additional call to flush is not required. exception: ConversionBufferFullException - if output array is filled before all the output can be flushed. flush will write what it canto the output buffer and remember its state. An additional call toflush with a new output buffer will conclude the operation. |
getBadInputLength | public int getBadInputLength()(Code) | | Returns the length, in bytes, of the input which caused a
MalformedInputException. Always refers to the last
MalformedInputException thrown by the converter. If none have
ever been thrown, returns 0.
|
getCharacterEncoding | abstract public String getCharacterEncoding()(Code) | | Returns the character set id for the conversion
|
getDefault | public static ByteToCharConverter getDefault()(Code) | | Create an instance of the default ByteToCharConverter subclass.
|
getMaxCharsPerByte | public int getMaxCharsPerByte()(Code) | | Returns the maximum number of characters needed to convert a byte. Useful
for calculating the maximum output buffer size needed for a particular
input buffer.
|
nextByteIndex | public int nextByteIndex()(Code) | | Returns the index of the byte just past the last byte successfully
converted by the previous call to convert.
|
nextCharIndex | public int nextCharIndex()(Code) | | Returns the index of the character just past the last character
written by the previous call to convert.
|
reset | abstract public void reset()(Code) | | Resets converter to its initial state.
|
setSubstitutionChars | public void setSubstitutionChars(char[] c) throws IllegalArgumentException(Code) | | sets the substitution character to use
Parameters: c - the substitution character |
setSubstitutionMode | public void setSubstitutionMode(boolean doSub)(Code) | | Sets converter into substitution mode. In substitution mode,
the converter will replace untranslatable characters in the source
encoding with the substitution character set by setSubstitionChars.
When not in substitution mode, the converter will throw an
UnknownCharacterException when it encounters untranslatable input.
Parameters: doSub - if true, enable substitution mode. See Also: ByteToCharConverter.setSubstitutionChars |
toString | public String toString()(Code) | | returns a string representation of the character conversion
|
|
|