sun.io
abstract public class: ByteToCharConverter [javadoc |
source]
java.lang.Object
sun.io.ByteToCharConverter
Direct Known Subclasses:
ByteToCharMacSymbol, ByteToCharMacDingbat, ByteToCharCp970, ByteToCharMS949, ByteToCharCp284, ByteToCharJIS0201, ByteToCharCp864, ByteToCharCp424, ByteToCharJIS0208_Solaris, ByteToCharCp856, ByteToCharCp918, ByteToCharCp1123, ByteToCharMS932DB, ByteToCharCp862, ByteToCharCp1149, ByteToCharCp874, ByteToCharEUC, ByteToCharHKSCS_2001, ByteToCharCp943, ByteToCharCp870, ByteToCharCp852, ByteToCharUTF16, ByteToCharCp1144, ByteToCharEUC_JP_Solaris, ByteToCharISO2022, ByteToCharCp937, ByteToCharISO8859_4, ByteToCharCp921, ByteToCharCp943C, ByteToCharDBCS_EBCDIC, ByteToCharCp838, ByteToCharCp297, ByteToCharCp1122, ByteToCharMacRoman, ByteToCharDBCS_ASCII, ByteToCharEUC_KR, ByteToCharCp922, ByteToCharEUC_JP_LINUX, ByteToCharCp1251, ByteToCharMS936, ByteToCharISO8859_15, ByteToCharCp869, ByteToCharCp949C, ByteToCharJIS0212, ByteToCharCp285, ByteToCharCp1047, ByteToCharISO8859_7, ByteToCharCp935, ByteToCharCp775, ByteToCharMacTurkish, ByteToCharCp1254, ByteToCharISO2022CN, ByteToCharDBCS_ONLY_EBCDIC, ByteToCharMacUkraine, ByteToCharCp866, ByteToCharISO8859_9, ByteToCharUTF8, ByteToCharISO2022KR, ByteToCharMS932, ByteToCharCp1253, ByteToCharKOI8_R, ByteToCharCp933, ByteToCharMacThai, ByteToCharCp855, ByteToCharSingleByte, ByteToCharCp1381, ByteToCharCp1026, ByteToCharCp1257, ByteToCharMS874, ByteToCharCp280, ByteToCharCp278, ByteToCharCp437, ByteToCharCp1140, ByteToCharMacHebrew, ByteToCharASCII, ByteToCharUnicodeLittle, ByteToCharMS950, ByteToCharCp33722, ByteToCharCp1006, ByteToCharCp1142, ByteToCharCp1141, ByteToCharCp1256, ByteToCharCp964, ByteToCharMacIceland, ByteToCharCp1112, ByteToCharCp930, ByteToCharCp1046, ByteToCharCp1145, ByteToCharISO8859_2, ByteToCharCp949, ByteToCharMacArabic, ByteToCharEUC_CN, ByteToCharEUC_JP, ByteToCharCp863, ByteToCharGB18030, ByteToCharCp942C, ByteToCharISO8859_6, ByteToCharGBK, ByteToCharMacGreek, ByteToCharCp868, ByteToCharTIS620, ByteToCharCp942, ByteToCharCp871, ByteToCharMacCroatian, ByteToCharHKSCS, ByteToCharMacRomania, ByteToCharJIS0208, ByteToCharBig5, ByteToCharCp1255, ByteToCharJohab, ByteToCharPCK, ByteToCharISO2022JP, ByteToCharUnicodeLittleUnmarked, ByteToCharCp1147, ByteToCharCp950, ByteToCharCp500, ByteToCharUnicodeBigUnmarked, ByteToCharCp1258, ByteToCharCp1148, ByteToCharCp865, ByteToCharCp850, ByteToCharEUC_TW, ByteToCharBig5_Solaris, ByteToCharCp948, ByteToCharDoubleByte, ByteToCharCp1098, ByteToCharISO8859_3, ByteToCharCp277, ByteToCharUnicode, ByteToCharCp861, ByteToCharUnicodeBig, ByteToCharJIS0212_Solaris, ByteToCharMacCentralEurope, ByteToCharCp1383, ByteToCharISCII91, ByteToCharCp1124, ByteToCharSJIS, ByteToCharCp037, ByteToCharCp858, ByteToCharCp273, ByteToCharCp875, ByteToCharCp857, ByteToCharCp420, ByteToCharCp1250, ByteToCharCp860, ByteToCharCp1097, ByteToCharMS950_HKSCS, ByteToCharCp1025, ByteToCharCp1143, ByteToCharCp834, ByteToCharISO8859_8, ByteToCharJISAutoDetect, ByteToCharBig5_HKSCS, ByteToCharCp1146, ByteToCharCp737, ByteToCharCp1252, ByteToCharISO8859_5, ByteToCharCp939, ByteToCharISO8859_1, ByteToCharGB18030DB, ByteToCharISO8859_13, ByteToCharMacCyrillic
Deprecated! Replaced - by
java.nio.charset . THIS API WILL BE
REMOVED IN J2SE 1.6.
An abstract base class for subclasses which convert character data
in an external encoding into Unicode characters.
- author:
Asmus - Freytag
- author:
Lloyd - Honomichl
| Field Summary |
|---|
| protected boolean | subMode | |
| protected char[] | subChars | |
| protected int | charOff | |
| protected int | byteOff | |
| protected int | badInputLength | |
| Method from sun.io.ByteToCharConverter Summary: |
|---|
|
convert, convertAll, flush, getBadInputLength, getCharacterEncoding, getConverter, getDefault, getMaxCharsPerByte, nextByteIndex, nextCharIndex, reset, setSubstitutionChars, setSubstitutionMode, toString |
| Method from sun.io.ByteToCharConverter Detail: |
abstract public int convert(byte[] input,
int inStart,
int inEnd,
char[] output,
int outStart,
int outEnd) throws ConversionBufferFullException, MalformedInputException, UnknownCharacterException Deprecated!
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. |
public char[] convertAll(byte[] input) throws MalformedInputException {
reset();
boolean savedSubMode = subMode;
subMode = true;
char[] output = new char[ getMaxCharsPerByte() * input.length ];
try {
int outputLength = convert( input, 0, input.length,
output, 0, output.length );
outputLength += flush( output, outputLength, output.length );
char [] returnedOutput = new char[ outputLength ];
System.arraycopy( output, 0, returnedOutput, 0, outputLength );
return returnedOutput;
}
catch( ConversionBufferFullException e ) {
//Not supposed to happen. If it does, getMaxCharsPerByte() lied.
throw new
InternalError("this.getMaxCharsBerByte returned bad value");
}
catch( UnknownCharacterException e ) {
// Not supposed to happen since we're in substitution mode.
throw new InternalError();
}
finally {
subMode = savedSubMode;
}
} Deprecated!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. |
abstract public int flush(char[] output,
int outStart,
int outEnd) throws ConversionBufferFullException, MalformedInputException Deprecated!
Writes any remaining output to the output buffer and resets the
converter to its initial state. |
public int getBadInputLength() {
return badInputLength;
} Deprecated!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. |
abstract public String getCharacterEncoding() Deprecated!
Returns the character set id for the conversion |
public static ByteToCharConverter getConverter(String encoding) throws UnsupportedEncodingException {
Object cvt;
cvt = Converters.newConverter(Converters.BYTE_TO_CHAR, encoding);
return (ByteToCharConverter)cvt;
} Deprecated!Returns appropriate ByteToCharConverter subclass instance. |
public static ByteToCharConverter getDefault() {
Object cvt;
cvt = Converters.newDefaultConverter(Converters.BYTE_TO_CHAR);
return (ByteToCharConverter)cvt;
} Deprecated!Create an instance of the default ByteToCharConverter subclass. |
public int getMaxCharsPerByte() {
// Until UTF-16, this will do for every encoding
return 1;
} Deprecated!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. |
public int nextByteIndex() {
return byteOff;
} Deprecated!Returns the index of the byte just past the last byte successfully
converted by the previous call to convert. |
public int nextCharIndex() {
return charOff;
} Deprecated!Returns the index of the character just past the last character
written by the previous call to convert. |
abstract public void reset() Deprecated!
Resets converter to its initial state. |
public void setSubstitutionChars(char[] c) throws IllegalArgumentException {
if( c.length > getMaxCharsPerByte() ) {
throw new IllegalArgumentException();
}
subChars = new char[ c.length ];
System.arraycopy( c, 0, subChars, 0, c.length );
} Deprecated!sets the substitution character to use |
public void setSubstitutionMode(boolean doSub) {
subMode = doSub;
} Deprecated!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. |
public String toString() {
return "ByteToCharConverter: " + getCharacterEncoding();
} Deprecated!returns a string representation of the character conversion |