Class ArrayInputStream
- All Implemented Interfaces:
Closeable, DataInput, ObjectInput, AutoCloseable, ErrorInfo, ErrorObjectInput, Limit, LimitObjectInput
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate an ArrayInputStream with a zero length byte array.ArrayInputStream(byte[] data) Create an ArrayInputStream with the passed in data. -
Method Summary
Modifier and TypeMethodDescriptionintfinal intClears 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 stuffintintread()intread(byte[] b, int off, int len) final booleanfinal bytereadByte()final charreadChar()final intRead a compressed int from the stream.final longRead a compressed long from the stream.final intreadDerbyUTF(char[][] rawData_array, int utflen) read in a Derby UTF formated string into a char[].final doublefinal floatfinal voidreadFully(byte[] b) final voidreadFully(byte[] b, int off, int len) final intreadInt()final StringreadLine()final longreadLong()final shortfinal intfinal intfinal StringreadUTF()voidsetData(byte[] data) Set the array of bytes to be read.final voidsetLimit(int length) Set the limit of the data that can be read or written.voidsetLimit(int offset, int length) A setLimit which also sets the position to be offset.final voidsetPosition(int newPosition) longskip(long count) Skip as many bytes as possible, but no more thancount.final intskipBytes(int n) Skip as many bytes as possible, but no more thann.Methods inherited from class InputStream
close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferToMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ObjectInput
close, read
-
Field Details
-
pageData
private byte[] pageData -
start
private int start -
end
private int end -
position
private int position -
oi
-
-
Constructor Details
-
ArrayInputStream
public ArrayInputStream()Create an ArrayInputStream with a zero length byte array. The position is set to 0 and the limit is the entire byte array. -
ArrayInputStream
public ArrayInputStream(byte[] data) Create an ArrayInputStream with the passed in data. The position is set to 0 and the limit is the entire byte array.- Parameters:
data-
-
-
Method Details
-
setData
public void setData(byte[] data) Set the array of bytes to be read. Position is set to zero. -
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
- Specified by:
readin interfaceObjectInput- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Specified by:
readin interfaceObjectInput- Overrides:
readin classInputStream- Throws:
IOException
-
skip
Skip as many bytes as possible, but no more thancount.- Specified by:
skipin interfaceObjectInput- Overrides:
skipin classInputStream- Parameters:
count- the number of bytes to skip- Returns:
- the number of bytes that were skipped
- Throws:
IOException
-
getPosition
public int getPosition() -
setPosition
- Throws:
IOException
-
available
- Specified by:
availablein interfaceObjectInput- Overrides:
availablein classInputStream- Throws:
IOException
-
setLimit
A setLimit which also sets the position to be offset.- Throws:
IOException- limit is out of range
-
setLimit
Description copied from interface:LimitSet 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
- Specified by:
setLimitin interfaceLimit- Throws:
IOException- IOException from some underlying stream
-
clearLimit
public final int clearLimit()Clears the limit by setting the limit to be the entire byte array.- Specified by:
clearLimitin interfaceLimit- Returns:
- the number of bytes within the limit that have not been read or written.
- See Also:
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
skipBytes
Skip as many bytes as possible, but no more thann.- Specified by:
skipBytesin interfaceDataInput- Parameters:
n- the number of bytes to skip- Returns:
- the number of bytes that were skipped
- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readLine
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
readDerbyUTF
read in a Derby 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 Derby 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.
The stream must be positioned on the first user byte when this method is invoked.
- Parameters:
rawData_array- This parameter uses a element array to implement an in/out function parameter. The char[] array in rawData_array[0] is used to read the data into unless it is not big enough, then a new array is allocated and the old one discarded. In either case on return rawData_array[0] contains the filled in char[] - caller must allow that the array may or may not be different from the one passed in.utflen- the byte length of the value, or0if unknown- Returns:
- The the number of valid char's in the returned char[].
- Throws:
IOException- if an I/O error happens
-
readCompressedInt
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
- Throws:
IOException- if an I/O error happens
-
readCompressedLong
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- Throws:
IOException
-
readObject
- Specified by:
readObjectin interfaceObjectInput- Throws:
ClassNotFoundExceptionIOException
-
getErrorInfo
- Specified by:
getErrorInfoin interfaceErrorInfo- Specified by:
getErrorInfoin interfaceErrorObjectInput
-
getNestedException
- Specified by:
getNestedExceptionin interfaceErrorInfo- Specified by:
getNestedExceptionin interfaceErrorObjectInput
-