public final class BasicSliceInput extends SliceInput
| Constructor and Description |
|---|
BasicSliceInput(Slice slice) |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of readable bytes which is equal to
(this.slice.length() - this.position). |
boolean |
isReadable()
Returns
true
if and only if available() is greater
than 0. |
int |
position()
Returns the
position of this buffer. |
int |
read() |
boolean |
readBoolean() |
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() |
float |
readFloat() |
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 integer 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() |
void |
setPosition(int position)
Sets the
position of this buffer. |
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.
|
mark, markSupported, readBytes, readBytes, readBytes, readChar, readFully, readFully, readLine, readUnsignedInt, readUTF, resetclose, read, read, skippublic BasicSliceInput(Slice slice)
public int position()
SliceInputposition of this buffer.position in class SliceInputpublic void setPosition(int 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()
SliceInput(this.slice.length() - this.position).available in class SliceInputpublic boolean readBoolean()
throws IOException
IOExceptionpublic 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()
throws IOException
IOExceptionpublic 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()
readFloat in interface DataInputreadFloat in class SliceInputpublic double readDouble()
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 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 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-2014. All Rights Reserved.