Class DataByteArrayInputStream
java.lang.Object
java.io.InputStream
org.apache.activemq.store.kahadb.disk.util.DataByteArrayInputStream
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
Optimized ByteArrayInputStream that can be used more than once
-
Constructor Summary
ConstructorsConstructorDescriptionCreatesWireByteArrayInputStreamwith a minmalist byte arrayDataByteArrayInputStream(byte[] buf) Creates aStoreByteArrayInputStream.DataByteArrayInputStream(ByteSequence sequence) Creates aStoreByteArrayInputStream. -
Method Summary
Modifier and TypeMethodDescriptionintintintgetPos()byte[]intread()Reads the next byte of data from this input stream.intread(byte[] b, int off, int len) Reads up tolenbytes of data into an array of bytes from this input stream.booleanbytereadByte()charreadChar()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) intreadInt()readLine()longreadLong()shortintintreadUTF()voidrestart()voidrestart(byte[] newBuff) reset theStoreByteArrayInputStreamto use an new byte arrayvoidrestart(int size) re-start the input stream - reusing the current buffervoidrestart(ByteSequence sequence) reset theStoreByteArrayInputStreamto use an new ByteSequencevoidsetLength(int length) voidsetPos(int pos) intsize()intskipBytes(int n) Methods inherited from class java.io.InputStream
close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
DataByteArrayInputStream
public DataByteArrayInputStream(byte[] buf) Creates aStoreByteArrayInputStream.- Parameters:
buf- the input buffer.
-
DataByteArrayInputStream
Creates aStoreByteArrayInputStream.- Parameters:
sequence- the input buffer.
-
DataByteArrayInputStream
public DataByteArrayInputStream()CreatesWireByteArrayInputStreamwith a minmalist byte array
-
-
Method Details
-
size
public int size()- Returns:
- the size
-
getRawData
public byte[] getRawData()- Returns:
- the underlying data array
-
restart
public void restart(byte[] newBuff) reset theStoreByteArrayInputStreamto use an new byte array- Parameters:
newBuff-
-
restart
public void restart() -
restart
reset theStoreByteArrayInputStreamto use an new ByteSequence- Parameters:
sequence-
-
restart
public void restart(int size) re-start the input stream - reusing the current buffer- Parameters:
size-
-
read
public int read()Reads the next byte of data from this input stream. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned.This
readmethod cannot block.- Specified by:
readin classInputStream- Returns:
- the next byte of data, or
-1if the end of the stream has been reached.
-
read
public int read(byte[] b, int off, int len) Reads up tolenbytes of data into an array of bytes from this input stream.- Overrides:
readin classInputStream- Parameters:
b- the buffer into which the data is read.off- the start offset of the data.len- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the stream has been reached.
-
available
public int available()- Overrides:
availablein classInputStream- Returns:
- the number of bytes that can be read from the input stream without blocking.
-
readFully
public void readFully(byte[] b) -
readFully
public void readFully(byte[] b, int off, int len) -
skipBytes
public int skipBytes(int n) -
readBoolean
public boolean readBoolean()- Specified by:
readBooleanin interfaceDataInput
-
readByte
public byte readByte() -
readUnsignedByte
public int readUnsignedByte()- Specified by:
readUnsignedBytein interfaceDataInput
-
readShort
public short readShort() -
readUnsignedShort
public int readUnsignedShort()- Specified by:
readUnsignedShortin interfaceDataInput
-
readChar
public char readChar() -
readInt
public int readInt() -
readLong
public long readLong() -
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readLine
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
getPos
public int getPos() -
setPos
public void setPos(int pos) -
getLength
public int getLength() -
setLength
public void setLength(int length)
-