|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.io.AbstractReadBuffer
com.tangosol.io.AbstractByteArrayReadBuffer
com.tangosol.util.Binary
public final class Binary
A thread-safe immutable binary object.
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 | |
---|---|
Binary()
Default constructor for a binary object. |
|
Binary(Binary that)
Construct a Binary object from a Binary object. |
|
Binary(byte[] ab)
Construct a binary object from a byte array. |
|
Binary(byte[] ab,
int of,
int cb)
Construct a binary object from a portion of a byte array. |
|
Binary(ByteArrayOutputStream stream)
Construct a Binary object from the contents of a ByteArrayOutputStream. |
|
Binary(DataInput stream)
Construct a binary object from a DataInput interface. |
Method Summary | |
---|---|
Object |
clone()
Create a clone of this Binary object. |
int |
compareTo(Object o)
Compares this object with the specified object for order. |
boolean |
endsWith(Binary bin)
Tests if this Binary object ends with the specified suffix. |
boolean |
equals(Object o)
Compares this Binary object with another object for equality. |
InputStream |
getInputStream()
Get an InputStream to read the Binary object's contents from. |
int |
hashCode()
Returns a hash code value for the object. |
int |
indexOf(byte b)
Returns the offset within this Binary object of the first occurrence of the specified byte. |
int |
indexOf(byte b,
int ofFrom)
Returns the offset within this Binary object of the first occurrence of the specified byte, starting the search at the specified offset. |
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. |
int |
lastIndexOf(byte b)
Returns the offset within this Binary object of the last occurrence of the specified byte. |
int |
lastIndexOf(byte b,
int ofFrom)
Returns the offset within this Binary object of the last occurrence of the specified byte, starting the search at the specified offset and searching backwards. |
void |
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from the passed DataInput object. |
void |
readExternal(ObjectInput in)
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. |
boolean |
regionMatches(int ofThis,
Binary that,
int ofThat,
int cb)
Tests if two Binary regions are equal. |
boolean |
startsWith(Binary bin)
Tests if this Binary object starts with the specified prefix. |
boolean |
startsWith(Binary bin,
int ofFrom)
Tests if this Binary object starts with the specified prefix beginning a specified offset. |
Binary |
toBinary()
Returns a new Binary object that holds the complete contents of this ReadBuffer.
This is the equivalent of |
Binary |
toBinary(int of,
int cb)
Returns a Binary object that holds the specified portion of this ReadBuffer.
This is the equivalent of
|
String |
toString()
Provide a human-readable representation of the Binary object. |
void |
writeExternal(DataOutput out)
Save the contents of this object by storing the object's state into the passed DataOutput object. |
void |
writeExternal(ObjectOutput out)
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays. |
void |
writeTo(OutputStream stream)
Write the contents of the Binary object to an OutputStream. |
Methods inherited from class com.tangosol.io.AbstractByteArrayReadBuffer |
---|
byteAt, copyBytes, instantiateBufferInput, length, resetRange, toByteArray |
Methods inherited from class com.tangosol.io.AbstractReadBuffer |
---|
checkBounds, getBufferInput, getReadBuffer, toByteArray |
Constructor Detail |
---|
public Binary()
public Binary(byte[] ab)
ab
- an array of bytespublic Binary(byte[] ab, int of, int cb)
ab
- an array of bytesof
- the offset into the byte arraycb
- the number of bytes to extractpublic Binary(Binary that)
that
- another Binary objectString.String(String)
public Binary(ByteArrayOutputStream stream)
stream
- the ByteArrayOutputStream that holds the value that
this Binary object will representpublic Binary(DataInput stream) throws IOException
stream
- the object implementing DataInput from which this
Binary object will load its data
IOException
- if an I/O error occurs reading the BinaryMethod Detail |
---|
public boolean regionMatches(int ofThis, Binary that, int ofThat, int cb)
ofThis
- the starting offset of the subregion in this Binary
objectthat
- the Binary object containing the subregion to compare toofThat
- the starting offset of the subregion in the passed
Binary object that
cb
- the number of bytes to compare
true
if the specified subregion of this Binary
object exactly matches the specified subregion of
the that
Binary object; false
otherwise
NullPointerException
- if that
is
null
String.regionMatches(int, java.lang.String, int, int)
public boolean startsWith(Binary bin, int ofFrom)
bin
- the prefixofFrom
- the offset to begin looking in this Binary object
true
if the byte sequence represented by the
bin
argument is a prefix of the substring of
this Binary object starting at offset ofFrom
;
false
otherwise
NullPointerException
- if bin
is
null
.String.startsWith(java.lang.String, int)
public boolean startsWith(Binary bin)
bin
- the prefix
true
if the byte sequence represented by the
bin
argument is a prefix of this Binary object;
false
otherwise
NullPointerException
- if bin
is
null
.String.startsWith(java.lang.String, int)
public boolean endsWith(Binary bin)
bin
- the suffix
true
if the byte sequence represented by the
bin
argument is a suffix of this Binary object;
false
otherwise
NullPointerException
- if bin
is
null
.String.endsWith(java.lang.String)
public int indexOf(byte b)
b
- the byte to search for
-1
if the byte does not occur in the sequenceString.indexOf(int)
public int indexOf(byte b, int ofFrom)
b
- the byte to search forofFrom
- the offset to search from
ofFrom
, or -1
if the
byte does not occur from that offset to the end of the sequenceString.indexOf(int)
public int lastIndexOf(byte b)
b
- the byte to search for
-1
if the byte does not occur in the sequenceString.lastIndexOf(int)
public int lastIndexOf(byte b, int ofFrom)
b
- the byte to search forofFrom
- the offset to search backwards from (inclusive)
ofFrom
, or -1
if the
byte does not occur from that offset to the start of the
sequenceString.lastIndexOf(int)
public Binary toBinary()
This is the equivalent of toBinary(0, length())
.
toBinary
in interface ReadBuffer
toBinary
in class AbstractByteArrayReadBuffer
public Binary toBinary(int of, int cb)
This is the equivalent of
getReadBuffer(of, cb).toBinary()
.
toBinary
in interface ReadBuffer
toBinary
in class AbstractByteArrayReadBuffer
of
- the beginning index, inclusivecb
- the number of bytes to include in the Binary object
protected ReadBuffer instantiateReadBuffer(int of, int cb)
instantiateReadBuffer
in class AbstractReadBuffer
of
- the beginning index, inclusivecb
- the number of bytes to include in the resulting ReadBuffer
protected boolean isByteArrayPrivate()
isByteArrayPrivate
in class AbstractByteArrayReadBuffer
public Object clone()
clone
in interface ReadBuffer
clone
in class AbstractReadBuffer
public String toString()
public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashed data structures.
The Binary object uses a CRC32 algorithm to determine the hash code. For more information on this algorithm, see http://www.tangosol.com/article-crc.jsp.
public boolean equals(Object o)
equals
in class AbstractReadBuffer
o
- an object reference or null
public int compareTo(Object o)
compareTo
in interface Comparable
o
- the Object to be compared.
ClassCastException
- if the specified object's type prevents it
from being compared to this Object
NullPointerException
- if the specified object is
null
public void readExternal(ObjectInput in) throws IOException
readExternal
in interface Externalizable
in
- the stream to read data from in order to restore the object
IOException
- if an I/O exception occurspublic void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
out
- the stream to write the object to
IOException
- if an I/O exception occurspublic void readExternal(DataInput in) throws IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore
the state of this object
IOException
- if an I/O exception occurs
NotActiveException
- if the object is not in its initial
state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object to
IOException
- if an I/O exception occurspublic InputStream getInputStream()
public void writeTo(OutputStream stream) throws IOException
stream
- an OutputStream to write to
IOException
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |