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 class
ByteBufferImpl.Externalizer
-
Field Summary
Fields Modifier and Type Field Description static ByteBufferImpl
EMPTY_INSTANCE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufferImpl
copy()
Returns a new byte[] instance of sizeByteBuffer.getLength()
that contains all the bytes owned by this buffer.static ByteBufferImpl
create(byte[] array)
static ByteBufferImpl
create(byte[] array, int offset, int length)
boolean
equals(Object o)
byte[]
getBuf()
Returns the underlying buffer.int
getLength()
Length bytes, starting from offset, within the underlying byte[] (as returned byByteBuffer.getBuf()
are owned by this buffer instance.int
getOffset()
Returns the offset within the underlying byte[] (as returned byByteBuffer.getBuf()
owned by this buffer instance.InputStream
getStream()
int
hashCode()
ByteBuffer
toJDKByteBuffer()
String
toString()
-
-
-
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:ByteBuffer
Returns the underlying buffer.- Specified by:
getBuf
in interfaceByteBuffer
-
getOffset
public int getOffset()
Description copied from interface:ByteBuffer
Returns the offset within the underlying byte[] (as returned byByteBuffer.getBuf()
owned by this buffer instance.- Specified by:
getOffset
in interfaceByteBuffer
-
getLength
public int getLength()
Description copied from interface:ByteBuffer
Length bytes, starting from offset, within the underlying byte[] (as returned byByteBuffer.getBuf()
are owned by this buffer instance.- Specified by:
getLength
in interfaceByteBuffer
-
copy
public ByteBufferImpl copy()
Description copied from interface:ByteBuffer
Returns a new byte[] instance of sizeByteBuffer.getLength()
that contains all the bytes owned by this buffer.- Specified by:
copy
in 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()
-
-