Package org.infinispan.commons.io
Class ByteBufferImpl
- java.lang.Object
-
- org.infinispan.commons.io.ByteBufferImpl
-
- All Implemented Interfaces:
ByteBuffer
public class ByteBufferImpl extends Object implements ByteBuffer
A byte buffer that exposes the internal byte array with minimal copying- Since:
- 4.0
- Author:
- (various)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classByteBufferImpl.Externalizer
-
Field Summary
Fields Modifier and Type Field Description static ByteBufferImplEMPTY_INSTANCE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufferImplcopy()Returns a new byte[] instance of sizeByteBuffer.getLength()that contains all the bytes owned by this buffer.static ByteBufferImplcreate(byte[] array)static ByteBufferImplcreate(byte[] array, int offset, int length)booleanequals(Object o)byte[]getBuf()Returns the underlying buffer.intgetLength()Length bytes, starting from offset, within the underlying byte[] (as returned byByteBuffer.getBuf()are owned by this buffer instance.intgetOffset()Returns the offset within the underlying byte[] (as returned byByteBuffer.getBuf()owned by this buffer instance.InputStreamgetStream()inthashCode()ByteBuffertoJDKByteBuffer()StringtoString()
-
-
-
Field Detail
-
EMPTY_INSTANCE
public static final ByteBufferImpl EMPTY_INSTANCE
-
-
Method Detail
-
create
public static ByteBufferImpl create(byte[] array)
-
create
public static ByteBufferImpl create(byte[] array, int offset, int length)
-
getBuf
public byte[] getBuf()
Description copied from interface:ByteBufferReturns the underlying buffer.- Specified by:
getBufin interfaceByteBuffer
-
getOffset
public int getOffset()
Description copied from interface:ByteBufferReturns the offset within the underlying byte[] (as returned byByteBuffer.getBuf()owned by this buffer instance.- Specified by:
getOffsetin interfaceByteBuffer
-
getLength
public int getLength()
Description copied from interface:ByteBufferLength bytes, starting from offset, within the underlying byte[] (as returned byByteBuffer.getBuf()are owned by this buffer instance.- Specified by:
getLengthin interfaceByteBuffer
-
copy
public ByteBufferImpl copy()
Description copied from interface:ByteBufferReturns a new byte[] instance of sizeByteBuffer.getLength()that contains all the bytes owned by this buffer.- Specified by:
copyin interfaceByteBuffer
-
toString
public String toString()
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
getStream
public InputStream getStream()
- Returns:
- an input stream for the bytes in the buffer
-
toJDKByteBuffer
public ByteBuffer toJDKByteBuffer()
-
-