Skip navigation links

Oracle® Coherence Java API Reference
v3.5.1

E15583-01


com.tangosol.util
Class Binary

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.util.Binary

All Implemented Interfaces:
ExternalizableLite, ReadBuffer, java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public final class Binary
extends AbstractByteArrayReadBuffer
implements java.lang.Cloneable, java.lang.Comparable, java.io.Externalizable, ExternalizableLite

A thread-safe immutable binary object.

Author:
cp 2002.01.25

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(java.io.ByteArrayOutputStream stream)
          Construct a Binary object from the contents of a ByteArrayOutputStream.
Binary(java.io.DataInput stream)
          Construct a binary object from a DataInput interface.

 

Method Summary
 java.lang.Object clone()
          Create a clone of this Binary object.
static byte[] clone(byte[] ab, int of, int cb)
          Create a clone of the specified binary region.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 Binary concat(Binary bin)
          Concatenate the passed Binary onto this Binary.
 boolean endsWith(Binary bin)
          Tests if this Binary object ends with the specified suffix.
static boolean equals(byte[] ab1, int of1, byte[] ab2, int of2, int cb)
          Compare two binary regions, testing for equality.
 boolean equals(java.lang.Object o)
          Compares this Binary object with another object for equality.
 java.io.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(Binary bin)
          Returns the offset within this Binary object of the first occurrence of the specified Binary.
 int indexOf(Binary bin, int ofFrom)
          Returns the offset within this Binary object of the first occurrence of the specified Binary, starting the search at the specified offset.
 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(Binary bin)
          Returns the offset within this Binary object of the last occurrence of the specified Binary.
 int lastIndexOf(Binary bin, int ofFrom)
          Returns the offset within this Binary object of the last occurrence of the specified Binary, starting the search at the specified offset.
 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.
static int memchr(byte[] abHaystack, int ofHaystack, int cbHaystack, byte bNeedle)
          Find the specified byte (a "needle") in the specified binary region ("the haystack").
static int memchr(byte[] abHaystack, int ofHaystack, int cbHaystack, byte bNeedle, boolean fBackwards)
          Find the specified byte (a "needle") in the specified binary region ("the haystack").
static int memcmp(byte[] ab1, int of1, int cb1, byte[] ab2, int of2, int cb2)
          Compare two binary regions.
static void memcpy(byte[] abSrc, int ofSrc, byte[] abDest, int ofDest, int cbCopy)
          Copy binary data from one binary region to another.
static int memmem(byte[] abHaystack, int ofHaystack, int cbHaystack, byte[] abNeedle, int ofNeedle, int cbNeedle)
          Find the second binary region (a "needle") in the first binary region ("the haystack").
static int memmem(byte[] abHaystack, int ofHaystack, int cbHaystack, byte[] abNeedle, int ofNeedle, int cbNeedle, boolean fBackwards)
          Find the second binary region (a "needle") in the first binary region ("the haystack").
 void readExternal(java.io.DataInput in)
          Restore the contents of this object by loading the object's state from the passed DataInput object.
 void readExternal(java.io.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.
 Binary replace(Binary binOld, Binary binNew)
          Replace all occurrences of one specified Binary with another in this Binary object.
 Binary replace(byte bOld, byte bNew)
          Replace all occurrences of one specified byte with another in this Binary object.
 Binary replaceRegion(int of, int cb, Binary binNew)
          Replace a region within this Binary with another Binary.
 Binary reverse()
          Reverse this Binary object's byte sequence such that the byte at offset zero of this sequence occurs at offset length()-1 in the resulting sequence, the byte at offset one of this sequence occurs at offset length()-2 in the resulting sequence, and so on.
 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 toBinary(0, length()).

 Binary toBinary(int of, int cb)
          Returns a Binary object that holds the specified portion of this ReadBuffer.

This is the equivalent of getReadBuffer(of, cb).toBinary().

 java.lang.String toString()
          Provide a human-readable representation of the Binary object.
static java.lang.String toString(byte[] ab)
          For debugging purposes, convert the passed byte array into a string that contains the information regarding whether the reference is null, and if it is not null, what the length of the byte array is.
 void writeExternal(java.io.DataOutput out)
          Save the contents of this object by storing the object's state into the passed DataOutput object.
 void writeExternal(java.io.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(java.nio.ByteBuffer buf)
          Write the contents of the Binary object to a ByteBuffer.
 void writeTo(java.nio.ByteBuffer buf, int of, int cb)
          Write the contents of the Binary object to a ByteBuffer.
 void writeTo(java.io.DataOutput out)
          Write the contents of the Binary object to a DataOutput.
 void writeTo(java.io.DataOutput out, int of, int cb)
          Write the contents of the Binary object to a DataOutput.
 void writeTo(java.io.OutputStream out)
          Write the contents of the Binary object to an OutputStream.
 void writeTo(java.io.OutputStream out, int of, int cb)
          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

Binary

public Binary()
Default constructor for a binary object. Supports deserialization.

Binary

public Binary(byte[] ab)
Construct a binary object from a byte array.
Parameters:
ab - an array of bytes

Binary

public Binary(byte[] ab,
              int of,
              int cb)
Construct a binary 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

Binary

public Binary(Binary that)
Construct a Binary object from a Binary object.
Parameters:
that - another Binary object
See Also:
String.String(String)

Binary

public Binary(java.io.ByteArrayOutputStream stream)
Construct a Binary object from the contents of a ByteArrayOutputStream.
Parameters:
stream - the ByteArrayOutputStream that holds the value that this Binary object will represent

Binary

public Binary(java.io.DataInput stream)
       throws java.io.IOException
Construct a binary object from a DataInput interface.
Parameters:
stream - the object implementing DataInput from which this Binary object will load its data
Throws:
java.io.IOException - if an I/O error occurs reading the Binary

Method Detail

regionMatches

public boolean regionMatches(int ofThis,
                             Binary that,
                             int ofThat,
                             int cb)
Tests if two Binary regions are equal.
Parameters:
ofThis - the starting offset of the subregion in this Binary object
that - the Binary object containing the subregion to compare to
ofThat - the starting offset of the subregion in the passed Binary object that
cb - the number of bytes to compare
Returns:
true if the specified subregion of this Binary object exactly matches the specified subregion of the that Binary object; false otherwise
Throws:
java.lang.NullPointerException - if that is null
See Also:
String.regionMatches(int, java.lang.String, int, int)

startsWith

public boolean startsWith(Binary bin,
                          int ofFrom)
Tests if this Binary object starts with the specified prefix beginning a specified offset.
Parameters:
bin - the prefix
ofFrom - the offset to begin looking in this Binary object
Returns:
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
Throws:
java.lang.NullPointerException - if bin is null.
See Also:
String.startsWith(java.lang.String, int)

startsWith

public boolean startsWith(Binary bin)
Tests if this Binary object starts with the specified prefix.
Parameters:
bin - the prefix
Returns:
true if the byte sequence represented by the bin argument is a prefix of this Binary object; false otherwise
Throws:
java.lang.NullPointerException - if bin is null.
See Also:
String.startsWith(java.lang.String, int)

endsWith

public boolean endsWith(Binary bin)
Tests if this Binary object ends with the specified suffix.
Parameters:
bin - the suffix
Returns:
true if the byte sequence represented by the bin argument is a suffix of this Binary object; false otherwise
Throws:
java.lang.NullPointerException - if bin is null.
See Also:
String.endsWith(java.lang.String)

indexOf

public int indexOf(byte b)
Returns the offset within this Binary object of the first occurrence of the specified byte. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
b - the byte to search for
Returns:
the offset of the first occurrence of the specified byte in the byte sequence represented by this Binary object, or -1 if the byte does not occur in the sequence
See Also:
String.indexOf(int)

indexOf

public 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. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
b - the byte to search for
ofFrom - the offset to search from
Returns:
the offset of the first occurrence of the specified byte in the byte sequence represented by this Binary object that is greater than or equal to ofFrom, or -1 if the byte does not occur from that offset to the end of the sequence
See Also:
String.indexOf(int, int)

indexOf

public int indexOf(Binary bin)
Returns the offset within this Binary object of the first occurrence of the specified Binary. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
bin - the Binary to search for
Returns:
the offset of the first occurrence of the byte sequence represented by the specified Binary in the byte sequence represented by this Binary object, or -1 if the byte sequence does not occur
Since:
Coherence 3.5
See Also:
String.indexOf(String)

indexOf

public int indexOf(Binary bin,
                   int ofFrom)
Returns the offset within this Binary object of the first occurrence of the specified Binary, starting the search at the specified offset. <p/> This method is identical in its functionality to the corresponding method in String. Note that one side-effect of maintaining compatibility with the String behavior is that zero-length Strings can be found even when the from-index is out-of-bounds. Given any Binary value "value" and a zero-length binary value "empty", the following will always hold true:
 int rnd = new Random().nextInt(Integer.MAX_VALUE - value.length());
 assert value.indexOf(empty, value.length() + rnd) == value.length();
 
Parameters:
bin - the Binary to search for
ofFrom - the offset to search from
Returns:
the offset of the first occurrence of the byte sequence represented by the specified Binary in the byte sequence represented by this Binary object that is greater than or equal to ofFrom, or -1 if the byte sequence does not occur from that offset to the end of this Binary
Since:
Coherence 3.5
See Also:
String.indexOf(String, int)

lastIndexOf

public int lastIndexOf(byte b)
Returns the offset within this Binary object of the last occurrence of the specified byte. The byte sequence of the Binary object is searched in backwards order. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
b - the byte to search for
Returns:
the offset of the last occurrence of the specified byte in the byte sequence represented by this Binary object, or -1 if the byte does not occur in the sequence
See Also:
String.lastIndexOf(int)

lastIndexOf

public 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. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
b - the byte to search for
ofFrom - the offset to search backwards from (inclusive)
Returns:
the offset of the last occurrence of the specified byte in the byte sequence represented by this Binary object that is less than or equal to ofFrom, or -1 if the byte does not occur from that offset to the start of the sequence
See Also:
String.lastIndexOf(int, int)

lastIndexOf

public int lastIndexOf(Binary bin)
Returns the offset within this Binary object of the last occurrence of the specified Binary. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
bin - the Binary to search for
Returns:
the offset of the last occurrence of the byte sequence represented by the specified Binary in the byte sequence represented by this Binary object, or -1 if the byte sequence does not occur
Since:
Coherence 3.5
See Also:
String.lastIndexOf(String)

lastIndexOf

public int lastIndexOf(Binary bin,
                       int ofFrom)
Returns the offset within this Binary object of the last occurrence of the specified Binary, starting the search at the specified offset. <p/> This method is identical in its functionality to the corresponding method in String.
Parameters:
bin - the Binary to search for
ofFrom - the offset to search from
Returns:
the offset of the last occurrence of the byte sequence represented by the specified Binary in the byte sequence represented by this Binary object that is less than or equal to ofFrom, or -1 if the byte sequence does not occur from that offset to the beginning of this Binary
Since:
Coherence 3.5
See Also:
String.lastIndexOf(String, int)

replace

public Binary replace(byte bOld,
                      byte bNew)
Replace all occurrences of one specified byte with another in this Binary object. (This method does not alter the state of this Binary; if replacement must occur, it is accomplished by creating a new Binary instance.)
Parameters:
bOld - the byte value to replace
bNew - the byte value to replace bOld with
Returns:
a Binary whose value is the same as this Binary's value, except that all occurrences of bOld will have been replaced with bNew

replace

public Binary replace(Binary binOld,
                      Binary binNew)
Replace all occurrences of one specified Binary with another in this Binary object. (This method does not alter the state of this Binary; if replacement must occur, it is accomplished by creating a new Binary instance.)
Parameters:
binOld - the Binary value to replace
binNew - the Binary value to replace binOld with
Returns:
a Binary whose value is the same as this Binary's value, except that all occurrences of binOld will have been replaced with binNew

replaceRegion

public Binary replaceRegion(int of,
                            int cb,
                            Binary binNew)
Replace a region within this Binary with another Binary. <p/> This method does not alter the state of this Binary; it creates a new Binary instance instead.
Parameters:
of - the offset of the range to replace within this Binary
cb - the length of the range to replace in bytes
binNew - the Binary value to replace the range with
Returns:
a Binary whose value is the same as this Binary's value, except that the specified range will have been replaced with binNew
Since:
Coherence 3.5

concat

public Binary concat(Binary bin)
Concatenate the passed Binary onto this Binary.
Parameters:
bin - the Binary to concatenate to this Binary
Returns:
a Binary containing the byte sequence of this Binary object followed immediately by the byte sequence of the passed Binary object
Since:
Coherence 3.5

reverse

public Binary reverse()
Reverse this Binary object's byte sequence such that the byte at offset zero of this sequence occurs at offset length()-1 in the resulting sequence, the byte at offset one of this sequence occurs at offset length()-2 in the resulting sequence, and so on. The resulting Binary object will have the same length as this Binary object.
Returns:
a Binary whose byte sequence contains the same byte values as this Binary, but in reverse sequence
Since:
Coherence 3.5

toBinary

public Binary toBinary()
Returns a new Binary object that holds the complete contents of this ReadBuffer.

This is the equivalent of toBinary(0, length()).

Specified by:
toBinary in interface ReadBuffer
Overrides:
toBinary in class AbstractByteArrayReadBuffer
Returns:
the contents of this ReadBuffer as a Binary object

toBinary

public Binary toBinary(int of,
                       int cb)
Returns a Binary object that holds the specified portion of this ReadBuffer.

This is the equivalent of getReadBuffer(of, cb).toBinary().

Specified by:
toBinary in interface ReadBuffer
Overrides:
toBinary in class AbstractByteArrayReadBuffer
Parameters:
of - the beginning index, inclusive
cb - the number of bytes to include in the Binary object
Returns:
a Binary object containing the specified portion of this ReadBuffer

instantiateReadBuffer

protected 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

isByteArrayPrivate

protected 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

clone

public java.lang.Object clone()
Create a clone of this Binary object.
Specified by:
clone in interface ReadBuffer
Overrides:
clone in class AbstractReadBuffer
Returns:
a Binary object with the same contents as this Binary 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

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashed data structures. <p/> The Binary object uses a CRC32 algorithm to determine the hash code.
Returns:
a hash code value for this object
See Also:
Base.toCrc(byte[], int, int)

equals

public boolean equals(java.lang.Object o)
Compares this Binary object with another object for equality.
Overrides:
equals in class AbstractReadBuffer
Parameters:
o - an object reference or null
Returns:
true iff the passed object reference is a Binary object representing the same exact sequence of byte values

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this Object
java.lang.NullPointerException - if the specified object is null

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException
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. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
java.io.IOException - if an I/O exception occurs

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
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.
Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the stream to write the object to
Throws:
java.io.IOException - if an I/O exception occurs

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException
Restore the contents of this object by loading the object's state from the passed DataInput object.
Specified by:
readExternal in interface ExternalizableLite
Parameters:
in - the DataInput stream to read data from in order to restore the state of this object
Throws:
java.io.IOException - if an I/O exception occurs
java.io.NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Save the contents of this object by storing the object's state into the passed DataOutput object.
Specified by:
writeExternal in interface ExternalizableLite
Parameters:
out - the DataOutput stream to write the state of this object to
Throws:
java.io.IOException - if an I/O exception occurs

getInputStream

public java.io.InputStream getInputStream()
Get an InputStream to read the Binary object's contents from.
Returns:
an InputStream backed by this Binary object

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Write the contents of the Binary object to an OutputStream.
Parameters:
out - an OutputStream to write to
Throws:
java.io.IOException - if an I/O exception occurs

writeTo

public void writeTo(java.io.OutputStream out,
                    int of,
                    int cb)
             throws java.io.IOException
Write the contents of the Binary object to an OutputStream.
Parameters:
out - an OutputStream to write to
of - the beginning index, inclusive
cb - the number of bytes to write to an OutputStream
Throws:
java.io.IOException - if an I/O exception occurs
Since:
Coherence 3.5

writeTo

public void writeTo(java.io.DataOutput out)
             throws java.io.IOException
Write the contents of the Binary object to a DataOutput.
Parameters:
out - a DataOutput to write to
Throws:
java.io.IOException - if an I/O exception occurs

writeTo

public void writeTo(java.io.DataOutput out,
                    int of,
                    int cb)
             throws java.io.IOException
Write the contents of the Binary object to a DataOutput.
Parameters:
out - a DataOutput to write to
of - the beginning index, inclusive
cb - the number of bytes to write to a DataOutput
Throws:
java.io.IOException - if an I/O exception occurs
Since:
Coherence 3.5

writeTo

public void writeTo(java.nio.ByteBuffer buf)
Write the contents of the Binary object to a ByteBuffer.
Parameters:
buf - a ByteBuffer to write to

writeTo

public void writeTo(java.nio.ByteBuffer buf,
                    int of,
                    int cb)
             throws java.io.IOException
Write the contents of the Binary object to a ByteBuffer.
Parameters:
buf - an ByteBuffer to write to
of - the beginning index, inclusive
cb - the number of bytes to write to a ByteBuffer
Throws:
java.io.IOException - if an I/O exception occurs
Since:
Coherence 3.5

memchr

public static int memchr(byte[] abHaystack,
                         int ofHaystack,
                         int cbHaystack,
                         byte bNeedle)
Find the specified byte (a "needle") in the specified binary region ("the haystack").
Parameters:
abHaystack - the byte array containing the binary region to search within (the "haystack")
ofHaystack - the offset of the binary region within abHaystack
cbHaystack - the size in bytes of the binary region within abHaystack
bNeedle - the byte to search for (a "needle")
Returns:
the offset within the binary region (the "haystack") at which the specified byte (the "needle") was found, or -1 if the specified byte does not occur within the binary region
Since:
Coherence 3.5

memchr

public static int memchr(byte[] abHaystack,
                         int ofHaystack,
                         int cbHaystack,
                         byte bNeedle,
                         boolean fBackwards)
Find the specified byte (a "needle") in the specified binary region ("the haystack").
Parameters:
abHaystack - the byte array containing the binary region to search within (the "haystack")
ofHaystack - the offset of the binary region within abHaystack
cbHaystack - the size in bytes of the binary region within abHaystack
bNeedle - the byte to search for (a "needle")
fBackwards - pass false to find the first occurrance, or true to find the last occurrence
Returns:
the offset within the binary region (the "haystack") at which the specified byte (the "needle") was found, or -1 if the specified byte does not occur within the binary region
Since:
Coherence 3.5

memmem

public static int memmem(byte[] abHaystack,
                         int ofHaystack,
                         int cbHaystack,
                         byte[] abNeedle,
                         int ofNeedle,
                         int cbNeedle)
Find the second binary region (a "needle") in the first binary region ("the haystack").
Parameters:
abHaystack - the byte array containing the binary region to search within (the "haystack")
ofHaystack - the offset of the binary region within abHaystack
cbHaystack - the size in bytes of the binary region within abHaystack
abNeedle - the byte array containing the binary region to search for (a "needle")
ofNeedle - the offset of the binary region within abNeedle
cbNeedle - the size in bytes of the binary region within abNeedle
Returns:
the offset within the first binary region (the "haystack") at which the second binary region (the "needle") was found, or -1 if the second binary region does not occur within the first
Since:
Coherence 3.5

memmem

public static int memmem(byte[] abHaystack,
                         int ofHaystack,
                         int cbHaystack,
                         byte[] abNeedle,
                         int ofNeedle,
                         int cbNeedle,
                         boolean fBackwards)
Find the second binary region (a "needle") in the first binary region ("the haystack").
Parameters:
abHaystack - the byte array containing the binary region to search within (the "haystack")
ofHaystack - the offset of the binary region within abHaystack
cbHaystack - the size in bytes of the binary region within abHaystack
abNeedle - the byte array containing the binary region to search for (a "needle")
ofNeedle - the offset of the binary region within abNeedle
cbNeedle - the size in bytes of the binary region within abNeedle
fBackwards - pass false to find the first occurrance, or true to find the last occurrence
Returns:
the offset within the first binary region (the "haystack") at which the second binary region (the "needle") was found, or -1 if the second binary region does not occur within the first
Since:
Coherence 3.5

memcmp

public static int memcmp(byte[] ab1,
                         int of1,
                         int cb1,
                         byte[] ab2,
                         int of2,
                         int cb2)
Compare two binary regions.
Parameters:
ab1 - the byte array containing the first binary region to compare
of1 - the offset of the binary region within ab1
cb1 - the size in bytes of the binary region within ab1
ab2 - the byte array containing the second binary region to compare
of2 - the offset of the binary region within ab2
cb2 - the size in bytes of the binary region within ab2
Returns:
a value less than zero, zero or greater than zero if the first binary region is "less than," "equal to" or "greater than" the second binary region
Since:
Coherence 3.5

memcpy

public static void memcpy(byte[] abSrc,
                          int ofSrc,
                          byte[] abDest,
                          int ofDest,
                          int cbCopy)
Copy binary data from one binary region to another. This is safe for copying a region from an array to itelf, even if the regions are overlapping; as such, it is equivalent to both memmov() and memcpy(). The implementation uses the arraycopy() method of the System class; the only difference between this method and the raw arraycopy() is that this method is typed and decorates any exception with debugging information about the arguments that caused the exception.
Parameters:
abSrc - the byte array containing the binary region to copy from
ofSrc - the offset of the binary region within abSrc
abDest - the byte array containing the binary region to copy to
ofDest - the offset of the binary region within abDest
cbCopy - the size in bytes of the binary region to copy
Since:
Coherence 3.5

equals

public static boolean equals(byte[] ab1,
                             int of1,
                             byte[] ab2,
                             int of2,
                             int cb)
Compare two binary regions, testing for equality.
Parameters:
ab1 - the byte array containing the first binary region to compare
of1 - the offset of the binary region within ab1
ab2 - the byte array containing the second binary region to compare
of2 - the offset of the binary region within ab2
cb - the size of the binary regions, which is the number of bytes to compare
Returns:
true iff the two specified binary regions are identical
Since:
Coherence 3.5

clone

public static byte[] clone(byte[] ab,
                           int of,
                           int cb)
Create a clone of the specified binary region.
Parameters:
ab - the byte array containing the binary region to copy from
of - the offset of the binary region within ab
cb - the size in bytes of the binary region to copy
Returns:
a copy of the specified binary region
Since:
Coherence 3.5

toString

public static java.lang.String toString(byte[] ab)
For debugging purposes, convert the passed byte array into a string that contains the information regarding whether the reference is null, and if it is not null, what the length of the byte array is.
Parameters:
ab - a byte array; may be null
Returns:
a String; never null
Since:
Coherence 3.5

Skip navigation links

Oracle® Coherence Java API Reference
v3.5.1

E15583-01


Copyright © 2000, 2009, Oracle. All rights reserved.