public class DynamicSliceOutput extends SliceOutput
Constructor and Description |
---|
DynamicSliceOutput(int estimatedSize) |
Modifier and Type | Method and Description |
---|---|
boolean |
isWritable()
Returns
true
if and only if (this.capacity - this.writerIndex) is greater
than 0 . |
void |
reset()
Resets this stream to the initial position.
|
int |
size()
Returns the
writerIndex of this buffer. |
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.
|
int |
writableBytes()
Returns the number of writable bytes which is equal to
(this.capacity - this.writerIndex) . |
void |
writeByte(int value)
Sets the specified byte at the current
writerIndex
and increases the writerIndex by 1 in this buffer. |
void |
writeBytes(byte[] source)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= source.length ). |
void |
writeBytes(byte[] source,
int sourceIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
void |
writeBytes(ByteBuffer source)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer's position
reaches its limit, and increases the writerIndex by the
number of the transferred bytes. |
int |
writeBytes(FileChannel in,
int position,
int length) |
int |
writeBytes(InputStream in,
int length)
Transfers the content of the specified stream to this buffer
starting at the current
writerIndex and increases the
writerIndex by the number of the transferred bytes. |
int |
writeBytes(ScatteringByteChannel in,
int length)
Transfers the content of the specified channel to this buffer
starting at the current
writerIndex and increases the
writerIndex by the number of the transferred bytes. |
void |
writeBytes(Slice source)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex until the source buffer becomes
unreadable, and increases the writerIndex by the number of
the transferred bytes. |
void |
writeBytes(SliceInput source,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
void |
writeBytes(Slice source,
int sourceIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the current
writerIndex and increases the writerIndex
by the number of the transferred bytes (= length ). |
void |
writeInt(int value)
Sets the specified 32-bit integer at the current
writerIndex
and increases the writerIndex by 4 in this buffer. |
void |
writeLong(long value)
Sets the specified 64-bit long integer at the current
writerIndex and increases the writerIndex by 8
in this buffer. |
void |
writeShort(int value)
Sets the specified 16-bit short integer at the current
writerIndex and increases the writerIndex by 2
in this buffer. |
void |
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the current
writerIndex and increases the writerIndex by the
specified length . |
write, write, write, writeBoolean, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeUTF
close, flush
public void reset()
SliceOutput
reset
in class SliceOutput
public int size()
SliceOutput
writerIndex
of this buffer.size
in class SliceOutput
public boolean isWritable()
SliceOutput
true
if and only if (this.capacity - this.writerIndex)
is greater
than 0
.isWritable
in class SliceOutput
public int writableBytes()
SliceOutput
(this.capacity - this.writerIndex)
.writableBytes
in class SliceOutput
public void writeByte(int value)
SliceOutput
writerIndex
and increases the writerIndex
by 1
in this buffer.
The 24 high-order bits of the specified value are ignored.writeByte
in interface DataOutput
writeByte
in class SliceOutput
public void writeShort(int value)
SliceOutput
writerIndex
and increases the writerIndex
by 2
in this buffer. The 16 high-order bits of the specified value are ignored.writeShort
in interface DataOutput
writeShort
in class SliceOutput
public void writeInt(int value)
SliceOutput
writerIndex
and increases the writerIndex
by 4
in this buffer.writeInt
in interface DataOutput
writeInt
in class SliceOutput
public void writeLong(long value)
SliceOutput
writerIndex
and increases the writerIndex
by 8
in this buffer.writeLong
in interface DataOutput
writeLong
in class SliceOutput
public void writeBytes(byte[] source)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= source.length
).writeBytes
in class SliceOutput
public void writeBytes(byte[] source, int sourceIndex, int length)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
).writeBytes
in class SliceOutput
sourceIndex
- the first index of the sourcelength
- the number of bytes to transferpublic void writeBytes(Slice source)
SliceOutput
writerIndex
until the source buffer becomes
unreadable, and increases the writerIndex
by the number of
the transferred bytes. This method is basically same with
SliceOutput.writeBytes(Slice, int, int)
, except that this method
increases the readerIndex
of the source buffer by the number of
the transferred bytes while SliceOutput.writeBytes(Slice, int, int)
does not.writeBytes
in class SliceOutput
public void writeBytes(SliceInput source, int length)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
). This method
is basically same with SliceOutput.writeBytes(Slice, int, int)
,
except that this method increases the readerIndex
of the source
buffer by the number of the transferred bytes (= length
) while
SliceOutput.writeBytes(Slice, int, int)
does not.writeBytes
in class SliceOutput
length
- the number of bytes to transferpublic void writeBytes(Slice source, int sourceIndex, int length)
SliceOutput
writerIndex
and increases the writerIndex
by the number of the transferred bytes (= length
).writeBytes
in class SliceOutput
sourceIndex
- the first index of the sourcelength
- the number of bytes to transferpublic void writeBytes(ByteBuffer source)
SliceOutput
writerIndex
until the source buffer's position
reaches its limit, and increases the writerIndex
by the
number of the transferred bytes.writeBytes
in class SliceOutput
public int writeBytes(InputStream in, int length) throws IOException
SliceOutput
writerIndex
and increases the
writerIndex
by the number of the transferred bytes.writeBytes
in class SliceOutput
length
- the number of bytes to transferIOException
- if the specified stream threw an exception during I/Opublic int writeBytes(ScatteringByteChannel in, int length) throws IOException
SliceOutput
writerIndex
and increases the
writerIndex
by the number of the transferred bytes.writeBytes
in class SliceOutput
length
- the maximum number of bytes to transferIOException
- if the specified channel threw an exception during I/Opublic int writeBytes(FileChannel in, int position, int length) throws IOException
writeBytes
in class SliceOutput
IOException
public void writeZero(int length)
SliceOutput
writerIndex
and increases the writerIndex
by the
specified length
.writeZero
in class SliceOutput
length
- the number of NULs to write to the bufferpublic Slice slice()
SliceOutput
buf.slice(buf.readerIndex(), buf.readableBytes())
.
This method does not modify readerIndex
or writerIndex
of
this buffer.slice
in class SliceOutput
public ByteBuffer toByteBuffer()
SliceOutput
buf.toByteBuffer(buf.readerIndex(), buf.readableBytes())
.
This method does not modify readerIndex
or writerIndex
of
this buffer.toByteBuffer
in class SliceOutput
public String toString(Charset charset)
SliceOutput
buf.toString(buf.readerIndex(), buf.readableBytes(), charsetName)
.
This method does not modify readerIndex
or writerIndex
of
this buffer.toString
in class SliceOutput
Copyright © 2011–2019. All rights reserved.