public final class SliceInput extends InputStream implements DataInput
| Constructor and Description |
|---|
SliceInput(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. |
byte[] |
readByteArray(int length) |
void |
readBytes(byte[] destination)
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 (= dst.length). |
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(ByteBuffer destination)
Transfers this buffer's data to the specified destination starting at
the current
position until the destination's position
reaches its limit, and increases the position by the
number of the transferred bytes. |
int |
readBytes(GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified stream starting at the
current
position. |
Slice |
readBytes(int length)
Transfers this buffer's data to a newly created buffer 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)
Transfers this buffer's data to the specified destination starting at
the current
position until the destination becomes
non-writable, and increases the position by the number of the
transferred bytes. |
void |
readBytes(Slice destination,
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(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). |
char |
readChar()
Unsupported operation
|
double |
readDouble() |
float |
readFloat()
Unsupported operation
|
void |
readFully(byte[] destination) |
void |
readFully(byte[] destination,
int offset,
int length) |
int |
readInt()
Gets a 32-bit integer at the current
position
and increases the position by 4 in this buffer. |
String |
readLine()
Unsupported operation
|
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. |
long |
readUnsignedInt()
Gets an unsigned 32-bit integer at the current
position
and increases the position by 4 in this buffer. |
int |
readUnsignedShort() |
String |
readUTF()
Unsupported operation
|
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.
|
ByteBuffer |
toByteBuffer()
Converts this buffer's readable bytes into a NIO buffer.
|
String |
toString() |
String |
toString(Charset charset)
Decodes this buffer's readable bytes into a string with the specified
character set name.
|
close, mark, markSupported, read, read, reset, skippublic SliceInput(Slice slice)
public int position()
position of this buffer.public void setPosition(int position)
position of this buffer.IndexOutOfBoundsException - if the specified position is
less than 0 or
greater than this.writerIndexpublic boolean isReadable()
true
if and only if available() is greater
than 0.public int available()
(this.slice.length() - this.position).available in class InputStreampublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic int read()
read in class InputStreampublic byte readByte()
position and increases
the position by 1 in this buffer.readByte in interface DataInputIndexOutOfBoundsException - if this.available() is less than 1public int readUnsignedByte()
position and increases
the position by 1 in this buffer.readUnsignedByte in interface DataInputIndexOutOfBoundsException - if this.available() is less than 1public short readShort()
position
and increases the position by 2 in this buffer.readShort in interface DataInputIndexOutOfBoundsException - if this.available() is less than 2public int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic int readInt()
position
and increases the position by 4 in this buffer.readInt in interface DataInputIndexOutOfBoundsException - if this.available() is less than 4public long readUnsignedInt()
position
and increases the position by 4 in this buffer.IndexOutOfBoundsException - if this.available() is less than 4public long readLong()
position
and increases the position by 8 in this buffer.readLong in interface DataInputIndexOutOfBoundsException - if this.available() is less than 8public byte[] readByteArray(int length)
public Slice readBytes(int length)
position and increases the position
by the number of the transferred bytes (= length).
The returned buffer's position and writerIndex are
0 and length respectively.length - the number of bytes to transferIndexOutOfBoundsException - if length is greater than this.available()public Slice readSlice(int length)
position and increases the position by the size
of the new slice (= length).length - the size of the new sliceIndexOutOfBoundsException - if length is greater than this.available()public void readBytes(byte[] destination)
position and increases the position
by the number of the transferred bytes (= dst.length).IndexOutOfBoundsException - if dst.length is greater than this.available()public void readFully(byte[] destination,
int offset,
int length)
public void readBytes(byte[] destination,
int destinationIndex,
int length)
position and increases the position
by the number of the transferred bytes (= length).destinationIndex - the first index of the destinationlength - the number of bytes to transferIndexOutOfBoundsException - if the specified destinationIndex is less than 0,
if length is greater than this.available(), or
if destinationIndex + length is greater than destination.lengthpublic void readBytes(Slice destination)
position until the destination becomes
non-writable, and increases the position by the number of the
transferred bytes. This method is basically same with
readBytes(Slice, int, int), except that this method
increases the writerIndex of the destination by the number of
the transferred bytes while readBytes(Slice, int, int)
does not.IndexOutOfBoundsException - if destination.writableBytes is greater than
this.available()public void readBytes(Slice destination, int length)
position and increases the position
by the number of the transferred bytes (= length). This method
is basically same with readBytes(Slice, int, int),
except that this method increases the writerIndex of the
destination by the number of the transferred bytes (= length)
while readBytes(Slice, int, int) does not.IndexOutOfBoundsException - if length is greater than this.available() or
if length is greater than destination.writableBytespublic void readBytes(Slice destination, int destinationIndex, int length)
position and increases the position
by the number of the transferred bytes (= length).destinationIndex - the first index of the destinationlength - the number of bytes to transferIndexOutOfBoundsException - if the specified destinationIndex is less than 0,
if length is greater than this.available(), or
if destinationIndex + length is greater than
destination.capacitypublic void readBytes(ByteBuffer destination)
position until the destination's position
reaches its limit, and increases the position by the
number of the transferred bytes.IndexOutOfBoundsException - if destination.remaining() is greater than
this.available()public int readBytes(GatheringByteChannel out, int length) throws IOException
position.length - the maximum number of bytes to transferIndexOutOfBoundsException - if length is greater than this.available()IOException - if the specified channel threw an exception during I/Opublic void readBytes(OutputStream out, int length) throws IOException
position.length - the number of bytes to transferIndexOutOfBoundsException - if length is greater than this.available()IOException - if the specified stream threw an exception during I/Opublic Slice slice()
buf.slice(buf.position(), buf.available()()).
This method does not modify position or writerIndex of
this buffer.public ByteBuffer toByteBuffer()
buf.toByteBuffer(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.UnsupportedCharsetException - if the specified character set name is not supported by the
current VMpublic char readChar()
readChar in interface DataInputUnsupportedOperationException - alwayspublic float readFloat()
readFloat in interface DataInputUnsupportedOperationException - alwayspublic double readDouble()
readDouble in interface DataInputpublic String readLine()
readLine in interface DataInputUnsupportedOperationException - alwayspublic String readUTF()
readUTF in interface DataInputUnsupportedOperationException - alwaysCopyright © 2011–2019. All rights reserved.