类 DataBufferWrapper
- 所有已实现的接口:
DataBuffer
DataBuffer interface
that can be overridden to adapt the delegate.
These methods default to calling through to the wrapped delegate object.
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
-
构造器概要
构造器构造器说明DataBufferWrapper(DataBuffer delegate) Create a newDataBufferWrapperthat wraps the given buffer. -
方法概要
修饰符和类型方法说明已过时。asByteBuffer(int index, int length) 已过时。Expose this buffer's data as anInputStream.asInputStream(boolean releaseOnClose) Expose this buffer's data as anInputStream.Expose this buffer's data as anOutputStream.intcapacity()Return the number of bytes that this buffer can contain.capacity(int capacity) 已过时。Return the wrapped delegate.ensureCapacity(int capacity) 已过时。ensureWritable(int capacity) Ensure that the current buffer has enoughDataBuffer.writableByteCount()to write the amount of data given as an argument.factory()Return theDataBufferFactorythat created this buffer.bytegetByte(int index) Read a single byte at the given index from this data buffer.intindexOf(IntPredicate predicate, int fromIndex) Return the index of the first byte in this buffer that matches the given predicate.intlastIndexOf(IntPredicate predicate, int fromIndex) Return the index of the last byte in this buffer that matches the given predicate.byteread()Read a single byte from the current reading position from this data buffer.read(byte[] destination) Read this buffer's data into the specified destination, starting at the current reading position of this buffer.read(byte[] destination, int offset, int length) Read at mostlengthbytes of this buffer into the specified destination, starting at the current reading position of this buffer.intReturn the number of bytes that can be read from this data buffer.intReturn the position from which this buffer will read.readPosition(int readPosition) Set the position from which this buffer will read.retainedSlice(int index, int length) 已过时。slice(int index, int length) 已过时。split(int index) Splits this data buffer into two at the given index.Returns aByteBufferrepresentation of this data buffer.toByteBuffer(int index, int length) Returns aByteBufferrepresentation of a subsequence of this buffer's bytes.Return a part of this buffer's data as a String using the specified charset.Return this buffer's data a String using the specified charset.intReturn the number of bytes that can be written to this data buffer.write(byte b) Write a single byte into this buffer at the current writing position.write(byte[] source) Write the given source into this buffer, starting at the current writing position of this buffer.write(byte[] source, int offset, int length) Write at mostlengthbytes of the given source into this buffer, starting at the current writing position of this buffer.write(DataBuffer... buffers) Write one or moreDataBuffers to this buffer, starting at the current writing position.write(CharSequence charSequence, Charset charset) Write the givenCharSequenceusing the givenCharset, starting at the current writing position.write(ByteBuffer... buffers) Write one or moreByteBufferto this buffer, starting at the current writing position.intReturn the position to which this buffer will write.writePosition(int writePosition) Set the position to which this buffer will write.
-
构造器详细资料
-
DataBufferWrapper
Create a newDataBufferWrapperthat wraps the given buffer.- 参数:
delegate- the buffer to wrap
-
-
方法详细资料
-
dataBuffer
Return the wrapped delegate. -
factory
从接口复制的说明:DataBufferReturn theDataBufferFactorythat created this buffer.- 指定者:
factory在接口中DataBuffer- 返回:
- the creating buffer factory
-
indexOf
从接口复制的说明:DataBufferReturn the index of the first byte in this buffer that matches the given predicate.- 指定者:
indexOf在接口中DataBuffer- 参数:
predicate- the predicate to matchfromIndex- the index to start the search from- 返回:
- the index of the first byte that matches
predicate; or-1if none match
-
lastIndexOf
从接口复制的说明:DataBufferReturn the index of the last byte in this buffer that matches the given predicate.- 指定者:
lastIndexOf在接口中DataBuffer- 参数:
predicate- the predicate to matchfromIndex- the index to start the search from- 返回:
- the index of the last byte that matches
predicate; or-1if none match
-
readableByteCount
public int readableByteCount()从接口复制的说明:DataBufferReturn the number of bytes that can be read from this data buffer.- 指定者:
readableByteCount在接口中DataBuffer- 返回:
- the readable byte count
-
writableByteCount
public int writableByteCount()从接口复制的说明:DataBufferReturn the number of bytes that can be written to this data buffer.- 指定者:
writableByteCount在接口中DataBuffer- 返回:
- the writable byte count
-
capacity
public int capacity()从接口复制的说明:DataBufferReturn the number of bytes that this buffer can contain.- 指定者:
capacity在接口中DataBuffer- 返回:
- the capacity
-
capacity
已过时。从接口复制的说明:DataBufferSet the number of bytes that this buffer can contain.If the new capacity is lower than the current capacity, the contents of this buffer will be truncated. If the new capacity is higher than the current capacity, it will be expanded.
- 指定者:
capacity在接口中DataBuffer- 参数:
capacity- the new capacity- 返回:
- this buffer
-
ensureCapacity
已过时。从接口复制的说明:DataBufferEnsure that the current buffer has enoughDataBuffer.writableByteCount()to write the amount of data given as an argument. If not, the missing capacity will be added to the buffer.- 指定者:
ensureCapacity在接口中DataBuffer- 参数:
capacity- the writable capacity to check for- 返回:
- this buffer
-
ensureWritable
从接口复制的说明:DataBufferEnsure that the current buffer has enoughDataBuffer.writableByteCount()to write the amount of data given as an argument. If not, the missing capacity will be added to the buffer.- 指定者:
ensureWritable在接口中DataBuffer- 参数:
capacity- the writable capacity to check for- 返回:
- this buffer
-
readPosition
public int readPosition()从接口复制的说明:DataBufferReturn the position from which this buffer will read.- 指定者:
readPosition在接口中DataBuffer- 返回:
- the read position
-
readPosition
从接口复制的说明:DataBufferSet the position from which this buffer will read.- 指定者:
readPosition在接口中DataBuffer- 参数:
readPosition- the new read position- 返回:
- this buffer
-
writePosition
public int writePosition()从接口复制的说明:DataBufferReturn the position to which this buffer will write.- 指定者:
writePosition在接口中DataBuffer- 返回:
- the write position
-
writePosition
从接口复制的说明:DataBufferSet the position to which this buffer will write.- 指定者:
writePosition在接口中DataBuffer- 参数:
writePosition- the new write position- 返回:
- this buffer
-
getByte
public byte getByte(int index) 从接口复制的说明:DataBufferRead a single byte at the given index from this data buffer.- 指定者:
getByte在接口中DataBuffer- 参数:
index- the index at which the byte will be read- 返回:
- the byte at the given index
-
read
public byte read()从接口复制的说明:DataBufferRead a single byte from the current reading position from this data buffer.- 指定者:
read在接口中DataBuffer- 返回:
- the byte at this buffer's current reading position
-
read
从接口复制的说明:DataBufferRead this buffer's data into the specified destination, starting at the current reading position of this buffer.- 指定者:
read在接口中DataBuffer- 参数:
destination- the array into which the bytes are to be written- 返回:
- this buffer
-
read
从接口复制的说明:DataBufferRead at mostlengthbytes of this buffer into the specified destination, starting at the current reading position of this buffer.- 指定者:
read在接口中DataBuffer- 参数:
destination- the array into which the bytes are to be writtenoffset- the index withindestinationof the first byte to be writtenlength- the maximum number of bytes to be written indestination- 返回:
- this buffer
-
write
从接口复制的说明:DataBufferWrite a single byte into this buffer at the current writing position.- 指定者:
write在接口中DataBuffer- 参数:
b- the byte to be written- 返回:
- this buffer
-
write
从接口复制的说明:DataBufferWrite the given source into this buffer, starting at the current writing position of this buffer.- 指定者:
write在接口中DataBuffer- 参数:
source- the bytes to be written into this buffer- 返回:
- this buffer
-
write
从接口复制的说明:DataBufferWrite at mostlengthbytes of the given source into this buffer, starting at the current writing position of this buffer.- 指定者:
write在接口中DataBuffer- 参数:
source- the bytes to be written into this bufferoffset- the index withinsourceto start writing fromlength- the maximum number of bytes to be written fromsource- 返回:
- this buffer
-
write
从接口复制的说明:DataBufferWrite one or moreDataBuffers to this buffer, starting at the current writing position. It is the responsibility of the caller to release the given data buffers.- 指定者:
write在接口中DataBuffer- 参数:
buffers- the byte buffers to write into this buffer- 返回:
- this buffer
-
write
从接口复制的说明:DataBufferWrite one or moreByteBufferto this buffer, starting at the current writing position.- 指定者:
write在接口中DataBuffer- 参数:
buffers- the byte buffers to write into this buffer- 返回:
- this buffer
-
write
从接口复制的说明:DataBufferWrite the givenCharSequenceusing the givenCharset, starting at the current writing position.- 指定者:
write在接口中DataBuffer- 参数:
charSequence- the char sequence to write into this buffercharset- the charset to encode the char sequence with- 返回:
- this buffer
-
slice
已过时。从接口复制的说明:DataBufferCreate a newDataBufferwhose contents is a shared subsequence of this data buffer's content. Data between this data buffer and the returned buffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.Note that this method will not call
DataBufferUtils.retain(DataBuffer)on the resulting slice: the reference count will not be increased.- 指定者:
slice在接口中DataBuffer- 参数:
index- the index at which to start the slicelength- the length of the slice- 返回:
- the specified slice of this data buffer
-
retainedSlice
已过时。从接口复制的说明:DataBufferCreate a newDataBufferwhose contents is a shared, retained subsequence of this data buffer's content. Data between this data buffer and the returned buffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.Note that unlike
DataBuffer.slice(int, int), this method will callDataBufferUtils.retain(DataBuffer)(or equivalent) on the resulting slice.- 指定者:
retainedSlice在接口中DataBuffer- 参数:
index- the index at which to start the slicelength- the length of the slice- 返回:
- the specified, retained slice of this data buffer
-
split
从接口复制的说明:DataBufferSplits this data buffer into two at the given index.Data that precedes the
indexwill be returned in a new buffer, while this buffer will contain data that follows afterindex. Memory between the two buffers is shared, but independent and cannot overlap (unlikeslice).The read and write position of the returned buffer are truncated to fit within the buffers capacity if necessary. The positions of this buffer are set to
0if they are smaller thanindex.- 指定者:
split在接口中DataBuffer- 参数:
index- the index at which it should be split- 返回:
- a new data buffer, containing the bytes from index
0toindex
-
asByteBuffer
已过时。从接口复制的说明:DataBufferExpose this buffer's bytes as aByteBuffer. Data between thisDataBufferand the returnedByteBufferis shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.- 指定者:
asByteBuffer在接口中DataBuffer- 返回:
- this data buffer as a byte buffer
-
asByteBuffer
已过时。从接口复制的说明:DataBufferExpose a subsequence of this buffer's bytes as aByteBuffer. Data between thisDataBufferand the returnedByteBufferis shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.- 指定者:
asByteBuffer在接口中DataBuffer- 参数:
index- the index at which to start the byte bufferlength- the length of the returned byte buffer- 返回:
- this data buffer as a byte buffer
-
toByteBuffer
从接口复制的说明:DataBufferReturns aByteBufferrepresentation of this data buffer. Data between thisDataBufferand the returnedByteBufferis not shared.- 指定者:
toByteBuffer在接口中DataBuffer- 返回:
- this data buffer as a byte buffer
-
toByteBuffer
从接口复制的说明:DataBufferReturns aByteBufferrepresentation of a subsequence of this buffer's bytes. Data between thisDataBufferand the returnedByteBufferis not shared.- 指定者:
toByteBuffer在接口中DataBuffer- 返回:
- this data buffer as a byte buffer
-
asInputStream
从接口复制的说明:DataBufferExpose this buffer's data as anInputStream. Both data and read position are shared between the returned stream and this data buffer. The underlying buffer will not be released when the input stream is closed.- 指定者:
asInputStream在接口中DataBuffer- 返回:
- this data buffer as an input stream
- 另请参阅:
-
asInputStream
从接口复制的说明:DataBufferExpose this buffer's data as anInputStream. Both data and read position are shared between the returned stream and this data buffer.- 指定者:
asInputStream在接口中DataBuffer- 参数:
releaseOnClose- whether the underlying buffer will be released when the input stream is closed.- 返回:
- this data buffer as an input stream
-
asOutputStream
从接口复制的说明:DataBufferExpose this buffer's data as anOutputStream. Both data and write position are shared between the returned stream and this data buffer.- 指定者:
asOutputStream在接口中DataBuffer- 返回:
- this data buffer as an output stream
-
toString
从接口复制的说明:DataBufferReturn this buffer's data a String using the specified charset. Default implementation delegates totoString(readPosition(), readableByteCount(), charset).- 指定者:
toString在接口中DataBuffer- 参数:
charset- the character set to use- 返回:
- a string representation of all this buffers data
-
toString
从接口复制的说明:DataBufferReturn a part of this buffer's data as a String using the specified charset.- 指定者:
toString在接口中DataBuffer- 参数:
index- the index at which to start the stringlength- the number of bytes to use for the stringcharset- the charset to use- 返回:
- a string representation of a part of this buffers data
-