Package org.fusesource.hawtbuf
Class DataByteArrayInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.fusesource.hawtbuf.DataByteArrayInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable
public final class DataByteArrayInputStream extends java.io.InputStream implements java.io.DataInputOptimized ByteArrayInputStream that can be used more than once
-
-
Constructor Summary
Constructors Constructor Description DataByteArrayInputStream()CreatesWireByteArrayInputStreamwith a minmalist byte arrayDataByteArrayInputStream(byte[] buf)Creates aStoreByteArrayInputStream.DataByteArrayInputStream(Buffer buffer)Creates aStoreByteArrayInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()intgetLength()intgetPos()byte[]getRawData()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.booleanreadBoolean()BufferreadBuffer(int len)bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()java.lang.StringreadLine()longreadLong()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()java.lang.StringreadUTF()intreadVarInt()longreadVarLong()intreadVarSignedInt()longreadVarSignedLong()voidrestart()voidrestart(byte[] newBuff)reset theStoreByteArrayInputStreamto use an new byte arrayvoidrestart(int size)re-start the input stream - reusing the current buffervoidrestart(Buffer buffer)reset theStoreByteArrayInputStreamto use an new BuffervoidsetLength(int length)voidsetPos(int pos)intsize()intskip(int n)intskipBytes(int n)
-
-
-
Field Detail
-
buf
private byte[] buf
-
pos
private int pos
-
offset
private int offset
-
length
private int length
-
helper
protected AbstractVarIntSupport helper
-
-
Constructor Detail
-
DataByteArrayInputStream
public DataByteArrayInputStream(byte[] buf)
Creates aStoreByteArrayInputStream.- Parameters:
buf- the input buffer.
-
DataByteArrayInputStream
public DataByteArrayInputStream(Buffer buffer)
Creates aStoreByteArrayInputStream.- Parameters:
buffer- the input buffer.
-
DataByteArrayInputStream
public DataByteArrayInputStream()
CreatesWireByteArrayInputStreamwith a minmalist byte array
-
-
Method Detail
-
restart
public void restart(Buffer buffer)
reset theStoreByteArrayInputStreamto use an new Buffer- Parameters:
buffer-
-
restart
public void restart(int size)
re-start the input stream - reusing the current buffer- Parameters:
size-
-
size
public int size()
- Returns:
- the size
-
getRawData
public byte[] getRawData()
- Returns:
- the underlying data array
-
readBuffer
public Buffer readBuffer(int len)
-
restart
public void restart(byte[] newBuff)
reset theStoreByteArrayInputStreamto use an new byte array- Parameters:
newBuff-
-
restart
public void restart()
-
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 classjava.io.InputStream- 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 classjava.io.InputStream- 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 classjava.io.InputStream- Returns:
- the number of bytes that can be read from the input stream without blocking.
-
readFully
public void readFully(byte[] b)
- Specified by:
readFullyin interfacejava.io.DataInput
-
readFully
public void readFully(byte[] b, int off, int len)- Specified by:
readFullyin interfacejava.io.DataInput
-
skip
public int skip(int n)
-
skipBytes
public int skipBytes(int n)
- Specified by:
skipBytesin interfacejava.io.DataInput
-
readBoolean
public boolean readBoolean()
- Specified by:
readBooleanin interfacejava.io.DataInput
-
readByte
public byte readByte()
- Specified by:
readBytein interfacejava.io.DataInput
-
readUnsignedByte
public int readUnsignedByte()
- Specified by:
readUnsignedBytein interfacejava.io.DataInput
-
readShort
public short readShort()
- Specified by:
readShortin interfacejava.io.DataInput
-
readUnsignedShort
public int readUnsignedShort()
- Specified by:
readUnsignedShortin interfacejava.io.DataInput
-
readChar
public char readChar()
- Specified by:
readCharin interfacejava.io.DataInput
-
readInt
public int readInt()
- Specified by:
readIntin interfacejava.io.DataInput
-
readLong
public long readLong()
- Specified by:
readLongin interfacejava.io.DataInput
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine()
- Specified by:
readLinein interfacejava.io.DataInput
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Throws:
java.io.IOException
-
getPos
public int getPos()
-
setPos
public void setPos(int pos)
-
getLength
public int getLength()
-
setLength
public void setLength(int length)
-
readVarInt
public int readVarInt() throws java.io.IOException- Throws:
java.io.IOException
-
readVarLong
public long readVarLong() throws java.io.IOException- Throws:
java.io.IOException
-
readVarSignedInt
public int readVarSignedInt() throws java.io.IOException- Throws:
java.io.IOException
-
readVarSignedLong
public long readVarSignedLong() throws java.io.IOException- Throws:
java.io.IOException
-
-