public class UnsafeBuffer extends Object implements ClientProtocolBuffer
| Constructor and Description | 
|---|
| UnsafeBuffer(byte[] buffer)Attach a view to a byte[] for providing direct access. | 
| Modifier and Type | Method and Description | 
|---|---|
| byte[] | byteArray()Get the underlying byte[] if one exists. | 
| int | capacity()Get the capacity of the underlying buffer. | 
| byte | getByte(int index)Get the value at a given index. | 
| void | getBytes(int index,
        byte[] dst)Get from the underlying buffer into a supplied byte array. | 
| void | getBytes(int index,
        byte[] dst,
        int offset,
        int length)Get bytes from the underlying buffer into a supplied byte array. | 
| int | getInt(int index)Get the value at a given index. | 
| long | getLong(int index)Get the value at a given index. | 
| short | getShort(int index)Get the value at a given index. | 
| String | getStringUtf8(int offset,
             int length)Get part of String from bytes encoded in UTF-8 format without a length prefix. | 
| void | putByte(int index,
       byte value)Put a value to a given index. | 
| void | putBytes(int index,
        byte[] src)Put an array of src into the underlying buffer. | 
| void | putBytes(int index,
        byte[] src,
        int offset,
        int length)Put an array into the underlying buffer. | 
| void | putInt(int index,
      int value)Put a value at a given index. | 
| void | putLong(int index,
       long value)Put a value at a given index. | 
| void | putShort(int index,
        short value)Put a value to a given index. | 
| int | putStringUtf8(int index,
             String value)Encode a String as UTF-8 bytes to the buffer with a length prefix. | 
| int | putStringUtf8(int index,
             String value,
             int maxEncodedSize)Encode a String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check. | 
| void | wrap(byte[] buffer)Attach a view to a byte[] for providing direct access. | 
public UnsafeBuffer(byte[] buffer)
buffer - The buffer to which the view is attached.public void wrap(byte[] buffer)
ClientProtocolBufferwrap in interface ClientProtocolBufferbuffer - to which the view is attached.public byte[] byteArray()
ClientProtocolBufferbyteArray in interface ClientProtocolBufferpublic int capacity()
ClientProtocolBuffercapacity in interface ClientProtocolBufferpublic long getLong(int index)
ClientProtocolBuffergetLong in interface ClientProtocolBufferindex - in bytes from which to get.public void putLong(int index,
           long value)
ClientProtocolBufferputLong in interface ClientProtocolBufferindex - The index in bytes where the value is put.value - The value to put at the given index.public int getInt(int index)
ClientProtocolBuffergetInt in interface ClientProtocolBufferindex - in bytes from which to get.public void putInt(int index,
          int value)
ClientProtocolBufferputInt in interface ClientProtocolBufferindex - The index in bytes where the value is put.value - The value put at the given index.public short getShort(int index)
ClientProtocolBuffergetShort in interface ClientProtocolBufferindex - in bytes from which to get.public void putShort(int index,
            short value)
ClientProtocolBufferputShort in interface ClientProtocolBufferindex - The index in bytes where the value is put.value - The value put at the given index.public byte getByte(int index)
ClientProtocolBuffergetByte in interface ClientProtocolBufferindex - in bytes from which to get.public void putByte(int index,
           byte value)
ClientProtocolBufferputByte in interface ClientProtocolBufferindex - The index in bytes where the value is put.value - The value put at the given index.public void getBytes(int index,
            byte[] dst)
ClientProtocolBuffergetBytes in interface ClientProtocolBufferindex - in the underlying buffer to start from.dst - into which the dst will be copied.public void getBytes(int index,
            byte[] dst,
            int offset,
            int length)
ClientProtocolBuffergetBytes in interface ClientProtocolBufferindex - in the underlying buffer to start from.dst - into which the bytes will be copied.offset - in the supplied buffer to start the copylength - of the supplied buffer to use.public void putBytes(int index,
            byte[] src)
ClientProtocolBufferputBytes in interface ClientProtocolBufferindex - The index in the underlying buffer from which to start the array.src - The array to be copied into the underlying buffer.public void putBytes(int index,
            byte[] src,
            int offset,
            int length)
ClientProtocolBufferputBytes in interface ClientProtocolBufferindex - The index in the underlying buffer from which to start the array.src - The array to be copied into the underlying buffer.offset - The offset in the supplied buffer at which to begin the copy.length - The length of the supplied buffer to copy.public String getStringUtf8(int offset, int length)
ClientProtocolBuffergetStringUtf8 in interface ClientProtocolBufferoffset - at which the String begins.length - of the String in bytes to decode.public int putStringUtf8(int index,
                String value)
ClientProtocolBufferputStringUtf8 in interface ClientProtocolBufferindex - The index at which the String should be encoded.value - The value of the String to be encoded.public int putStringUtf8(int index,
                String value,
                int maxEncodedSize)
ClientProtocolBufferputStringUtf8 in interface ClientProtocolBufferindex - The index at which the String should be encoded.value - The value of the String to be encoded.maxEncodedSize - The maximum encoded size to be checked before writing to the buffer.Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.