org.apache.derby.client.net
Class EncodedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.derby.client.net.EncodedInputStream
All Implemented Interfaces:
java.io.Closeable

public final class EncodedInputStream
extends java.io.InputStream

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.


Nested Class Summary
(package private) static class EncodedInputStream.PublicBufferOutputStream
           
 
Field Summary
private static int BUFFERED_CHAR_LEN
           
private  char[] decodedBuffer_
           
private  java.io.ByteArrayInputStream encodedInputStream_
           
private  EncodedInputStream.PublicBufferOutputStream encodedOutputStream_
           
private  java.io.OutputStreamWriter encodedStreamWriter_
           
private  java.io.Reader reader_
           
private static java.io.ByteArrayInputStream suspendMarker
           
 
Constructor Summary
private EncodedInputStream(java.io.Reader reader, java.lang.String encoding, int charBufferSize, int initialByteBufferSize)
          Create an encoded stream for the specified Reader.
 
Method Summary
 int available()
           
 void close()
           
(package private) static EncodedInputStream createUTF16BEStream(java.io.Reader reader)
          Create a UTF-16BE encoded stream from the given Reader.
static EncodedInputStream createUTF8Stream(java.io.Reader reader)
          Create a UTF-8 encoded stream from the given Reader.
protected  void finalize()
           
 int read()
           
private  java.io.ByteArrayInputStream reEncode(java.io.Reader reader)
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 EncodedInputStream.PublicBufferOutputStream encodedOutputStream_

encodedInputStream_

private java.io.ByteArrayInputStream encodedInputStream_
Constructor Detail

EncodedInputStream

private EncodedInputStream(java.io.Reader reader,
                           java.lang.String encoding,
                           int charBufferSize,
                           int initialByteBufferSize)
Create an encoded stream for the specified Reader.

Parameters:
reader - the Reader to read characters from
encoding - the encoding to use in the encoded stream
charBufferSize - the size of the char buffer. This is the number of characters read at once from the Reader.
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 given Reader.

Parameters:
reader - the Reader to 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 given Reader.

Parameters:
reader - the Reader to 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:
available in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

finalize

protected void finalize()
                 throws java.io.IOException
Overrides:
finalize in class java.lang.Object
Throws:
java.io.IOException

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.