| java.lang.Object java.io.InputStream org.apache.derby.client.am.ByteArrayCombinerStream
ByteArrayCombinerStream | public class ByteArrayCombinerStream extends InputStream (Code) | | A stream whose source is a list of byte arrays.
This class was created when first implementing the JDBC 4 length less
overloads in the client driver. The reason was missing support for
streaming data with unknown length from the client to the server.
The purpose of the stream is to avoid having to repeatedly copy data to grow
the byte buffer, or doing a single big copy to combine the byte arrays in
the end. This is important for the temporary solution, since we must
materialize the stream to find the length anyway.
If there is less data available than the specified length, an exception is
thrown. Available data is determined by the length of the byte arrays, not
the contents of them. A byte array with all 0's is considered valid data.
Besides from truncation, this stream does not change the underlying data in
any way.
|
Constructor Summary | |
public | ByteArrayCombinerStream(ArrayList arraysIn, long length) Create a stream whose source is a list of byte arrays.
Parameters: arraysIn - an ArrayList with references to the sourcebyte arrays. |
Method Summary | |
public int | available() Return the number of available bytes. | public int | read() Read a single byte. | public int | read(byte[] buf, int offset, int length) Reads up to len bytes of data from the input stream into an array of
bytes.
An attempt is made to read as many as len bytes, but
a smaller number may be read. |
ByteArrayCombinerStream | public ByteArrayCombinerStream(ArrayList arraysIn, long length)(Code) | | Create a stream whose source is a list of byte arrays.
Parameters: arraysIn - an ArrayList with references to the sourcebyte arrays. The references are copied to a newArrayList instance. Parameters: length - the length of the stream. Never published outsidethis object. Note that the length specified can be shorterthan the actual number of bytes in the byte arrays. throws: IllegalArgumentException - if there is less data available thanspecified by length , or length isnegative. |
available | public int available()(Code) | | Return the number of available bytes.
The method assumes the specified length of the stream is correct.
number of available bytes |
read | public int read() throws IOException(Code) | | Read a single byte.
a byte, or -1 if the end-of-stream is reached |
read | public int read(byte[] buf, int offset, int length) throws IOException(Code) | | Reads up to len bytes of data from the input stream into an array of
bytes.
An attempt is made to read as many as len bytes, but
a smaller number may be read. The number of bytes actually read
is returned as an integer.
Parameters: buf - the array to copy bytes into Parameters: offset - offset into the array Parameters: length - the maximum number of bytes to read the number of bytes read, or -1 if end-of-streamis reached |
|
|