Class Buffer
- java.lang.Object
 - 
- org.apache.jackrabbit.oak.commons.Buffer
 
 
- 
public final class Buffer extends java.lang.ObjectThis 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 ofByteBufferinstead. 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,Bufferis used consistently in place ofByteBuffer. Since it is not possible to directly convert aBufferinto aByteBufferand the other way around,Buffermakes 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 Bufferallocate(int cap)static BufferallocateDirect(int cap)byte[]array()BufferasReadOnlyBuffer()intcapacity()java.nio.CharBufferdecode(java.nio.charset.Charset charset)Bufferduplicate()booleanequals(java.lang.Object obj)Bufferflip()byteget()Bufferget(byte[] b)Bufferget(byte[] b, int pos, int len)byteget(int pos)intgetInt()intgetInt(int pos)longgetLong()longgetLong(int pos)shortgetShort(int pos)inthashCode()booleanhasRemaining()booleanisDirect()intlimit()Bufferlimit(int lim)static Buffermap(java.nio.channels.FileChannel channel, java.nio.channels.FileChannel.MapMode mode, long position, long size)Buffermark()intposition()Bufferposition(int pos)Bufferput(byte b)Bufferput(byte[] b)Bufferput(byte[] buf, int pos, int len)Bufferput(Buffer b)BufferputInt(int i)BufferputLong(long l)intreadFully(java.nio.channels.FileChannel channel, int position)intremaining()Bufferreset()Bufferrewind()Bufferslice()voidupdate(java.util.zip.CRC32 checksum)static Bufferwrap(byte[] buffer)static Bufferwrap(byte[] buffer, int pos, int len)intwrite(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:
 hashCodein classjava.lang.Object
 
- 
equals
public boolean equals(java.lang.Object obj)
- Overrides:
 equalsin classjava.lang.Object
 
 - 
 
 -