sun.io
Class CharToByteDBCS_EBCDIC

java.lang.Object
  extended by sun.io.CharToByteConverter
      extended by sun.io.CharToByteDBCS_EBCDIC
Direct Known Subclasses:
CharToByteCp930, CharToByteCp935, CharToByteCp937, CharToByteCp939

public abstract class CharToByteDBCS_EBCDIC
extends CharToByteConverter


Field Summary
protected  short[] index1
           
protected  String index2
           
protected  String index2a
           
protected  int mask1
           
protected  int mask2
           
protected  int shift
           
 
Fields inherited from class sun.io.CharToByteConverter
badInputLength, byteOff, charOff, subBytes, subMode
 
Constructor Summary
CharToByteDBCS_EBCDIC()
           
 
Method Summary
 boolean canConvert(char ch)
          Returns true if the given character can be converted to the target character encoding.
 int convert(char[] input, int inOff, int inEnd, byte[] output, int outOff, int outEnd)
          Character conversion
 int flush(byte[] output, int outStart, int outEnd)
          flush out any residual data and reset the buffer state
 int getMaxBytesPerChar()
          Returns the maximum number of bytes needed to convert a char.
 void reset()
          Resets converter to its initial state.
 void setSubstitutionBytes(byte[] newSubBytes)
          Sets the substitution bytes to use when the converter is in substitution mode.
 
Methods inherited from class sun.io.CharToByteConverter
convertAll, convertAny, flushAny, getBadInputLength, getCharacterEncoding, getConverter, getDefault, nextByteIndex, nextCharIndex, setSubstitutionMode, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index1

protected short[] index1

index2

protected String index2

index2a

protected String index2a

mask1

protected int mask1

mask2

protected int mask2

shift

protected int shift
Constructor Detail

CharToByteDBCS_EBCDIC

public CharToByteDBCS_EBCDIC()
Method Detail

flush

public int flush(byte[] output,
                 int outStart,
                 int outEnd)
          throws MalformedInputException,
                 ConversionBufferFullException
flush out any residual data and reset the buffer 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 UnknownCharacterException,
                   MalformedInputException,
                   ConversionBufferFullException
Character conversion

Specified by:
convert in class CharToByteConverter
Parameters:
input - array containing Unicode characters to be converted.
inOff - begin conversion at this offset in input array.
inEnd - stop conversion at this offset in input array (exclusive).
output - byte array to receive conversion result.
outOff - start writing to output array at this offset.
outEnd - stop writing to output array at this offset (exclusive).
Returns:
the number of bytes written to output.
Throws:
UnknownCharacterException - for any character that that cannot be converted to the external character encoding. Thrown only when converter is not in substitution mode.
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.
ConversionBufferFullException - if output array is filled prior to converting all the input.

reset

public void reset()
Resets converter to its initial state.

Specified by:
reset in class CharToByteConverter

getMaxBytesPerChar

public int getMaxBytesPerChar()
Returns the maximum number of bytes needed to convert a char.

Specified by:
getMaxBytesPerChar in class CharToByteConverter

setSubstitutionBytes

public void setSubstitutionBytes(byte[] newSubBytes)
                          throws IllegalArgumentException
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.

Overrides:
setSubstitutionBytes in class CharToByteConverter
Parameters:
newSubBytes - the substitution bytes
Throws:
IllegalArgumentException - if given byte array is longer than the value returned by the method getMaxBytesPerChar.
See Also:
CharToByteConverter.setSubstitutionMode(boolean), CharToByteConverter.getMaxBytesPerChar()

canConvert

public boolean canConvert(char ch)
Returns true if the given character can be converted to the target character encoding.

Overrides:
canConvert in class CharToByteConverter
Parameters:
ch - character to test
Returns:
true if given character is translatable, false otherwise.