Save This Page
Home » openjdk-7 » sun » io » [javadoc | source]
sun.io
abstract public class: CharToByteConverter [javadoc | source]
java.lang.Object
   sun.io.CharToByteConverter
Deprecated! Replaced - by java.nio.charset . THIS API WILL BE REMOVED IN J2SE 1.6.

An abstract base class for subclasses which convert Unicode characters into an external encoding.
Field Summary
protected  boolean subMode    Substitution mode flag. 
protected  byte[] subBytes    Bytes to substitute for unmappable input. 
protected  int charOff    Offset of next character to be converted. 
protected  int byteOff    Offset of next byte to be output. 
protected  int badInputLength    Length of bad input that caused conversion to stop. 
Method from sun.io.CharToByteConverter Summary:
canConvert,   convert,   convertAll,   convertAny,   flush,   flushAny,   getBadInputLength,   getCharacterEncoding,   getConverter,   getDefault,   getMaxBytesPerChar,   nextByteIndex,   nextCharIndex,   reset,   setSubstitutionBytes,   setSubstitutionMode,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.io.CharToByteConverter Detail:
 public boolean canConvert(char c) 
      Deprecated!
    Returns true if the given character can be converted to the target character encoding.
 abstract public int convert(char[] input,
    int inStart,
    int inEnd,
    byte[] output,
    int outStart,
    int outEnd) throws MalformedInputException, UnknownCharacterException, ConversionBufferFullException       Deprecated!
    Converts an array of Unicode characters into an array of bytes in the target character encoding. This method allows a buffer by buffer conversion of a data stream. The state of the conversion is saved between calls to convert. 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 byte[] convertAll(char[] input) throws MalformedInputException 
      Deprecated!
    Converts an array of Unicode characters into an array of bytes in the target character encoding. 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 nextCharIndex.

    This method uses substitution mode when performing the conversion. The method setSubstitutionBytes may be used to determine what bytes 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.

 public int convertAny(char[] input,
    int inStart,
    int inEnd,
    byte[] output,
    int outStart,
    int outEnd) throws ConversionBufferFullException 
      Deprecated!
 abstract public int flush(byte[] output,
    int outStart,
    int outEnd) throws MalformedInputException, ConversionBufferFullException       Deprecated!
    Writes any remaining output to the output buffer and resets the converter to its initial state.
 public int flushAny(byte[] output,
    int outStart,
    int outEnd) throws ConversionBufferFullException 
      Deprecated!
    Writes any remaining output to the output buffer and resets the converter to its initial state. May only be called when substitution mode is turned on, and never complains about malformed input (always substitutes).
 public int getBadInputLength() 
      Deprecated!
    Returns the length, in chars, 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 CharToByteConverter getConverter(String encoding) throws UnsupportedEncodingException 
      Deprecated!
    Returns appropriate CharToByteConverter subclass instance.
 public static CharToByteConverter getDefault() 
      Deprecated!
    Create an instance of the default CharToByteConverter subclass.
 abstract public int getMaxBytesPerChar()       Deprecated!
    Returns the maximum number of bytes needed to convert a char. Useful for calculating the maximum output buffer size needed for a particular input buffer.
 public int nextByteIndex() 
      Deprecated!
    Returns the index of the byte just past the last byte written by the previous call to convert.
 public int nextCharIndex() 
      Deprecated!
    Returns the index of the character just past the last character successfully converted by the previous call to convert.
 abstract public  void reset()       Deprecated!
    Resets converter to its initial state.
 public  void setSubstitutionBytes(byte[] newSubBytes) throws IllegalArgumentException 
      Deprecated!
    Sets the substitution bytes to use when the converter is in substitution mode. The given bytes should represent a valid character in the target character encoding and must not be longer than the value returned by getMaxBytesPerChar for this converter.
 public  void setSubstitutionMode(boolean 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 setSubstitutionBytes. When not in substitution mode, the converter will throw an UnknownCharacterException when it encounters untranslatable input.
 public String toString() 
      Deprecated!
    Returns a string representation of the class.