com.netflix.astyanax.serializers
Class ByteBufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.netflix.astyanax.serializers.ByteBufferOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class ByteBufferOutputStream
extends java.io.OutputStream

Utility to collect data written to an OutputStream in ByteBuffers. Originally from org.apache.avro.util.ByteBufferOutputStream, moved into Hector and added getByteBuffer to return single ByteBuffer from contents.


Field Summary
static int INIT_BUFFER_SIZE
           
static int MAX_BUFFER_SIZE
           
 
Constructor Summary
ByteBufferOutputStream()
           
 
Method Summary
 void append(java.util.List<java.nio.ByteBuffer> lists)
          Append a list of ByteBuffers to this stream.
 java.util.List<java.nio.ByteBuffer> getBufferList()
          Returns all data written and resets the stream to be empty.
 java.nio.ByteBuffer getByteBuffer()
           
 void prepend(java.util.List<java.nio.ByteBuffer> lists)
          Prepend a list of ByteBuffers to this stream.
 void reset()
           
 void write(byte[] b, int off, int len)
           
 void write(java.nio.ByteBuffer buffer)
          Add a buffer to the output without copying, if possible.
 void write(int b)
           
 void writeChar(char value)
           
 void writeDouble(double value)
           
 void writeFloat(float value)
           
 void writeInt(int value)
           
 void writeLong(long value)
           
 void writeShort(short value)
           
 
Methods inherited from class java.io.OutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INIT_BUFFER_SIZE

public static final int INIT_BUFFER_SIZE
See Also:
Constant Field Values

MAX_BUFFER_SIZE

public static final int MAX_BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

ByteBufferOutputStream

public ByteBufferOutputStream()
Method Detail

getBufferList

public java.util.List<java.nio.ByteBuffer> getBufferList()
Returns all data written and resets the stream to be empty.


getByteBuffer

public java.nio.ByteBuffer getByteBuffer()

prepend

public void prepend(java.util.List<java.nio.ByteBuffer> lists)
Prepend a list of ByteBuffers to this stream.


append

public void append(java.util.List<java.nio.ByteBuffer> lists)
Append a list of ByteBuffers to this stream.


reset

public void reset()

write

public void write(int b)
Specified by:
write in class java.io.OutputStream

writeShort

public void writeShort(short value)

writeChar

public void writeChar(char value)

writeInt

public void writeInt(int value)

writeFloat

public void writeFloat(float value)

writeLong

public void writeLong(long value)

writeDouble

public void writeDouble(double value)

write

public void write(byte[] b,
                  int off,
                  int len)
Overrides:
write in class java.io.OutputStream

write

public void write(java.nio.ByteBuffer buffer)
Add a buffer to the output without copying, if possible.