Class LinkedBuffer
java.lang.Object
io.protostuff.LinkedBuffer
A buffer that wraps a byte array and has a reference to the next buffer for dynamic increase.
- Author:
- David Yu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default buffer size for aLinkedBuffer.static final intThe minimum buffer size for aLinkedBuffer. -
Method Summary
Modifier and TypeMethodDescriptionstatic LinkedBufferallocate()Allocates a new buffer with default size.static LinkedBufferallocate(int size) Allocates a new buffer with the specified size.static LinkedBufferallocate(int size, LinkedBuffer previous) Allocates a new buffer with the specified size and appends it to the previous buffer.clear()The offset will be reset to its starting position.static LinkedBufferuse(byte[] buffer) Uses the existing byte array as the internal buffer.static LinkedBufferuse(byte[] buffer, int start) Uses the existing byte array as the internal buffer.static LinkedBufferwrap(byte[] array, int offset, int length) Wraps the byte array buffer as a read-only buffer.static intwriteTo(DataOutput out, LinkedBuffer node) Writes the contents of theLinkedBufferinto theDataOutput.static intwriteTo(OutputStream out, LinkedBuffer node) Writes the contents of theLinkedBufferinto theOutputStream.
-
Field Details
-
MIN_BUFFER_SIZE
-
DEFAULT_BUFFER_SIZE
-
-
Method Details
-
allocate
Allocates a new buffer with default size. -
allocate
Allocates a new buffer with the specified size. -
allocate
Allocates a new buffer with the specified size and appends it to the previous buffer. -
wrap
Wraps the byte array buffer as a read-only buffer. -
use
Uses the existing byte array as the internal buffer. -
use
Uses the existing byte array as the internal buffer. -
writeTo
Writes the contents of theLinkedBufferinto theOutputStream.- Returns:
- the total content size of the buffer.
- Throws:
IOException
-
writeTo
Writes the contents of theLinkedBufferinto theDataOutput.- Returns:
- the total content size of the buffer.
- Throws:
IOException
-
clear
The offset will be reset to its starting position. The buffer next to this will be dereferenced.
-