com.go.trove.io
Class DefaultByteBuffer

java.lang.Object
  |
  +--com.go.trove.io.DefaultByteBuffer
All Implemented Interfaces:
ByteBuffer, ByteData, java.io.Serializable
Direct Known Subclasses:
DefaultByteBuffer

public class DefaultByteBuffer
extends java.lang.Object
implements ByteBuffer, java.io.Serializable

A ByteBuffer implementation that keeps byte data in memory.

Version:
18 , 01/05/30
Author:
Brian S O'Neill
See Also:
Serialized Form

Constructor Summary
DefaultByteBuffer()
           
 
Method Summary
 void addCaptureBuffer(ByteBuffer buffer)
          Add a ByteBuffer that will receive a copy of all the data appended to this ByteBuffer.
 void append(byte b)
          Add one byte to the end of this buffer.
 void append(byte[] bytes)
          Copy the given bytes to the end of this buffer.
 void append(byte[] bytes, int offset, int length)
          Copy the given bytes to the end of this buffer, starting at the offset, using the length provided.
 void appendSurrogate(ByteData s)
          Append ByteData that will not be touched until this ByteBuffer needs to calculate its byte count, or it needs to write out.
 long getBaseByteCount()
          Returns the base byte count, which excludes surrogates.
 long getByteCount()
          Return the amount of bytes that will be written by the writeTo method.
 void removeCaptureBuffer(ByteBuffer buffer)
          Remove a capture buffer that was previously added by addCaptureBuffer.
 void reset()
          Reset any transient data stored in this ByteData.
 void writeTo(java.io.OutputStream out)
          Writes all the bytes to the given OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultByteBuffer

public DefaultByteBuffer()
Method Detail

getBaseByteCount

public long getBaseByteCount()
Description copied from interface: ByteBuffer
Returns the base byte count, which excludes surrogates.
Specified by:
getBaseByteCount in interface ByteBuffer

getByteCount

public long getByteCount()
                  throws java.io.IOException
Description copied from interface: ByteData
Return the amount of bytes that will be written by the writeTo method.
Specified by:
getByteCount in interface ByteData

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Description copied from interface: ByteData
Writes all the bytes to the given OutputStream.
Specified by:
writeTo in interface ByteData

append

public void append(byte b)
            throws java.io.IOException
Description copied from interface: ByteBuffer
Add one byte to the end of this buffer.
Specified by:
append in interface ByteBuffer

append

public void append(byte[] bytes)
            throws java.io.IOException
Description copied from interface: ByteBuffer
Copy the given bytes to the end of this buffer.
Specified by:
append in interface ByteBuffer

append

public void append(byte[] bytes,
                   int offset,
                   int length)
            throws java.io.IOException
Description copied from interface: ByteBuffer
Copy the given bytes to the end of this buffer, starting at the offset, using the length provided.
Specified by:
append in interface ByteBuffer

appendSurrogate

public void appendSurrogate(ByteData s)
                     throws java.io.IOException
Description copied from interface: ByteBuffer
Append ByteData that will not be touched until this ByteBuffer needs to calculate its byte count, or it needs to write out. A null surrogate is not appended.
Specified by:
appendSurrogate in interface ByteBuffer

addCaptureBuffer

public void addCaptureBuffer(ByteBuffer buffer)
Description copied from interface: ByteBuffer
Add a ByteBuffer that will receive a copy of all the data appended to this ByteBuffer.
Specified by:
addCaptureBuffer in interface ByteBuffer

removeCaptureBuffer

public void removeCaptureBuffer(ByteBuffer buffer)
Description copied from interface: ByteBuffer
Remove a capture buffer that was previously added by addCaptureBuffer.
Specified by:
removeCaptureBuffer in interface ByteBuffer

reset

public void reset()
           throws java.io.IOException
Description copied from interface: ByteData
Reset any transient data stored in this ByteData. A call to getByteCount or writeTo will force this data to be restored.
Specified by:
reset in interface ByteData