Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.io
Class ByteArrayReadBuffer

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.io.AbstractReadBuffer
          extended by com.tangosol.io.AbstractByteArrayReadBuffer
              extended by com.tangosol.io.ByteArrayReadBuffer

All Implemented Interfaces:
ReadBuffer, ByteSequence, java.lang.Cloneable

public class ByteArrayReadBuffer
extends AbstractByteArrayReadBuffer

A ReadBuffer on top of a byte array.

Author:
cp 2005.01.20

Nested Class Summary

 

Nested classes/interfaces inherited from class com.tangosol.io.AbstractByteArrayReadBuffer
AbstractByteArrayReadBuffer.ByteArrayBufferInput

 

Nested classes/interfaces inherited from class com.tangosol.io.AbstractReadBuffer
AbstractReadBuffer.AbstractBufferInput

 

Nested classes/interfaces inherited from interface com.tangosol.io.ReadBuffer
ReadBuffer.BufferInput

 

Field Summary

 

Fields inherited from class com.tangosol.io.AbstractByteArrayReadBuffer
m_ab, m_cb, m_of

 

Fields inherited from class com.tangosol.io.AbstractReadBuffer
NO_BINARY, NO_BYTES

 

Constructor Summary
protected ByteArrayReadBuffer()
          Default constructor provided for subclasses.
  ByteArrayReadBuffer(byte[] ab)
          Construct a ByteArrayReadBuffer object from a byte array.
  ByteArrayReadBuffer(byte[] ab, int of, int cb)
          Construct a ByteArrayReadBuffer object from a portion of a byte array.
  ByteArrayReadBuffer(byte[] ab, int of, int cb, boolean fCopy, boolean fPrivate, boolean fShallowClone)
          Construct a ByteArrayReadBuffer object from a portion of a byte array.

 

Method Summary
 java.lang.Object clone()
          Create a clone of this ByteArrayReadBuffer object.
 byte[] getRawByteArray()
          Obtain the byte array that this ReadBuffer uses.
 int getRawOffset()
          Determine the offset into the byte array returned from getRawByteArray() that this ReadBuffer uses.
protected  ReadBuffer instantiateReadBuffer(int of, int cb)
          Factory method: Instantiate a ReadBuffer for a portion of this ReadBuffer.
protected  boolean isByteArrayPrivate()
          Determine if the underlying byte[] should be treated as private data.
protected  boolean isShallowCloneable()
          Determine whether a clone can be made without cloning the byte array.
 void resetRange(int of, int cb)
          Reset the portion of the byte array the ReadBuffer operates upon.
 java.lang.String toString()
          Provide a human-readable representation of the Binary object.

 

Methods inherited from class com.tangosol.io.AbstractByteArrayReadBuffer
byteAt, copyBytes, equals, instantiateBufferInput, length, toBinary, toBinary, toByteArray

 

Methods inherited from class com.tangosol.io.AbstractReadBuffer
checkBounds, getBufferInput, getReadBuffer, subSequence, toByteArray

 

Constructor Detail

ByteArrayReadBuffer

protected ByteArrayReadBuffer()
Default constructor provided for subclasses.

ByteArrayReadBuffer

public ByteArrayReadBuffer(byte[] ab)
Construct a ByteArrayReadBuffer object from a byte array. This constructor does not copy the byte array or make it private.
Parameters:
ab - an array of bytes

ByteArrayReadBuffer

public ByteArrayReadBuffer(byte[] ab,
                           int of,
                           int cb)
Construct a ByteArrayReadBuffer object from a portion of a byte array. This constructor does not copy the byte array or make it private.
Parameters:
ab - an array of bytes
of - the offset into the byte array
cb - the number of bytes to extract

ByteArrayReadBuffer

public ByteArrayReadBuffer(byte[] ab,
                           int of,
                           int cb,
                           boolean fCopy,
                           boolean fPrivate,
                           boolean fShallowClone)
Construct a ByteArrayReadBuffer object from a portion of a byte array.
Parameters:
ab - an array of bytes
of - the offset into the byte array
cb - the number of bytes to extract
fCopy - true to make a copy of the passed array
fPrivate - true to treat the passed array as private data
fShallowClone - true to allow cloning without copying the underlying byte[]

Method Detail

resetRange

public final void resetRange(int of,
                             int cb)
Reset the portion of the byte array the ReadBuffer operates upon.
Overrides:
resetRange in class AbstractByteArrayReadBuffer
Parameters:
of - an offset into the byte array
cb - the number of bytes to utilize

getRawByteArray

public final byte[] getRawByteArray()
Obtain the byte array that this ReadBuffer uses. If the underlying byte array is private, then this method will always return a copy of the portion of the byte array that this ReadBuffer represents as if the called had called AbstractReadBuffer.toByteArray().
Returns:
the byte array that this ReadBuffer uses

getRawOffset

public final int getRawOffset()
Determine the offset into the byte array returned from getRawByteArray() that this ReadBuffer uses. If the underlying byte array is private, then this method will always return zero because getRawByteArray() will always return a copy of the portion of the byte array that this ReadBuffer represents.
Returns:
the offset into the raw byte array that this ReadBuffer uses

instantiateReadBuffer

protected final ReadBuffer instantiateReadBuffer(int of,
                                                 int cb)
Factory method: Instantiate a ReadBuffer for a portion of this ReadBuffer.
Specified by:
instantiateReadBuffer in class AbstractReadBuffer
Parameters:
of - the beginning index, inclusive
cb - the number of bytes to include in the resulting ReadBuffer
Returns:
a ReadBuffer that represents a portion of this ReadBuffer

clone

public java.lang.Object clone()
Create a clone of this ByteArrayReadBuffer object.
Specified by:
clone in interface ReadBuffer
Overrides:
clone in class AbstractReadBuffer
Returns:
a ByteArrayReadBuffer object with the same contents as this ByteArrayReadBuffer object

toString

public java.lang.String toString()
Provide a human-readable representation of the Binary object.
Returns:
a String whose contents represent the value of this Binary object

isByteArrayPrivate

protected final boolean isByteArrayPrivate()
Determine if the underlying byte[] should be treated as private data.
Specified by:
isByteArrayPrivate in class AbstractByteArrayReadBuffer
Returns:
true iff the underlying data should not ever be exposed by this object

isShallowCloneable

protected final boolean isShallowCloneable()
Determine whether a clone can be made without cloning the byte array.
Returns:
true iff the underlying data can be shared by multiple instances of the ByteArrayReadBuffer class

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.