public final class BasicSliceInput extends FixedLengthSliceInput
| Constructor and Description |
|---|
BasicSliceInput(Slice slice) |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of bytes that can be read without blocking.
|
boolean |
isReadable()
Returns
true
if and only if available() is greater
than 0. |
long |
length()
Gets the total size of this input stream.
|
long |
position()
Returns the
position of this buffer. |
int |
read() |
int |
read(byte[] destination,
int destinationIndex,
int length) |
boolean |
readBoolean()
Returns true if the byte at the current
position is not 0 and increases
the position by 1 in this buffer. |
byte |
readByte()
Gets a byte at the current
position and increases
the position by 1 in this buffer. |
void |
readBytes(byte[] destination,
int destinationIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
position and increases the position
by the number of the transferred bytes (= length). |
void |
readBytes(OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
position. |
void |
readBytes(Slice destination,
int destinationIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
position and increases the position
by the number of the transferred bytes (= length). |
double |
readDouble()
Gets a 64-bit double at the current
position
and increases the position by 8 in this buffer. |
float |
readFloat()
Gets a 32-bit float at the current
position
and increases the position by 4 in this buffer. |
int |
readInt()
Gets a 32-bit integer at the current
position
and increases the position by 4 in this buffer. |
long |
readLong()
Gets a 64-bit long at the current
position
and increases the position by 8 in this buffer. |
short |
readShort()
Gets a 16-bit short integer at the current
position
and increases the position by 2 in this buffer. |
Slice |
readSlice(int length)
Returns a new slice of this buffer's sub-region starting at the current
position and increases the position by the size
of the new slice (= length). |
int |
readUnsignedByte()
Gets an unsigned byte at the current
position and increases
the position by 1 in this buffer. |
int |
readUnsignedShort()
Gets an unsigned 16-bit short integer at the current
position
and increases the position by 2 in this buffer. |
void |
setPosition(long position)
Sets the
position of this buffer. |
long |
skip(long length) |
int |
skipBytes(int length) |
Slice |
slice()
Returns a slice of this buffer's readable bytes.
|
String |
toString() |
String |
toString(Charset charset)
Decodes this buffer's readable bytes into a string with the specified
character set name.
|
remainingclose, mark, markSupported, read, readBytes, readBytes, readBytes, readChar, readFully, readFully, readLine, readUnsignedInt, readUTF, resetpublic BasicSliceInput(Slice slice)
public long length()
FixedLengthSliceInputlength in class FixedLengthSliceInputpublic long position()
SliceInputposition of this buffer.position in class SliceInputpublic void setPosition(long position)
SliceInputposition of this buffer.setPosition in class SliceInputpublic boolean isReadable()
SliceInputtrue
if and only if available() is greater
than 0.isReadable in class SliceInputpublic int available()
SliceInputavailable in class SliceInputpublic boolean readBoolean()
SliceInputposition is not 0 and increases
the position by 1 in this buffer.readBoolean in interface DataInputreadBoolean in class SliceInputpublic int read()
read in class SliceInputpublic byte readByte()
SliceInputposition and increases
the position by 1 in this buffer.readByte in interface DataInputreadByte in class SliceInputpublic int readUnsignedByte()
SliceInputposition and increases
the position by 1 in this buffer.readUnsignedByte in interface DataInputreadUnsignedByte in class SliceInputpublic short readShort()
SliceInputposition
and increases the position by 2 in this buffer.readShort in interface DataInputreadShort in class SliceInputpublic int readUnsignedShort()
SliceInputposition
and increases the position by 2 in this buffer.readUnsignedShort in interface DataInputreadUnsignedShort in class SliceInputpublic int readInt()
SliceInputposition
and increases the position by 4 in this buffer.readInt in interface DataInputreadInt in class SliceInputpublic long readLong()
SliceInputposition
and increases the position by 8 in this buffer.readLong in interface DataInputreadLong in class SliceInputpublic float readFloat()
SliceInputposition
and increases the position by 4 in this buffer.readFloat in interface DataInputreadFloat in class SliceInputpublic double readDouble()
SliceInputposition
and increases the position by 8 in this buffer.readDouble in interface DataInputreadDouble in class SliceInputpublic Slice readSlice(int length)
SliceInputposition and increases the position by the size
of the new slice (= length).readSlice in class SliceInputlength - the size of the new slicepublic int read(byte[] destination,
int destinationIndex,
int length)
read in class SliceInputpublic void readBytes(byte[] destination,
int destinationIndex,
int length)
SliceInputposition and increases the position
by the number of the transferred bytes (= length).readBytes in class SliceInputdestinationIndex - the first index of the destinationlength - the number of bytes to transferpublic void readBytes(Slice destination, int destinationIndex, int length)
SliceInputposition and increases the position
by the number of the transferred bytes (= length).readBytes in class SliceInputdestinationIndex - the first index of the destinationlength - the number of bytes to transferpublic void readBytes(OutputStream out, int length) throws IOException
SliceInputposition.readBytes in class SliceInputlength - the number of bytes to transferIOException - if the specified stream threw an exception during I/Opublic long skip(long length)
skip in class SliceInputpublic int skipBytes(int length)
skipBytes in interface DataInputskipBytes in class SliceInputpublic Slice slice()
buf.slice(buf.position(), buf.available()()).
This method does not modify position or writerIndex of
this buffer.public String toString(Charset charset)
buf.toString(buf.position(), buf.available()(), charsetName).
This method does not modify position or writerIndex of
this buffer.Copyright © 2012–2018. All rights reserved.