Package db
Interface Buffer
-
- All Known Implementing Classes:
ChainedBuffer,DataBuffer
public interface BufferBufferprovides a general purpose storage buffer interface providing various data access methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidget(int offset, byte[] bytes)Get the byte data located at the specified offset and store into the bytes array provided.voidget(int offset, byte[] data, int dataOffset, int length)Get the byte data located at the specified offset and store into the data array at the specified data offset.byte[]get(int offset, int length)Get the byte data located at the specified offset.bytegetByte(int offset)Get the 8-bit byte value located at the specified offset.intgetId()Get the buffer ID for this buffer.intgetInt(int offset)Get the 32-bit integer value located at the specified offset.longgetLong(int offset)Get the 64-bit long value located at the specified offset.shortgetShort(int offset)Get the 16-bit short value located at the specified offset.intlength()Get the length of the buffer in bytes.intput(int offset, byte[] bytes)Put the bytes provided into the buffer at the specified offset.intput(int offset, byte[] data, int dataOffset, int length)Put a specified number of bytes from the array provided into the buffer at the specified offset.intputByte(int offset, byte b)Put the 8-bit byte value into the buffer at the specified offset.intputInt(int offset, int v)Put the 32-bit integer value into the buffer at the specified offset.intputLong(int offset, long v)Put the 64-bit long value into the buffer at the specified offset.intputShort(int offset, short v)Put the 16-bit short value into the buffer at the specified offset.
-
-
-
Method Detail
-
getId
int getId()
Get the buffer ID for this buffer.- Returns:
- int
-
length
int length()
Get the length of the buffer in bytes. The length reflects the number of bytes which have been allocated to the buffer.- Returns:
- length of allocated buffer.
-
get
void get(int offset, byte[] bytes) throws java.io.IOExceptionGet the byte data located at the specified offset and store into the bytes array provided.- Parameters:
offset- byte offset from start of buffer.bytes- byte array to store data- Throws:
java.lang.ArrayIndexOutOfBoundsException- is thrown if an invalid offset is specified.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
get
void get(int offset, byte[] data, int dataOffset, int length) throws java.io.IOExceptionGet the byte data located at the specified offset and store into the data array at the specified data offset.- Parameters:
offset- byte offset from the start of the buffer.data- byte array to store the data.dataOffset- offset into the data bufferlength- amount of data to read- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset, dataOffset, or length is specified.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
get
byte[] get(int offset, int length) throws java.io.IOExceptionGet the byte data located at the specified offset.- Parameters:
offset- byte offset from start of buffer.- Returns:
- the byte array.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the data.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
getByte
byte getByte(int offset) throws java.io.IOExceptionGet the 8-bit byte value located at the specified offset.- Parameters:
offset- byte offset from start of buffer.- Returns:
- the byte value at the specified offset.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- is thrown if an invalid offset is specified.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
getInt
int getInt(int offset) throws java.io.IOExceptionGet the 32-bit integer value located at the specified offset.- Parameters:
offset- byte offset from start of buffer.- Returns:
- the integer value at the specified offset.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the value.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
getShort
short getShort(int offset) throws java.io.IOExceptionGet the 16-bit short value located at the specified offset.- Parameters:
offset- byte offset from start of buffer.- Returns:
- the short value at the specified offset.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the value.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
getLong
long getLong(int offset) throws java.io.IOExceptionGet the 64-bit long value located at the specified offset.- Parameters:
offset- byte offset from start of buffer.- Returns:
- the long value at the specified offset.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the value.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
put
int put(int offset, byte[] data, int dataOffset, int length) throws java.io.IOExceptionPut a specified number of bytes from the array provided into the buffer at the specified offset. The number of bytes stored is specified by the length specified.- Parameters:
offset- byte offset from start of buffer.data- the byte data to be stored.dataOffset- the starting offset into the data.length- the number of bytes to be stored.- Returns:
- the next available offset into the buffer, or -1 if the buffer is full.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset is provided or the end of buffer was encountered while storing the data.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
put
int put(int offset, byte[] bytes) throws java.io.IOExceptionPut the bytes provided into the buffer at the specified offset. The number of bytes stored is determined by the length of the bytes array.- Parameters:
offset- byte offset from start of buffer.bytes- the byte data to be stored.- Returns:
- the next available offset into the buffer, or -1 if the buffer is full.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset is provided or the end of buffer was encountered while storing the data.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
putByte
int putByte(int offset, byte b) throws java.io.IOExceptionPut the 8-bit byte value into the buffer at the specified offset.- Parameters:
offset- byte offset from start of buffer.b- the byte value to be stored.- Returns:
- the next available offset into the buffer, or -1 if the buffer is full.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset is provided.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
putInt
int putInt(int offset, int v) throws java.io.IOExceptionPut the 32-bit integer value into the buffer at the specified offset.- Parameters:
offset- byte offset from start of buffer.v- the integer value to be stored.- Returns:
- the next available offset into the buffer, or -1 if the buffer is full.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset is provided or the end of buffer was encountered while storing the data.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
putShort
int putShort(int offset, short v) throws java.io.IOExceptionPut the 16-bit short value into the buffer at the specified offset.- Parameters:
offset- byte offset from start of buffer.v- the short value to be stored.- Returns:
- the next available offset into the buffer, or -1 if the buffer is full.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset is provided or the end of buffer was encountered while storing the data.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
putLong
int putLong(int offset, long v) throws java.io.IOExceptionPut the 64-bit long value into the buffer at the specified offset.- Parameters:
offset- byte offset from start of buffer.v- the long value to be stored.- Returns:
- the next available offset into the buffer, or -1 if the buffer is full.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if an invalid offset is provided or the end of buffer was encountered while storing the data.java.io.IOException- is thrown if an error occurs while accessing the underlying storage.
-
-