|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsun.io.ByteToCharConverter
public abstract class ByteToCharConverter
An abstract base class for subclasses which convert character data in an external encoding into Unicode characters.
| Field Summary | |
|---|---|
protected int |
badInputLength
|
protected int |
byteOff
|
protected int |
charOff
|
protected char[] |
subChars
|
protected boolean |
subMode
|
| Constructor Summary | |
|---|---|
ByteToCharConverter()
|
|
| Method Summary | |
|---|---|
abstract 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. |
char[] |
convertAll(byte[] input)
Converts an array of bytes containing characters in an external encoding into an array of Unicode characters. |
abstract int |
flush(char[] output,
int outStart,
int outEnd)
Writes any remaining output to the output buffer and resets the converter to its initial state. |
int |
getBadInputLength()
Returns the length, in bytes, of the input which caused a MalformedInputException. |
abstract String |
getCharacterEncoding()
Returns the character set id for the conversion |
static ByteToCharConverter |
getConverter(String encoding)
Returns appropriate ByteToCharConverter subclass instance. |
static ByteToCharConverter |
getDefault()
Create an instance of the default ByteToCharConverter subclass. |
int |
getMaxCharsPerByte()
Returns the maximum number of characters needed to convert a byte. |
int |
nextByteIndex()
Returns the index of the byte just past the last byte successfully converted by the previous call to convert. |
int |
nextCharIndex()
Returns the index of the character just past the last character written by the previous call to convert. |
abstract void |
reset()
Resets converter to its initial state. |
void |
setSubstitutionChars(char[] c)
sets the substitution character to use |
void |
setSubstitutionMode(boolean doSub)
Sets converter into substitution mode. |
String |
toString()
returns a string representation of the character conversion |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean subMode
protected char[] subChars
protected int charOff
protected int byteOff
protected int badInputLength
| Constructor Detail |
|---|
public ByteToCharConverter()
| Method Detail |
|---|
public static ByteToCharConverter getDefault()
public static ByteToCharConverter getConverter(String encoding)
throws UnsupportedEncodingException
string - represents encoding
UnsupportedEncodingExceptionpublic abstract String getCharacterEncoding()
public abstract int convert(byte[] input,
int inStart,
int inEnd,
char[] output,
int outStart,
int outEnd)
throws MalformedInputException,
UnknownCharacterException,
ConversionBufferFullException
input - byte array containing text to be converted.inStart - begin conversion at this offset in input array.inEnd - stop conversion at this offset in input array (exclusive).output - character array to receive conversion result.outStart - start writing to output array at this offset.outEnd - stop writing to output array at this offset (exclusive).
MalformedInputException - if the input buffer contains any
sequence of bytes that is illegal for the input character set.
UnknownCharacterException - for any character that
that cannot be converted to Unicode. Thrown only when converter
is not in substitution mode.
ConversionBufferFullException - if output array is filled prior
to converting all the input.
public char[] convertAll(byte[] input)
throws MalformedInputException
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.
input - array containing Unicode characters to be converted.
MalformedInputException - if the input buffer contains any
sequence 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 the
first invalid input byte and getBadInputLength can be called
to determine the length of the invalid input.nextByteIndex(),
setSubstitutionMode(boolean),
CharToByteConverter.setSubstitutionBytes(byte[]),
getBadInputLength()
public abstract int flush(char[] output,
int outStart,
int outEnd)
throws MalformedInputException,
ConversionBufferFullException
output - char array to receive flushed output.outStart - start writing to output array at this offset.outEnd - stop writing to output array at this offset (exclusive).
MalformedInputException - if the output to be flushed contained
a partial or invalid multibyte character sequence. 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.public abstract void reset()
public int getMaxCharsPerByte()
public int getBadInputLength()
public int nextCharIndex()
public int nextByteIndex()
public void setSubstitutionMode(boolean doSub)
doSub - if true, enable substitution mode.setSubstitutionChars(char[])
public void setSubstitutionChars(char[] c)
throws IllegalArgumentException
c - the substitution character
IllegalArgumentExceptionpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||