ewe.io
Class AsciiCodec

java.lang.Object
  extended byewe.io.AsciiCodec
All Implemented Interfaces:
Copyable, TextCodec

public class AsciiCodec
extends Object
implements TextCodec


Field Summary
static int STRIP_CR
          This is a creation option.
static int STRIP_CR_ON_DECODE
          This is a creation option.
static int STRIP_CR_ON_ENCODE
          This is a creation option.
 
Constructor Summary
AsciiCodec()
           
AsciiCodec(int options)
           
 
Method Summary
 void closeCodec()
          This aborts any on-going processing and frees resources associated with the codec.
 CharArray decodeText(byte[] encoded, int start, int length, boolean endOfData, CharArray dest)
          Decode the bytes into Unicode characters.
 ByteArray encodeText(char[] text, int start, int length, boolean endOfData, ByteArray dest)
          Enocde the Unicode characters into a byte Stream.
 Object getCopy()
          This should return a new instance of the TextCodec, ready to begin converting a new set of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

STRIP_CR_ON_DECODE

public static final int STRIP_CR_ON_DECODE
This is a creation option. It specifies that CR characters should be removed when encoding text into ASCII.

See Also:
Constant Field Values

STRIP_CR_ON_ENCODE

public static final int STRIP_CR_ON_ENCODE
This is a creation option. It specifies that CR characters should be removed when decoding text from ASCII.

See Also:
Constant Field Values

STRIP_CR

public static final int STRIP_CR
This is a creation option. It specifies that CR characters should be removed when decoding text from ASCII AND encoding text to ASCII.

See Also:
Constant Field Values
Constructor Detail

AsciiCodec

public AsciiCodec(int options)

AsciiCodec

public AsciiCodec()
Method Detail

encodeText

public ByteArray encodeText(char[] text,
                            int start,
                            int length,
                            boolean endOfData,
                            ByteArray dest)
                     throws IOException
Description copied from interface: TextCodec
Enocde the Unicode characters into a byte Stream.

Specified by:
encodeText in interface TextCodec
Parameters:
text - The characters to encode. This can be null if length is zero and endOfData is true. You would use those settings to tell the codec that no more characters are to be encoded and the final set of output bytes (if any) should be output.
start - The start of the characters in the text array.
length - The number of characters to encode.
endOfData - If this is true this tells the codec that no more characters are to be encoded and the final set of output bytes (if any) should be output.
dest - A ByteArray to hold the output data. The output data goes in the data member and and the length member holds how many bytes were output.
Returns:
The destination ByteArray or a new one if the destination was null.
Throws:
IOException - if an error occurs during encoding.

decodeText

public CharArray decodeText(byte[] encoded,
                            int start,
                            int length,
                            boolean endOfData,
                            CharArray dest)
                     throws IOException
Description copied from interface: TextCodec
Decode the bytes into Unicode characters.

Specified by:
decodeText in interface TextCodec
Parameters:
encoded - The encoded bytes. This can be null if length is zero and endOfData is true. You would use those settings to tell the codec that no more characters are to be decoded and the final set of decoded characters (if any) should be output.
start - The start of the bytes in the byte array.
length - The number of bytes to decode.
endOfData - If this is true this tells the codec that no more characters are to be decoded and the final set of decoded characters (if any) should be output.
dest - A CharArray to hold the output data. The output data goes in the data member and and the length member holds how many characters were output.
Returns:
The destination CharArray or a new one if the destination was null.
Throws:
IOException - if an error occurs during decoding, including badly formatted data.

closeCodec

public void closeCodec()
                throws IOException
Description copied from interface: TextCodec
This aborts any on-going processing and frees resources associated with the codec. The codec should not be used again after this. An IOException should be thrown if there was an error closing the process.

Specified by:
closeCodec in interface TextCodec
Throws:
IOException

getCopy

public Object getCopy()
Description copied from interface: TextCodec
This should return a new instance of the TextCodec, ready to begin converting a new set of data. This is needed because TextCodec objects are not resetable and cannot be reused.

Specified by:
getCopy in interface TextCodec