This class represents a byte buffer that contains persistent data of a page.
| Methods |
| static void |
copyString(Reader source, OutputStream target)
Copy a String from a reader to an output stream.
|
| static void |
copyString(Reader source, OutputStream target) throws IOException
Copy a String from a reader to an output stream.
Parameters:
source - the reader
target - the output stream
|
| static Data |
create(DataHandler handler, int capacity)
Create a new buffer for the given handler.
|
| static Data |
create(DataHandler handler, int capacity)
Create a new buffer for the given handler. The
handler will decide what type of buffer is created.
Parameters:
handler - the data handler
capacity - the initial capacity of the buffer
Returns:
the buffer
|
| static Data |
create(DataHandler handler, byte[] buff)
Create a new buffer using the given data for the given handler.
|
| static Data |
create(DataHandler handler, byte[] buff)
Create a new buffer using the given data for the given handler. The
handler will decide what type of buffer is created.
Parameters:
handler - the data handler
buff - the data
Returns:
the buffer
|
| static int |
getStringLen(String s)
Get the length of a String.
|
| static int |
getStringLen(String s)
Get the length of a String. This includes the bytes required to encode
the length.
Parameters:
s - the string
Returns:
the number of bytes required
|
| static int |
getValueLen(Value v, DataHandler handler)
Calculate the number of bytes required to encode the given value.
|
| static int |
getValueLen(Value v, DataHandler handler)
Calculate the number of bytes required to encode the given value.
Parameters:
v - the value
handler - the data handler for lobs
Returns:
the number of bytes required to store this value
|
| static int |
getVarLongLen(long x)
The number of bytes required for a variable size long.
|
| static int |
getVarLongLen(long x)
The number of bytes required for a variable size long.
Parameters:
x - the value
Returns:
the len
|
| void |
checkCapacity(int plus)
Check if there is still enough capacity in the buffer.
|
| void |
checkCapacity(int plus)
Check if there is still enough capacity in the buffer.
This method extends the buffer if required.
Parameters:
plus - the number of additional bytes required
|
| void |
fillAligned()
Fill up the buffer with empty space and an (initially empty) checksum
until the size is a multiple of Constants.FILE_BLOCK_SIZE.
|
| void |
fillAligned()
Fill up the buffer with empty space and an (initially empty) checksum
until the size is a multiple of Constants.FILE_BLOCK_SIZE.
|
| byte[] |
getBytes()
Get the byte array used for this page.
|
| byte[] |
getBytes()
Get the byte array used for this page.
Returns:
the byte array
|
| DataHandler |
getHandler()
|
| DataHandler |
getHandler()
|
| int |
getValueLen(Value v)
Calculate the number of bytes required to encode the given value.
|
| int |
getValueLen(Value v)
Calculate the number of bytes required to encode the given value.
Parameters:
v - the value
Returns:
the number of bytes required to store this value
|
| int |
length()
Get the current write position of this buffer, which is the current
length.
|
| int |
length()
Get the current write position of this buffer, which is the current
length.
Returns:
the length
|
| void |
read(byte[] buff, int off, int len)
Copy a number of bytes to the given buffer from the current position.
|
| void |
read(byte[] buff, int off, int len)
Copy a number of bytes to the given buffer from the current position. The
current position is incremented accordingly.
Parameters:
buff - the output buffer
off - the offset in the output buffer
len - the number of bytes to copy
|
| byte |
readByte()
Read one single byte.
|
| byte |
readByte()
Read one single byte.
Returns:
the value
|
| int |
readInt()
Read an integer at the current position.
|
| int |
readInt()
Read an integer at the current position.
The current position is incremented.
Returns:
the value
|
| long |
readLong()
Read a long value.
|
| long |
readLong()
Read a long value. This method reads two int values and combines them.
Returns:
the long value
|
| short |
readShortInt()
Read an short integer at the current position.
|
| short |
readShortInt()
Read an short integer at the current position.
The current position is incremented.
Returns:
the value
|
| String |
readString()
Read a String value.
|
| String |
readString()
Read a String value.
The current position is incremented.
Returns:
the value
|
| Value |
readValue()
Read a value.
|
| Value |
readValue()
Read a value.
Returns:
the value
|
| int |
readVarInt()
Read a variable size int.
|
| int |
readVarInt()
Read a variable size int.
Returns:
the value
|
| long |
readVarLong()
Read a variable size long.
|
| long |
readVarLong()
Read a variable size long.
Returns:
the value
|
| void |
reset()
Set the position to 0.
|
| void |
reset()
Set the position to 0.
|
| void |
setInt(int pos, int x)
Update an integer at the given position.
|
| void |
setInt(int pos, int x)
Update an integer at the given position.
The current position is not change.
Parameters:
pos - the position
x - the value
|
| void |
setPos(int pos)
Set the current read / write position.
|
| void |
setPos(int pos)
Set the current read / write position.
Parameters:
pos - the new position
|
| void |
truncate(int size)
Shrink the array to this size.
|
| void |
truncate(int size)
Shrink the array to this size.
Parameters:
size - the new size
|
| void |
write(byte[] buff, int off, int len)
Append a number of bytes to this buffer.
|
| void |
write(byte[] buff, int off, int len)
Append a number of bytes to this buffer.
Parameters:
buff - the data
off - the offset in the data
len - the length in bytes
|
| void |
writeByte(byte x)
Append one single byte.
|
| void |
writeByte(byte x)
Append one single byte.
Parameters:
x - the value
|
| void |
writeInt(int x)
Write an integer at the current position.
|
| void |
writeInt(int x)
Write an integer at the current position.
The current position is incremented.
Parameters:
x - the value
|
| void |
writeLong(long x)
Append a long value.
|
| void |
writeLong(long x)
Append a long value. This method writes two int values.
Parameters:
x - the value
|
| void |
writeShortInt(int x)
Write a short integer at the current position.
|
| void |
writeShortInt(int x)
Write a short integer at the current position.
The current position is incremented.
Parameters:
x - the value
|
| void |
writeString(String s)
Write a String.
|
| void |
writeString(String s)
Write a String.
The current position is incremented.
Parameters:
s - the value
|
| void |
writeValue(Value v)
Append a value.
|
| void |
writeValue(Value v)
Append a value.
Parameters:
v - the value
|
| void |
writeVarInt(int x)
Write a variable size int.
|
| void |
writeVarInt(int x)
Write a variable size int.
Parameters:
x - the value
|
| void |
writeVarLong(long x)
Write a variable size long.
|
| void |
writeVarLong(long x)
Write a variable size long.
Parameters:
x - the value
|
The length of an integer value.