|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> services >> [ io overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.iapi.services.io
Class ArrayInputStream

java.lang.Objectjava.io.InputStream
org.apache.derby.iapi.services.io.ArrayInputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.DataInput, ErrorInfo, ErrorObjectInput, Limit, LimitObjectInput, java.io.ObjectInput
- public final class ArrayInputStream
- extends java.io.InputStream
- implements LimitObjectInput
- extends java.io.InputStream
An InputStream that allows reading from an array of bytes. The array of bytes that is read from can be changed without having to create a new instance of this class.
| Field Summary | |
private int |
end
|
private ErrorObjectInput |
oi
|
private byte[] |
pageData
|
private int |
position
|
private int |
start
|
| Constructor Summary | |
ArrayInputStream()
|
|
ArrayInputStream(byte[] data)
|
|
ArrayInputStream(byte[] data,
int offset,
int length)
|
|
| Method Summary | |
int |
available()
This method returns the number of bytes that can be read without blocking. |
int |
clearLimit()
Clears the limit by setting the limit to be the entire byte array. |
byte[] |
getData()
Return a reference to the array of bytes this stream is going to read from so that caller may load it with stuff |
java.lang.String |
getErrorInfo()
|
java.lang.Exception |
getNestedException()
|
int |
getPosition()
|
int |
read()
This method reading a byte of data from a stream. |
int |
read(byte[] b,
int off,
int len)
This method reads raw bytes and stores them in a byte array buffer buf starting at position offset into the
buffer. |
boolean |
readBoolean()
This method reads a Java boolean value from an input stream. |
byte |
readByte()
This method reads a Java byte value from an input stream. |
char |
readChar()
This method reads a Java char value from an input stream. |
int |
readCloudscapeUTF(char[][] rawData_array)
read in a cloudscape UTF formated string into a char[]. |
int |
readCompressedInt()
Read a compressed int from the stream. |
long |
readCompressedLong()
Read a compressed long from the stream. |
double |
readDouble()
This method reads a Java double value from an input stream. |
float |
readFloat()
This method reads a Java float value from an input stream. |
void |
readFully(byte[] b)
This method reads raw bytes into the passed array until the array is full. |
void |
readFully(byte[] b,
int off,
int len)
This method reads raw bytes into the passed array buf
starting
offset bytes into the buffer. |
int |
readInt()
This method reads a Java int value from an input stream
It operates by reading four bytes from the stream and converting them to
a single Java int. |
java.lang.String |
readLine()
This method reads the next line of text data from an input stream. |
long |
readLong()
This method reads a Java long value from an input stream
It operates by reading eight bytes from the stream and converting them to
a single Java long. |
java.lang.Object |
readObject()
Reads an object instance and returns it. |
short |
readShort()
This method reads a signed 16-bit value into a Java in from the stream. |
int |
readUnsignedByte()
This method reads 8 unsigned bits into a Java int value from
the stream. |
int |
readUnsignedShort()
This method reads 16 unsigned bits into a Java int value from the stream. |
java.lang.String |
readUTF()
This method reads a String from an input stream that is
encoded in a modified UTF-8 format. |
void |
setData(byte[] data)
Set the array of bytes to be read. |
void |
setData(byte[] data,
int offset,
int length)
|
void |
setLimit(int length)
Set the limit of the data that can be read or written. |
int |
setLimit(int offset,
int length)
A setLimit which also sets the position to be offset. |
void |
setPosition(int newPosition)
|
long |
skip(long count)
This method causes the specified number of bytes to be read and discarded. |
int |
skipBytes(int n)
This method skips and discards the specified number of bytes in an input stream. |
| Methods inherited from class java.io.InputStream |
close, mark, markSupported, read, reset |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.io.ObjectInput |
close, read |
| Field Detail |
pageData
private byte[] pageData
start
private int start
end
private int end
position
private int position
oi
private ErrorObjectInput oi
| Constructor Detail |
ArrayInputStream
public ArrayInputStream()
ArrayInputStream
public ArrayInputStream(byte[] data)
ArrayInputStream
public ArrayInputStream(byte[] data,
int offset,
int length)
throws java.io.IOException
| Method Detail |
setData
public void setData(byte[] data)
- Set the array of bytes to be read.
setData
public void setData(byte[] data,
int offset,
int length)
throws java.io.IOException
getData
public byte[] getData()
- Return a reference to the array of bytes this stream is going to read
from so that caller may load it with stuff
read
public int read()
throws java.io.IOException
- Description copied from interface:
java.io.ObjectInput - This method reading a byte of data from a stream. It returns that byte
as an
int. This method blocks if no data is available to be read.- Specified by:
readin interfacejava.io.ObjectInput
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Description copied from interface:
java.io.ObjectInput - This method reads raw bytes and stores them in a byte array buffer
bufstarting at positionoffsetinto the buffer. A maximum oflenbytes will be read. Note that this method blocks if no data is available, but will not necessarily block until it can readlenbytes of data. That is, a "short count" is possible.- Specified by:
readin interfacejava.io.ObjectInput
skip
public long skip(long count)
throws java.io.IOException
- Description copied from interface:
java.io.ObjectInput - This method causes the specified number of bytes to be read and
discarded. It is possible that fewer than the requested number of bytes
will actually be skipped.
- Specified by:
skipin interfacejava.io.ObjectInput
getPosition
public int getPosition()
setPosition
public final void setPosition(int newPosition)
throws java.io.IOException
available
public int available()
throws java.io.IOException
- Description copied from interface:
java.io.ObjectInput - This method returns the number of bytes that can be read without
blocking.
- Specified by:
availablein interfacejava.io.ObjectInput
setLimit
public int setLimit(int offset,
int length)
throws java.io.IOException
- A setLimit which also sets the position to be offset.
setLimit
public final void setLimit(int length)
throws java.io.IOException
- Description copied from interface:
Limit - Set the limit of the data that can be read or written. After this
call up to and including length bytes can be read from or skipped in
the stream.
On input classes (e.g. InputStreams) any attempt to read or skip beyond the limit will result in an end of file indication (e.g. read() methods returning -1 or throwing EOFException).
On output classes (e.g. OutputStream) any attempt to write more beyond the limit will result in an EOFException
clearLimit
public final int clearLimit()
- Clears the limit by setting the limit to be the entire byte array.
- Specified by:
clearLimitin interfaceLimit
readFully
public final void readFully(byte[] b)
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads raw bytes into the passed array until the array is
full. Note that this method blocks until the data is available and
throws an exception if there is not enough data left in the stream to
fill the buffer. Note also that zero length buffers are permitted.
In this case, the method will return immediately without reading any
bytes from the stream.
- Specified by:
readFullyin interfacejava.io.DataInput
readFully
public final void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads raw bytes into the passed array
bufstartingoffsetbytes into the buffer. The number of bytes read will be exactlylen. Note that this method blocks until the data is available and throws an exception if there is not enough data left in the stream to readlenbytes. Note also that zero length buffers are permitted. In this case, the method will return immediately without reading any bytes from the stream.- Specified by:
readFullyin interfacejava.io.DataInput
skipBytes
public final int skipBytes(int n)
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method skips and discards the specified number of bytes in an
input stream. Note that this method may skip less than the requested
number of bytes. The actual number of bytes skipped is returned.
No bytes are skipped if a negative number is passed to this method.
- Specified by:
skipBytesin interfacejava.io.DataInput
readBoolean
public final boolean readBoolean()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java boolean value from an input stream. It does
so by reading a single byte of data. If that byte is zero, then the
value returned is
false. If the byte is non-zero, then the value returned istrue.This method can read a
booleanwritten by an object implementing thewriteBoolean()method in theDataOutputinterface.- Specified by:
readBooleanin interfacejava.io.DataInput
readByte
public final byte readByte()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java byte value from an input stream. The value
is in the range of -128 to 127.
This method can read a
bytewritten by an object implementing thewriteByte()method in theDataOutputinterface.- Specified by:
readBytein interfacejava.io.DataInput
readUnsignedByte
public final int readUnsignedByte()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads 8 unsigned bits into a Java
intvalue from the stream. The value returned is in the range of 0 to 255.This method can read an unsigned byte written by an object implementing the
writeByte()method in theDataOutputinterface.- Specified by:
readUnsignedBytein interfacejava.io.DataInput
readShort
public final short readShort()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a signed 16-bit value into a Java in from the stream.
It operates by reading two bytes from the stream and converting them to
a single 16-bit Java
short. The two bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1andbyte2represent the first and second byte read from the stream respectively, they will be transformed to ashortin the following manner:(short)(((byte1 & 0xFF) << 8) + (byte2 & 0xFF))The value returned is in the range of -32768 to 32767.
This method can read a
shortwritten by an object implementing thewriteShort()method in theDataOutputinterface.- Specified by:
readShortin interfacejava.io.DataInput
readUnsignedShort
public final int readUnsignedShort()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads 16 unsigned bits into a Java int value from the stream.
It operates by reading two bytes from the stream and converting them to
a single Java
int. The two bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1andbyte2represent the first and second byte read from the stream respectively, they will be transformed to anintin the following manner:(int)(((byte1 0xFF) << 8) + (byte2 & 0xFF))The value returned is in the range of 0 to 65535.
This method can read an unsigned short written by an object implementing the
writeShort()method in theDataOutputinterface.- Specified by:
readUnsignedShortin interfacejava.io.DataInput
readChar
public final char readChar()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java
charvalue from an input stream. It operates by reading two bytes from the stream and converting them to a single 16-bit Javachar. The two bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1andbyte2represent the first and second byte read from the stream respectively, they will be transformed to acharin the following manner:(char)((byte1 << 8) + byte2)This method can read a
charwritten by an object implementing thewriteChar()method in theDataOutputinterface.- Specified by:
readCharin interfacejava.io.DataInput
readInt
public final int readInt()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java
intvalue from an input stream It operates by reading four bytes from the stream and converting them to a single Javaint. The bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1throughbyte4represent the first four bytes read from the stream, they will be transformed to anintin the following manner:(int)(((byte1 & 0xFF) << 24) + ((byte2 & 0xFF) << 16) + ((byte3 & 0xFF)<< 8) + (byte4 & 0xFF)))The value returned is in the range of -2147483648 to 2147483647.
This method can read an
intwritten by an object implementing thewriteInt()method in theDataOutputinterface.- Specified by:
readIntin interfacejava.io.DataInput
readLong
public final long readLong()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java
longvalue from an input stream It operates by reading eight bytes from the stream and converting them to a single Javalong. The bytes are stored most significant byte first (i.e., "big endian") regardless of the native host byte ordering.As an example, if
byte1throughbyte8represent the first eight bytes read from the stream, they will be transformed to anlongin the following manner:(long)(((byte1 & 0xFF) << 56) + ((byte2 & 0xFF) << 48) + ((byte3 & 0xFF) << 40) + ((byte4 & 0xFF) << 32) + ((byte5 & 0xFF) << 24) + ((byte6 & 0xFF) << 16) + ((byte7 & 0xFF) << 8) + (byte8 & 0xFF)))The value returned is in the range of -9223372036854775808 to 9223372036854775807.
This method can read an
longwritten by an object implementing thewriteLong()method in theDataOutputinterface.- Specified by:
readLongin interfacejava.io.DataInput
readFloat
public final float readFloat()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java float value from an input stream. It operates
by first reading an
intvalue from the stream by calling thereadInt()method in this interface, then converts thatintto afloatusing theintBitsToFloatmethod in the classjava.lang.Float.This method can read a
floatwritten by an object implementing thewriteFloat()method in theDataOutputinterface.- Specified by:
readFloatin interfacejava.io.DataInput
readDouble
public final double readDouble()
throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a Java double value from an input stream. It operates
by first reading a
longvalue from the stream by calling thereadLong()method in this interface, then converts thatlongto adoubleusing thelongBitsToDoublemethod in the classjava.lang.Double.This method can read a
doublewritten by an object implementing thewriteDouble()method in theDataOutputinterface.- Specified by:
readDoublein interfacejava.io.DataInput
readLine
public final java.lang.String readLine() throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads the next line of text data from an input stream.
It operates by reading bytes and converting those bytes to
charvalues by treating the byte read as the low eight bits of thecharand using 0 as the high eight bits. Because of this, it does not support the full 16-bit Unicode character set.The reading of bytes ends when either the end of file or a line terminator is encountered. The bytes read are then returned as a
String. A line terminator is a byte sequence consisting of either\r,\nor\r\n. These termination charaters are discarded and are not returned as part of the string. A line is also terminated by an end of file condition.- Specified by:
readLinein interfacejava.io.DataInput
readUTF
public final java.lang.String readUTF() throws java.io.IOException
- Description copied from interface:
java.io.DataInput - This method reads a
Stringfrom an input stream that is encoded in a modified UTF-8 format. This format has a leading two byte sequence that contains the remaining number of bytes to read. This two byte sequence is read using thereadUnsignedShort()method of this interface. After the number of remaining bytes have been determined, these bytes are read an transformed intocharvalues. Thesecharvalues are encoded in the stream using either a one, two, or three byte format. The particular format in use can be determined by examining the first byte read.If the first byte has a high order bit of 0, then that character consists on only one byte. This character value consists of seven bits that are at positions 0 through 6 of the byte. As an example, if
byte1is the byte read from the stream, it would be converted to acharlike so:(char)byte1If the first byte has 110 as its high order bits, then the character consists of two bytes. The bits that make up the character value are in positions 0 through 4 of the first byte and bit positions 0 through 5 of the second byte. (The second byte should have 10 as its high order bits). These values are in most significant byte first (i.e., "big endian") order.
As an example, if
byte1andbyte2are the first two bytes read respectively, and the high order bits of them match the patterns which indicate a two byte character encoding, then they would be converted to a Javacharlike so:(char)(((byte1 & 0x1F) << 6) + (byte2 & 0x3F))If the first byte has a 1110 as its high order bits, then the character consists of three bytes. The bits that make up the character value are in positions 0 through 3 of the first byte and bit positions 0 through 5 of the other two bytes. (The second and third bytes should have 10 as their high order bits). These values are in most significant byte first (i.e., "big endian") order.
As an example, if
byte1,byte2, andbyte3are the three bytes read, and the high order bits of them match the patterns which indicate a three byte character encoding, then they would be converted to a Javacharlike so:(char)(((byte1 & 0x0F) << 12) + ((byte2 & 0x3F) + (byte3 & 0x3F))Note that all characters are encoded in the method that requires the fewest number of bytes with the exception of the character with the value of\<llll>u0000which is encoded as two bytes. This is a modification of the UTF standard used to prevent C language styleNULvalues from appearing in the byte stream.This method can read data that was written by an object implementing the
writeUTF()method inDataOutput.- Specified by:
readUTFin interfacejava.io.DataInput
readCloudscapeUTF
public final int readCloudscapeUTF(char[][] rawData_array)
throws java.io.IOException
- read in a cloudscape UTF formated string into a char[].
This routine inline's the code to read a UTF format string from a byte[] array (pageData), into a char[] array. The string will be read into the char[] array passed into this routine through rawData_array[0] if it is big enough. If it is not big enough a new char[] will be alocated and returned to the caller by putting it into rawData_array[0].
To see detailed description of the cloudscape UTF format see the writeExternal() routine of SQLChar.
The routine returns the number of char's read into the returned char[], note that this length may smaller than the actual length of the char[] array.
readCompressedInt
public final int readCompressedInt()
throws java.io.IOException
- Read a compressed int from the stream.
Read a compressed int from the stream, which is assumed to have been written by a call to CompressNumber.writeInt().
Code from CompressedNumber is inlined here so that these fields can be read from the array with a minimum of function calls.
The format of a compressed int is as follows: Formats are (with x representing value bits):
1 Byte- 00xxxxxx val <= 63 (0x3f) 2 Byte- 01xxxxxx xxxxxxxx val > 63 && <= 16383 (0x3fff) 4 byte- 1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx val > 16383 && <= MAX_INT
readCompressedLong
public final long readCompressedLong()
throws java.io.IOException
- Read a compressed long from the stream.
Read a compressed long from the stream, which is assumed to have been written by a call to CompressNumber.writeLong().
Code from CompressedNumber is inlined here so that these fields can be read from the array with a minimum of function calls.
The format of a compressed int is as follows: Formats are (with x representing value bits):
value <= 16383 (0x3fff): 2 byte - 00xxxxxx xxxxxxxx value > 16383 && <= 0x3fffffff: 4 byte - 01xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx value > 0x3fffffff && <= MAX_LONG: 8 byte - 1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
readObject
public java.lang.Object readObject() throws java.lang.ClassNotFoundException, java.io.IOException
- Description copied from interface:
java.io.ObjectInput - Reads an object instance and returns it. If the class for the object
being read cannot be found, then a
ClassNotFoundExceptionwill be thrown.- Specified by:
readObjectin interfacejava.io.ObjectInput
getErrorInfo
public java.lang.String getErrorInfo()
- Specified by:
getErrorInfoin interfaceErrorObjectInput
getNestedException
public java.lang.Exception getNestedException()
- Specified by:
getNestedExceptionin interfaceErrorObjectInput
|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> services >> [ io overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC