org.elasticsearch.common.io.stream
Class BytesStreamOutput

java.lang.Object
  extended by java.io.OutputStream
      extended by org.elasticsearch.common.io.stream.StreamOutput
          extended by org.elasticsearch.common.io.stream.BytesStreamOutput
All Implemented Interfaces:
Closeable, Flushable, BytesStream

public class BytesStreamOutput
extends StreamOutput
implements BytesStream


Field Summary
protected  byte[] buf
          The buffer where data is stored.
protected  int count
          The number of valid bytes in the buffer.
 
Constructor Summary
BytesStreamOutput()
           
BytesStreamOutput(int size)
           
 
Method Summary
 BytesReference bytes()
           
 void close()
          Closes this stream to further operations.
 void flush()
          Forces any buffered output to be written.
 long position()
           
 void reset()
           
 void seek(int seekTo)
           
 void seek(long position)
           
 boolean seekPositionSupported()
           
 int size()
          Returns the current size of the buffer.
 void writeByte(byte b)
          Writes a single byte.
 void writeBytes(byte[] b, int offset, int length)
          Writes an array of bytes.
 
Methods inherited from class org.elasticsearch.common.io.stream.StreamOutput
write, write, writeBoolean, writeBytes, writeBytes, writeBytesReference, writeDouble, writeFloat, writeGenericValue, writeInt, writeLong, writeMap, writeOptionalString, writeOptionalUTF, writeShort, writeString, writeStringArray, writeText, writeUTF, writeVInt, writeVLong
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buf

protected byte[] buf
The buffer where data is stored.


count

protected int count
The number of valid bytes in the buffer.

Constructor Detail

BytesStreamOutput

public BytesStreamOutput()

BytesStreamOutput

public BytesStreamOutput(int size)
Method Detail

seekPositionSupported

public boolean seekPositionSupported()
Overrides:
seekPositionSupported in class StreamOutput

position

public long position()
              throws IOException
Overrides:
position in class StreamOutput
Throws:
IOException

seek

public void seek(long position)
          throws IOException
Overrides:
seek in class StreamOutput
Throws:
IOException

writeByte

public void writeByte(byte b)
               throws IOException
Description copied from class: StreamOutput
Writes a single byte.

Specified by:
writeByte in class StreamOutput
Throws:
IOException

writeBytes

public void writeBytes(byte[] b,
                       int offset,
                       int length)
                throws IOException
Description copied from class: StreamOutput
Writes an array of bytes.

Specified by:
writeBytes in class StreamOutput
Parameters:
b - the bytes to write
offset - the offset in the byte array
length - the number of bytes to write
Throws:
IOException

seek

public void seek(int seekTo)

reset

public void reset()
Specified by:
reset in class StreamOutput

flush

public void flush()
           throws IOException
Description copied from class: StreamOutput
Forces any buffered output to be written.

Specified by:
flush in interface Flushable
Specified by:
flush in class StreamOutput
Throws:
IOException

close

public void close()
           throws IOException
Description copied from class: StreamOutput
Closes this stream to further operations.

Specified by:
close in interface Closeable
Specified by:
close in class StreamOutput
Throws:
IOException

bytes

public BytesReference bytes()
Specified by:
bytes in interface BytesStream

size

public int size()
Returns the current size of the buffer.

Returns:
the value of the count field, which is the number of valid bytes in this output stream.
See Also:
ByteArrayOutputStream.count


Copyright © 2009-2012. All Rights Reserved.