Top Description Fields Constructors Methods
org.h2.store

public Class Data

extends Object
Class Inheritance
Static Imports
org.h2.util.Bits.INT_VH_BE

This class represents a byte buffer that contains persistent data of a page.
Authors
Thomas Mueller, Noel Grandin, Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888

Field Summary

Modifier and TypeField and Description
private byte[]
data

The data itself.

private int
pos

The current write or read position.

Constructor Summary

AccessConstructor and Description
private
Data(byte[] data)

Method Summary

Modifier and TypeMethod and Description
public void
checkCapacity(int
the number of additional bytes required
plus
)

Check if there is still enough capacity in the buffer.

public static void
copyString(Reader
the reader
source
,
OutputStream
the output stream
target
)

Copy a String from a reader to an output stream.

public static Data

Returns:

the buffer
create
(int
the initial capacity of the buffer
capacity
)

Create a new buffer.

private void
expand(int plus)

public 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.

public byte[]

Returns:

the byte array
getBytes
()

Get the byte array used for this page.

public int

Returns:

the length
length
()

Get the current write position of this buffer, which is the current length.

public void
read(byte[]
the output buffer
buff
,
int
the offset in the output buffer
off
,
int
the number of bytes to copy
len
)

Copy a number of bytes to the given buffer from the current position.

public byte

Returns:

the value
readByte
()

Read one single byte.

public int

Returns:

the value
readInt
()

Read an integer at the current position.

public void
reset()

Set the position to 0.

public void
setPos(int
the new position
pos
)

Set the current read / write position.

public void
write(byte[]
the data
buff
,
int
the offset in the data
off
,
int
the length in bytes
len
)

Append a number of bytes to this buffer.

public void
writeInt(int
the value
x
)

Write an integer at the current position.

private void
writeStringWithoutLength(char[] chars, int len)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
private byte[] data

The data itself.

posback to summary
private int pos

The current write or read position.

Constructor Detail

Databack to summary
private Data(byte[] data)

Method Detail

checkCapacityback to summary
public void checkCapacity(int plus)

Check if there is still enough capacity in the buffer. This method extends the buffer if required.

Parameters
plus:int

the number of additional bytes required

copyStringback to summary
public static void copyString(Reader source, OutputStream target) throws IOException

Copy a String from a reader to an output stream.

Parameters
source:Reader

the reader

target:OutputStream

the output stream

Exceptions
IOException:
on failure
createback to summary
public static Data create(int capacity)

Create a new buffer.

Parameters
capacity:int

the initial capacity of the buffer

Returns:Data

the buffer

expandback to summary
private void expand(int plus)
fillAlignedback to summary
public 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.

getBytesback to summary
public byte[] getBytes()

Get the byte array used for this page.

Returns:byte[]

the byte array

lengthback to summary
public int length()

Get the current write position of this buffer, which is the current length.

Returns:int

the length

readback to summary
public 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:byte[]

the output buffer

off:int

the offset in the output buffer

len:int

the number of bytes to copy

readByteback to summary
public byte readByte()

Read one single byte.

Returns:byte

the value

readIntback to summary
public int readInt()

Read an integer at the current position. The current position is incremented.

Returns:int

the value

resetback to summary
public void reset()

Set the position to 0.

setPosback to summary
public void setPos(int pos)

Set the current read / write position.

Parameters
pos:int

the new position

writeback to summary
public void write(byte[] buff, int off, int len)

Append a number of bytes to this buffer.

Parameters
buff:byte[]

the data

off:int

the offset in the data

len:int

the length in bytes

writeIntback to summary
public void writeInt(int x)

Write an integer at the current position. The current position is incremented.

Parameters
x:int

the value

writeStringWithoutLengthback to summary
private void writeStringWithoutLength(char[] chars, int len)