Package com.tangosol.util
Class BinaryWriteBuffer
- java.lang.Object
-
- com.tangosol.io.AbstractWriteBuffer
-
- com.tangosol.io.ByteArrayWriteBuffer
-
- com.tangosol.util.BinaryWriteBuffer
-
- All Implemented Interfaces:
WriteBuffer
public final class BinaryWriteBuffer extends ByteArrayWriteBuffer
a WriteBuffer implementation whose primary purpose is to be used to create Binary objects.- Author:
- cp 2005.06.02
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.io.ByteArrayWriteBuffer
ByteArrayWriteBuffer.Allocator, ByteArrayWriteBuffer.ByteArrayBufferOutput
-
Nested classes/interfaces inherited from class com.tangosol.io.AbstractWriteBuffer
AbstractWriteBuffer.AbstractBufferOutput
-
Nested classes/interfaces inherited from interface com.tangosol.io.WriteBuffer
WriteBuffer.BufferOutput
-
-
Field Summary
-
Fields inherited from class com.tangosol.io.ByteArrayWriteBuffer
m_ab, m_bufUnsafe, m_cb, m_cbMax
-
Fields inherited from class com.tangosol.io.AbstractWriteBuffer
CHAR_BUF_MASK, CHAR_BUF_SIZE, m_achBuf, NO_BINARY, NO_BYTES
-
-
Constructor Summary
Constructors Constructor Description BinaryWriteBuffer(int cbCap)
Construct an BinaryWriteBuffer with a certain initial capacity.BinaryWriteBuffer(int cbCap, int cbMax)
Construct an BinaryWriteBuffer with a certain initial capacity and a certain maximum capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkBounds(int of, int cb)
Validate the ranges for the passed bounds and make sure that the underlying array is big enough to handle them.Binary
toBinary()
Returns a new Binary object that holds the complete contents of this WriteBuffer.-
Methods inherited from class com.tangosol.io.ByteArrayWriteBuffer
copyStream, createBytes, getBufferOutput, getCapacity, getMaximumCapacity, getRawByteArray, getUnsafeReadBuffer, grow, isByteArrayPrivate, length, makeByteArrayPrivate, retain, setLength, toByteArray, updateLength, write, write, write, write
-
Methods inherited from class com.tangosol.io.AbstractWriteBuffer
clear, clone, copyBufferInputPortion, copyBufferInputRemainder, getAppendingBufferOutput, getBufferOutput, getReadBuffer, getWriteBuffer, getWriteBuffer, releaseBuffers, retain, tmpbuf, tmpbuf, write, write, write
-
-
-
-
Constructor Detail
-
BinaryWriteBuffer
public BinaryWriteBuffer(int cbCap)
Construct an BinaryWriteBuffer with a certain initial capacity.- Parameters:
cbCap
- initial capacity- Throws:
IllegalArgumentException
- if cbCap is negative
-
BinaryWriteBuffer
public BinaryWriteBuffer(int cbCap, int cbMax)
Construct an BinaryWriteBuffer with a certain initial capacity and a certain maximum capacity.- Parameters:
cbCap
- initial capacitycbMax
- maximum capacity- Throws:
IllegalArgumentException
- if cbCap or cbMax is negative, or if cbCap is greater than cbMax
-
-
Method Detail
-
toBinary
public Binary toBinary()
Returns a new Binary object that holds the complete contents of this WriteBuffer.This method is functionally equivalent to the following code:
return getUnsafeReadBuffer().toBinary();
- Specified by:
toBinary
in interfaceWriteBuffer
- Overrides:
toBinary
in classByteArrayWriteBuffer
- Returns:
- the contents of this WriteBuffer as a Binary object
-
checkBounds
protected void checkBounds(int of, int cb)
Validate the ranges for the passed bounds and make sure that the underlying array is big enough to handle them.Note: This method prevents all modifications from occurring once the BinaryWriteBuffer has supplied its byte array to a Binary object.
- Overrides:
checkBounds
in classByteArrayWriteBuffer
- Parameters:
of
- the offset that data is about to be written tocb
- the length of the data that is about to be written
-
-