Package org.apache.derby.client.net
Class EncodedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.derby.client.net.EncodedInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class EncodedInputStream extends java.io.InputStreamCreate an encoded stream from aReader. This is an internal class, used to pass readers of characters as streams of bytes. The characters will be represented according to the specified encoding. It is up to the caller to ensure the specified encoding is available, and in general only encodings available as default from Java 1.3 and up should be used. Currently, the encodings 'UTF8' and 'UTF-16BE' are used. Streams are obtained by calling the static methods of this class, for instancecreateUTF8Stream.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBUFFERED_CHAR_LENprivate char[]decodedBuffer_private java.io.ByteArrayInputStreamencodedInputStream_private PublicBufferOutputStreamencodedOutputStream_private java.io.OutputStreamWriterencodedStreamWriter_private java.io.Readerreader_private static java.io.ByteArrayInputStreamsuspendMarkerprivate static java.nio.charset.CharsetUTF_16BEprivate static java.nio.charset.CharsetUTF_8
-
Constructor Summary
Constructors Modifier Constructor Description privateEncodedInputStream(java.io.Reader reader, java.nio.charset.Charset encoding, int charBufferSize, int initialByteBufferSize)Create an encoded stream for the specifiedReader.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()(package private) static EncodedInputStreamcreateUTF16BEStream(java.io.Reader reader)Create a UTF-16BE encoded stream from the givenReader.static EncodedInputStreamcreateUTF8Stream(java.io.Reader reader)Create a UTF-8 encoded stream from the givenReader.intread()private java.io.ByteArrayInputStreamreEncode(java.io.Reader reader)
-
-
-
Field Detail
-
UTF_8
private static final java.nio.charset.Charset UTF_8
-
UTF_16BE
private static final java.nio.charset.Charset UTF_16BE
-
BUFFERED_CHAR_LEN
private static final int BUFFERED_CHAR_LEN
- See Also:
- Constant Field Values
-
suspendMarker
private static final java.io.ByteArrayInputStream suspendMarker
-
reader_
private java.io.Reader reader_
-
decodedBuffer_
private final char[] decodedBuffer_
-
encodedStreamWriter_
private java.io.OutputStreamWriter encodedStreamWriter_
-
encodedOutputStream_
private PublicBufferOutputStream encodedOutputStream_
-
encodedInputStream_
private java.io.ByteArrayInputStream encodedInputStream_
-
-
Constructor Detail
-
EncodedInputStream
private EncodedInputStream(java.io.Reader reader, java.nio.charset.Charset encoding, int charBufferSize, int initialByteBufferSize)Create an encoded stream for the specifiedReader.- Parameters:
reader- theReaderto read characters fromencoding- the encoding to use in the encoded streamcharBufferSize- the size of the char buffer. This is the number of characters read at once from theReader.initialByteBufferSize- the initial size of the byte buffer. holding the encoded bytes
-
-
Method Detail
-
createUTF8Stream
public static EncodedInputStream createUTF8Stream(java.io.Reader reader)
Create a UTF-8 encoded stream from the givenReader.- Parameters:
reader- theReaderto read characters from.- Returns:
- a byte-stream with UTF-8 encoded characters
-
createUTF16BEStream
static EncodedInputStream createUTF16BEStream(java.io.Reader reader)
Create a UTF-16BE encoded stream from the givenReader.- Parameters:
reader- theReaderto read characters from.- Returns:
- a byte-stream with UTF-16BE encoded characters
-
reEncode
private java.io.ByteArrayInputStream reEncode(java.io.Reader reader) throws java.io.IOException- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
-