org.elasticsearch.common.bytes
Interface BytesReference

All Known Implementing Classes:
ByteBufferBytesReference, BytesArray, ChannelBufferBytesReference, HashedBytesArray

public interface BytesReference

A reference to bytes.


Method Summary
 byte[] array()
          The underlying byte array (if exists).
 int arrayOffset()
          The offset into the underlying byte array.
 BytesArray copyBytesArray()
          Returns the bytes copied over as a byte array.
 byte get(int index)
          Returns the byte at the specified index.
 boolean hasArray()
          Is there an underlying byte array for this bytes reference.
 int length()
          The length.
 BytesReference slice(int from, int length)
          Slice the bytes from the from index up to length.
 StreamInput streamInput()
          A stream input of the bytes.
 byte[] toBytes()
          Returns the bytes as a single byte array.
 BytesArray toBytesArray()
          Returns the bytes as a byte array, possibly sharing the underlying byte buffer.
 org.jboss.netty.buffer.ChannelBuffer toChannelBuffer()
          Returns the bytes as a channel buffer.
 String toUtf8()
          Converts to a string based on utf8.
 void writeTo(OutputStream os)
          Writes the bytes directly to the output stream.
 

Method Detail

get

byte get(int index)
Returns the byte at the specified index. Need to be between 0 and length.


length

int length()
The length.


slice

BytesReference slice(int from,
                     int length)
Slice the bytes from the from index up to length.


streamInput

StreamInput streamInput()
A stream input of the bytes.


writeTo

void writeTo(OutputStream os)
             throws IOException
Writes the bytes directly to the output stream.

Throws:
IOException

toBytes

byte[] toBytes()
Returns the bytes as a single byte array.


toBytesArray

BytesArray toBytesArray()
Returns the bytes as a byte array, possibly sharing the underlying byte buffer.


copyBytesArray

BytesArray copyBytesArray()
Returns the bytes copied over as a byte array.


toChannelBuffer

org.jboss.netty.buffer.ChannelBuffer toChannelBuffer()
Returns the bytes as a channel buffer.


hasArray

boolean hasArray()
Is there an underlying byte array for this bytes reference.


array

byte[] array()
The underlying byte array (if exists).


arrayOffset

int arrayOffset()
The offset into the underlying byte array.


toUtf8

String toUtf8()
Converts to a string based on utf8.



Copyright © 2009-2012. All Rights Reserved.