Top Description Fields Constructors Methods
org.apache.derby.client.net

public final Class EncodedInputStream

extends InputStream
Class Inheritance
Imports
java.io.InputStream, .Reader, .OutputStreamWriter, .ByteArrayInputStream, .IOException, java.nio.charset.Charset

Create an encoded stream from a Reader. 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 instance createUTF8Stream.

Field Summary

Modifier and TypeField and Description
private static final int
private final char[]
private ByteArrayInputStream
private PublicBufferOutputStream
private OutputStreamWriter
private Reader
private static final ByteArrayInputStream
private static final Charset
private static final Charset

Constructor Summary

AccessConstructor and Description
private
EncodedInputStream(Reader
the Reader to read characters from
reader
,
Charset
the encoding to use in the encoded stream
encoding
,
int
the size of the char buffer. This is the number of characters read at once from the Reader.
charBufferSize
,
int
the initial size of the byte buffer. holding the encoded bytes
initialByteBufferSize
)

Create an encoded stream for the specified Reader.

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.
public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.
pack-priv static EncodedInputStream

Returns:

a byte-stream with UTF-16BE encoded characters
createUTF16BEStream
(Reader
the Reader to read characters from.
reader
)

Create a UTF-16BE encoded stream from the given Reader.

public static EncodedInputStream

Returns:

a byte-stream with UTF-8 encoded characters
createUTF8Stream
(Reader
the Reader to read characters from.
reader
)

Create a UTF-8 encoded stream from the given Reader.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.
private ByteArrayInputStream
reEncode(Reader reader)

Inherited from java.io.InputStream:
markmarkSupportednullInputStreamreadreadreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

BUFFERED_CHAR_LENback to summary
private static final int BUFFERED_CHAR_LEN
decodedBuffer_back to summary
private final char[] decodedBuffer_
encodedInputStream_back to summary
private ByteArrayInputStream encodedInputStream_
encodedOutputStream_back to summary
private PublicBufferOutputStream encodedOutputStream_
encodedStreamWriter_back to summary
private OutputStreamWriter encodedStreamWriter_
reader_back to summary
private Reader reader_
suspendMarkerback to summary
private static final ByteArrayInputStream suspendMarker
UTF_16BEback to summary
private static final Charset UTF_16BE
UTF_8back to summary
private static final Charset UTF_8

Constructor Detail

EncodedInputStreamback to summary
private EncodedInputStream(Reader reader, Charset encoding, int charBufferSize, int initialByteBufferSize)

Create an encoded stream for the specified Reader.

Parameters
reader:Reader

the Reader to read characters from

encoding:Charset

the encoding to use in the encoded stream

charBufferSize:int

the size of the char buffer. This is the number of characters read at once from the Reader.

initialByteBufferSize:int

the initial size of the byte buffer. holding the encoded bytes

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream.

Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
createUTF16BEStreamback to summary
pack-priv static EncodedInputStream createUTF16BEStream(Reader reader)

Create a UTF-16BE encoded stream from the given Reader.

Parameters
reader:Reader

the Reader to read characters from.

Returns:EncodedInputStream

a byte-stream with UTF-16BE encoded characters

createUTF8Streamback to summary
public static EncodedInputStream createUTF8Stream(Reader reader)

Create a UTF-8 encoded stream from the given Reader.

Parameters
reader:Reader

the Reader to read characters from.

Returns:EncodedInputStream

a byte-stream with UTF-8 encoded characters

readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs.
reEncodeback to summary
private ByteArrayInputStream reEncode(Reader reader) throws IOException