Class Buffer
java.lang.Object
org.apache.jackrabbit.oak.commons.Buffer
This is a wrapper around
ByteBuffer. It maintains the same semantics
and mechanisms of the ByteBuffer.
Java 9 introduced API changes to some methods in ByteBuffer. Instead
of returning instances of Buffer, those methods were
rewritten to return instances of ByteBuffer instead. While this is
perfectly fine at compile time, running "modern" code on Java 8 and earlier
throws NoSuchMethodError. In order to prevent occurrences of this
exceptions in the future, Buffer is used consistently in place of
ByteBuffer. Since it is not possible to directly convert a Buffer into a ByteBuffer and the other way around, Buffer
makes it less likely to develop dangerous code in the future.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Bufferallocate(int cap) static BufferallocateDirect(int cap) byte[]array()intcapacity()booleanflip()byteget()get(byte[] b) get(byte[] b, int pos, int len) byteget(int pos) intgetInt()intgetInt(int pos) longgetLong()longgetLong(int pos) shortgetShort()shortgetShort(int pos) inthashCode()booleanbooleanisDirect()intlimit()limit(int lim) static Buffermap(FileChannel channel, FileChannel.MapMode mode, long position, long size) mark()intposition()position(int pos) put(byte b) put(byte[] b) put(byte[] buf, int pos, int len) putInt(int i) putLong(long l) intreadFully(FileChannel channel, int position) intreset()rewind()slice()voidstatic Bufferwrap(byte[] buffer) static Bufferwrap(byte[] buffer, int pos, int len) intwrite(WritableByteChannel channel)
-
Method Details
-
map
public static Buffer map(FileChannel channel, FileChannel.MapMode mode, long position, long size) throws IOException - Throws:
IOException
-
wrap
-
wrap
-
allocate
-
allocateDirect
-
remaining
public int remaining() -
asReadOnlyBuffer
-
position
-
position
public int position() -
limit
-
limit
public int limit() -
slice
-
readFully
- Throws:
IOException
-
flip
-
getInt
public int getInt() -
getInt
public int getInt(int pos) -
mark
-
get
-
get
-
get
public byte get(int pos) -
get
public byte get() -
reset
-
update
-
array
public byte[] array() -
capacity
public int capacity() -
isDirect
public boolean isDirect() -
put
-
put
-
put
-
put
-
rewind
-
getLong
public long getLong(int pos) -
getLong
public long getLong() -
getShort
public short getShort(int pos) -
getShort
public short getShort() -
duplicate
-
decode
-
hasRemaining
public boolean hasRemaining() -
write
- Throws:
IOException
-
putInt
-
putLong
-
hashCode
public int hashCode() -
equals
-