Package org.h2.mvstore
Class WriteBuffer
java.lang.Object
org.h2.mvstore.WriteBuffer
An auto-resize buffer to write data into a ByteBuffer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()Get the capacity.clear()Clear the buffer after use.get(byte[] dst) Copy the data into the destination array.Get the byte buffer.intlimit()Get the limit.limit(int newLimit) Set the limit, possibly growing the buffer.intposition()Get the current position.position(int newPosition) Set the position.put(byte x) Put a byte.put(byte[] bytes) Put a byte array.put(byte[] bytes, int offset, int length) Put a byte array.put(ByteBuffer src) Put the contents of a byte buffer.putChar(char x) Put a character.putDouble(double x) Put a double.putFloat(float x) Put a float.putInt(int x) Put an integer.putInt(int index, int value) Update an integer at the given index.putLong(long x) Put a long.putShort(int index, short value) Update a short at the given index.putShort(short x) Put a short.putStringData(String s, int len) Write the characters of a string in a format similar to UTF-8.putVarInt(int x) Write a variable size integer.putVarLong(long x) Write a variable size long.
-
Constructor Details
-
WriteBuffer
public WriteBuffer(int initialSize) -
WriteBuffer
public WriteBuffer()
-
-
Method Details
-
putVarInt
Write a variable size integer.- Parameters:
x- the value- Returns:
- this
-
putVarLong
Write a variable size long.- Parameters:
x- the value- Returns:
- this
-
putStringData
Write the characters of a string in a format similar to UTF-8.- Parameters:
s- the stringlen- the number of characters to write- Returns:
- this
-
put
Put a byte.- Parameters:
x- the value- Returns:
- this
-
putChar
Put a character.- Parameters:
x- the value- Returns:
- this
-
putShort
Put a short.- Parameters:
x- the value- Returns:
- this
-
putInt
Put an integer.- Parameters:
x- the value- Returns:
- this
-
putLong
Put a long.- Parameters:
x- the value- Returns:
- this
-
putFloat
Put a float.- Parameters:
x- the value- Returns:
- this
-
putDouble
Put a double.- Parameters:
x- the value- Returns:
- this
-
put
Put a byte array.- Parameters:
bytes- the value- Returns:
- this
-
put
Put a byte array.- Parameters:
bytes- the valueoffset- the source offsetlength- the number of bytes- Returns:
- this
-
put
Put the contents of a byte buffer.- Parameters:
src- the source buffer- Returns:
- this
-
limit
Set the limit, possibly growing the buffer.- Parameters:
newLimit- the new limit- Returns:
- this
-
capacity
public int capacity()Get the capacity.- Returns:
- the capacity
-
position
Set the position.- Parameters:
newPosition- the new position- Returns:
- the new position
-
limit
public int limit()Get the limit.- Returns:
- the limit
-
position
public int position()Get the current position.- Returns:
- the position
-
get
Copy the data into the destination array.- Parameters:
dst- the destination array- Returns:
- this
-
putInt
Update an integer at the given index.- Parameters:
index- the indexvalue- the value- Returns:
- this
-
putShort
Update a short at the given index.- Parameters:
index- the indexvalue- the value- Returns:
- this
-
clear
Clear the buffer after use.- Returns:
- this
-
getBuffer
Get the byte buffer.- Returns:
- the byte buffer
-