Class Buffer
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.Buffer
-
public final class Buffer extends java.lang.Object
This is a wrapper aroundByteBuffer
. It maintains the same semantics and mechanisms of theByteBuffer
.Java 9 introduced API changes to some methods in
ByteBuffer
. Instead of returning instances ofBuffer
, those methods were rewritten to return instances ofByteBuffer
instead. While this is perfectly fine at compile time, running "modern" code on Java 8 and earlier throwsNoSuchMethodError
. In order to prevent occurrences of this exceptions in the future,Buffer
is used consistently in place ofByteBuffer
. Since it is not possible to directly convert aBuffer
into aByteBuffer
and the other way around,Buffer
makes it less likely to develop dangerous code in the future.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Buffer
allocate(int cap)
static Buffer
allocateDirect(int cap)
byte[]
array()
Buffer
asReadOnlyBuffer()
int
capacity()
java.nio.CharBuffer
decode(java.nio.charset.Charset charset)
Buffer
duplicate()
boolean
equals(java.lang.Object obj)
Buffer
flip()
byte
get()
Buffer
get(byte[] b)
Buffer
get(byte[] b, int pos, int len)
byte
get(int pos)
int
getInt()
int
getInt(int pos)
long
getLong()
long
getLong(int pos)
short
getShort(int pos)
int
hashCode()
boolean
hasRemaining()
boolean
isDirect()
int
limit()
Buffer
limit(int lim)
static Buffer
map(java.nio.channels.FileChannel channel, java.nio.channels.FileChannel.MapMode mode, long position, long size)
Buffer
mark()
int
position()
Buffer
position(int pos)
Buffer
put(byte b)
Buffer
put(byte[] b)
Buffer
put(byte[] buf, int pos, int len)
Buffer
put(Buffer b)
Buffer
putInt(int i)
Buffer
putLong(long l)
int
readFully(java.nio.channels.FileChannel channel, int position)
int
remaining()
Buffer
reset()
Buffer
rewind()
Buffer
slice()
void
update(java.util.zip.CRC32 checksum)
static Buffer
wrap(byte[] buffer)
static Buffer
wrap(byte[] buffer, int pos, int len)
int
write(java.nio.channels.WritableByteChannel channel)
-
-
-
Method Detail
-
map
public static Buffer map(java.nio.channels.FileChannel channel, java.nio.channels.FileChannel.MapMode mode, long position, long size) throws java.io.IOException
- Throws:
java.io.IOException
-
wrap
public static Buffer wrap(byte[] buffer)
-
wrap
public static Buffer wrap(byte[] buffer, int pos, int len)
-
allocate
public static Buffer allocate(int cap)
-
allocateDirect
public static Buffer allocateDirect(int cap)
-
remaining
public int remaining()
-
asReadOnlyBuffer
public Buffer asReadOnlyBuffer()
-
position
public Buffer position(int pos)
-
position
public int position()
-
limit
public Buffer limit(int lim)
-
limit
public int limit()
-
slice
public Buffer slice()
-
readFully
public int readFully(java.nio.channels.FileChannel channel, int position) throws java.io.IOException
- Throws:
java.io.IOException
-
flip
public Buffer flip()
-
getInt
public int getInt()
-
getInt
public int getInt(int pos)
-
mark
public Buffer mark()
-
get
public Buffer get(byte[] b)
-
get
public Buffer get(byte[] b, int pos, int len)
-
get
public byte get(int pos)
-
get
public byte get()
-
reset
public Buffer reset()
-
update
public void update(java.util.zip.CRC32 checksum)
-
array
public byte[] array()
-
capacity
public int capacity()
-
isDirect
public boolean isDirect()
-
put
public Buffer put(byte[] b)
-
put
public Buffer put(byte[] buf, int pos, int len)
-
put
public Buffer put(byte b)
-
rewind
public Buffer rewind()
-
getLong
public long getLong(int pos)
-
getLong
public long getLong()
-
getShort
public short getShort(int pos)
-
duplicate
public Buffer duplicate()
-
decode
public java.nio.CharBuffer decode(java.nio.charset.Charset charset)
-
hasRemaining
public boolean hasRemaining()
-
write
public int write(java.nio.channels.WritableByteChannel channel) throws java.io.IOException
- Throws:
java.io.IOException
-
putInt
public Buffer putInt(int i)
-
putLong
public Buffer putLong(long l)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-