Top Description Fields Constructors Methods
org.h2.mvstore

public Class WriteBuffer

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer

An auto-resize buffer to write data into a ByteBuffer.

Field Summary

Modifier and TypeField and Description
private ByteBuffer
buff

The current buffer (may be replaced if it is too small).

private static final int
MAX_REUSE_CAPACITY

The maximum size of the buffer in order to be re-used after a clear operation.

private static final int
MIN_GROW

The minimum number of bytes to grow a buffer at a time.

private ByteBuffer
reuse

The buffer that is used after a clear operation.

Constructor Summary

AccessConstructor and Description
public
WriteBuffer(int initialSize)

public

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the capacity
capacity
()

Get the capacity.

public WriteBuffer

Returns:

this
clear
()

Clear the buffer after use.

private ByteBuffer
ensureCapacity(int len)

public WriteBuffer

Returns:

this
get
(byte[]
the destination array
dst
)

Copy the data into the destination array.

public ByteBuffer

Returns:

the byte buffer
getBuffer
()

Get the byte buffer.

private void
grow(int additional)

public WriteBuffer

Returns:

this
limit
(int
the new limit
newLimit
)

Set the limit, possibly growing the buffer.

public int

Returns:

the limit
limit
()

Get the limit.

public WriteBuffer

Returns:

the new position
position
(int
the new position
newPosition
)

Set the position.

public int

Returns:

the position
position
()

Get the current position.

public WriteBuffer

Returns:

this
put
(byte
the value
x
)

Put a byte.

public WriteBuffer

Returns:

this
put
(byte[]
the value
bytes
)

Put a byte array.

public WriteBuffer

Returns:

this
put
(byte[]
the value
bytes
,
int
the source offset
offset
,
int
the number of bytes
length
)

Put a byte array.

public WriteBuffer

Returns:

this
put
(ByteBuffer
the source buffer
src
)

Put the contents of a byte buffer.

public WriteBuffer

Returns:

this
putChar
(char
the value
x
)

Put a character.

public WriteBuffer

Returns:

this
putDouble
(double
the value
x
)

Put a double.

public WriteBuffer

Returns:

this
putFloat
(float
the value
x
)

Put a float.

public WriteBuffer

Returns:

this
putInt
(int
the value
x
)

Put an integer.

public WriteBuffer

Returns:

this
putInt
(int
the index
index
,
int
the value
value
)

Update an integer at the given index.

public WriteBuffer

Returns:

this
putLong
(long
the value
x
)

Put a long.

public WriteBuffer

Returns:

this
putShort
(short
the value
x
)

Put a short.

public WriteBuffer

Returns:

this
putShort
(int
the index
index
,
short
the value
value
)

Update a short at the given index.

public WriteBuffer

Returns:

this
putStringData
(String
the string
s
,
int
the number of characters to write
len
)

Write the characters of a string in a format similar to UTF-8.

public WriteBuffer

Returns:

this
putVarInt
(int
the value
x
)

Write a variable size integer.

public WriteBuffer

Returns:

this
putVarLong
(long
the value
x
)

Write a variable size long.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

buffback to summary
private ByteBuffer buff

The current buffer (may be replaced if it is too small).

MAX_REUSE_CAPACITYback to summary
private static final int MAX_REUSE_CAPACITY

The maximum size of the buffer in order to be re-used after a clear operation.

MIN_GROWback to summary
private static final int MIN_GROW

The minimum number of bytes to grow a buffer at a time.

reuseback to summary
private ByteBuffer reuse

The buffer that is used after a clear operation.

Constructor Detail

WriteBufferback to summary
public WriteBuffer(int initialSize)
WriteBufferback to summary
public WriteBuffer()

Method Detail

capacityback to summary
public int capacity()

Get the capacity.

Returns:int

the capacity

clearback to summary
public WriteBuffer clear()

Clear the buffer after use.

Returns:WriteBuffer

this

ensureCapacityback to summary
private ByteBuffer ensureCapacity(int len)
getback to summary
public WriteBuffer get(byte[] dst)

Copy the data into the destination array.

Parameters
dst:byte[]

the destination array

Returns:WriteBuffer

this

getBufferback to summary
public ByteBuffer getBuffer()

Get the byte buffer.

Returns:ByteBuffer

the byte buffer

growback to summary
private void grow(int additional)
limitback to summary
public WriteBuffer limit(int newLimit)

Set the limit, possibly growing the buffer.

Parameters
newLimit:int

the new limit

Returns:WriteBuffer

this

limitback to summary
public int limit()

Get the limit.

Returns:int

the limit

positionback to summary
public WriteBuffer position(int newPosition)

Set the position.

Parameters
newPosition:int

the new position

Returns:WriteBuffer

the new position

positionback to summary
public int position()

Get the current position.

Returns:int

the position

putback to summary
public WriteBuffer put(byte x)

Put a byte.

Parameters
x:byte

the value

Returns:WriteBuffer

this

putback to summary
public WriteBuffer put(byte[] bytes)

Put a byte array.

Parameters
bytes:byte[]

the value

Returns:WriteBuffer

this

putback to summary
public WriteBuffer put(byte[] bytes, int offset, int length)

Put a byte array.

Parameters
bytes:byte[]

the value

offset:int

the source offset

length:int

the number of bytes

Returns:WriteBuffer

this

putback to summary
public WriteBuffer put(ByteBuffer src)

Put the contents of a byte buffer.

Parameters
src:ByteBuffer

the source buffer

Returns:WriteBuffer

this

putCharback to summary
public WriteBuffer putChar(char x)

Put a character.

Parameters
x:char

the value

Returns:WriteBuffer

this

putDoubleback to summary
public WriteBuffer putDouble(double x)

Put a double.

Parameters
x:double

the value

Returns:WriteBuffer

this

putFloatback to summary
public WriteBuffer putFloat(float x)

Put a float.

Parameters
x:float

the value

Returns:WriteBuffer

this

putIntback to summary
public WriteBuffer putInt(int x)

Put an integer.

Parameters
x:int

the value

Returns:WriteBuffer

this

putIntback to summary
public WriteBuffer putInt(int index, int value)

Update an integer at the given index.

Parameters
index:int

the index

value:int

the value

Returns:WriteBuffer

this

putLongback to summary
public WriteBuffer putLong(long x)

Put a long.

Parameters
x:long

the value

Returns:WriteBuffer

this

putShortback to summary
public WriteBuffer putShort(short x)

Put a short.

Parameters
x:short

the value

Returns:WriteBuffer

this

putShortback to summary
public WriteBuffer putShort(int index, short value)

Update a short at the given index.

Parameters
index:int

the index

value:short

the value

Returns:WriteBuffer

this

putStringDataback to summary
public WriteBuffer putStringData(String s, int len)

Write the characters of a string in a format similar to UTF-8.

Parameters
s:String

the string

len:int

the number of characters to write

Returns:WriteBuffer

this

putVarIntback to summary
public WriteBuffer putVarInt(int x)

Write a variable size integer.

Parameters
x:int

the value

Returns:WriteBuffer

this

putVarLongback to summary
public WriteBuffer putVarLong(long x)

Write a variable size long.

Parameters
x:long

the value

Returns:WriteBuffer

this