Package org.infinispan.commons.io
Interface ByteBuffer
-
- All Known Implementing Classes:
ByteBufferImpl
public interface ByteBuffer
A byte buffer that exposes the internal byte array with minimal copying. To be instantiated withByteBufferFactory
.- Since:
- 6.0
- Author:
- Mircea Markus
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ByteBuffer
copy()
Returns a new byte[] instance of sizegetLength()
that contains all the bytes owned by this buffer.byte[]
getBuf()
Returns the underlying buffer.int
getLength()
Length bytes, starting from offset, within the underlying byte[] (as returned bygetBuf()
are owned by this buffer instance.int
getOffset()
Returns the offset within the underlying byte[] (as returned bygetBuf()
owned by this buffer instance.default InputStream
getStream()
default byte[]
trim()
Returns a trimmed byte array.
-
-
-
Method Detail
-
getBuf
byte[] getBuf()
Returns the underlying buffer.
-
getOffset
int getOffset()
Returns the offset within the underlying byte[] (as returned bygetBuf()
owned by this buffer instance.
-
getLength
int getLength()
Length bytes, starting from offset, within the underlying byte[] (as returned bygetBuf()
are owned by this buffer instance.
-
copy
ByteBuffer copy()
Returns a new byte[] instance of sizegetLength()
that contains all the bytes owned by this buffer.
-
trim
default byte[] trim()
Returns a trimmed byte array.The returned byte array should not be modified. A copy is not guaranteed.
It does not copy the byte array if
getOffset()
is zero andgetLength()
is equals to the underlying byte array length.- Returns:
- A trimmed byte array.
-
getStream
default InputStream getStream()
- Returns:
- An
InputStream
for the content of thisByteBuffer
.
-
-