Class Binary
- All Implemented Interfaces:
ExternalizableLite
,ReadBuffer
,ByteSequence
,HashEncoded
,Externalizable
,Serializable
,Cloneable
,Comparable
- Author:
- cp 2002.01.25
- See Also:
-
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 class com.tangosol.util.Base
Base.LoggingWriter
Nested classes/interfaces inherited from interface com.tangosol.io.ReadBuffer
ReadBuffer.BufferInput
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Binary
An empty Binary.static final Binary
A Binary representation ofBoolean.FALSE
value.static final Binary
A Binary representation ofBoolean.TRUE
value.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
Fields inherited from class com.tangosol.util.Base
LOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
Fields inherited from interface com.tangosol.util.HashEncoded
UNENCODED
-
Constructor Summary
ConstructorDescriptionBinary()
Default constructor for 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.Construct a Binary object from a Binary object.Binary
(ByteArrayOutputStream stream) Construct a Binary object from the contents of a ByteArrayOutputStream.Construct a binary object from a DataInput interface. -
Method Summary
Modifier and TypeMethodDescriptionint
calculateNaturalPartition
(int cPartitions) Calculate the partition ID to which the specified Binary should be naturally assigned.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
Compares this object with the specified object for order.Concatenate the passed Binary onto this Binary.boolean
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
Compares this Binary object with another object for equality.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.int
Returns the offset within this Binary object of the first occurrence of the specified Binary.int
Returns the offset within this Binary object of the first occurrence of the specified Binary, 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
Determine if the underlying byte[] should be treated as private data.static Binary
Join an array of Binaries into a single Binary.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.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.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").static Binary
readBinary
(DataInput input) Read a Binary from the specified DataInput.static Binary
Read a Binary from the specified DataInputStream.static Binary
readBinary
(File file) Read a Binary from the specified File.static Binary
Read a Binary from the specified InputStream.static Binary
readBinary
(InputStream in, int cb) Read a Binary from the specified InputStream.static Binary
readBinary
(URL url) Read a Binary from the specified URL.static Binary
readBinary
(FileChannel channel, long of, int cb, byte[] ab2) Read a Binary of the specified length at the specified offset from the specified FileChannel.void
Restore the contents of this object by loading the object's state from the passed DataInput object.void
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.replace
(byte bOld, byte bNew) Replace all occurrences of one specified byte with another in this Binary object.Replace all occurrences of one specified Binary with another in this Binary object.replaceRegion
(int of, int cb, Binary binNew) Replace a region within this Binary with another 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.Binary[]
split
(int nSize) Split a Binary into an array of Binaries each of which does not exceed the specified size.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.toBinary()
Return a new Binary object that holds the complete contents of this ReadBuffer.toBinary
(int of, int cb) Return a Binary object that holds the specified portion of this ReadBuffer.toString()
Provide a human-readable representation of the Binary object.static 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
(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.static void
writeExternal
(DataOutput out, ReadBuffer buf) Write the contents of the specified ReadBuffer to the specified DataOutput stream in a format that can be restored as a Binary viareadExternal(java.io.ObjectInput)
void
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.Methods inherited from class com.tangosol.io.AbstractByteArrayReadBuffer
byteAt, copyBytes, instantiateBufferInput, length, resetRange, toByteArray, toByteBuffer, toByteBuffer, writeTo, writeTo, writeTo, writeTo, writeTo, writeTo
Methods inherited from class com.tangosol.io.AbstractReadBuffer
checkBounds, getBufferInput, getEncodedHash, getReadBuffer, readPackedInt, readUnsignedByte, sizeofPackedInt, subSequence, toByteArray
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Field Details
-
EMPTY
An empty Binary. -
TRUE
A Binary representation ofBoolean.TRUE
value. -
FALSE
A Binary representation ofBoolean.FALSE
value.
-
-
Constructor Details
-
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 bytesof
- the offset into the byte arraycb
- the number of bytes to extract
-
Binary
Construct a Binary object from a Binary object.- Parameters:
that
- another Binary object- See Also:
-
Binary
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
Construct a binary object from a DataInput interface.- Parameters:
stream
- the object implementing DataInput from which this Binary object will load its data- Throws:
IOException
- if an I/O error occurs reading the Binary
-
-
Method Details
-
regionMatches
Tests if two Binary regions are equal.- Parameters:
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 objectthat
cb
- the number of bytes to compare- Returns:
true
if the specified subregion of this Binary object exactly matches the specified subregion of thethat
Binary object;false
otherwise- Throws:
NullPointerException
- ifthat
isnull
- See Also:
-
startsWith
Tests if this Binary object starts with the specified prefix beginning a specified offset.- Parameters:
bin
- the prefixofFrom
- the offset to begin looking in this Binary object- Returns:
true
if the byte sequence represented by thebin
argument is a prefix of the substring of this Binary object starting at offsetofFrom
;false
otherwise- Throws:
NullPointerException
- ifbin
isnull
.- See Also:
-
startsWith
Tests if this Binary object starts with the specified prefix.- Parameters:
bin
- the prefix- Returns:
true
if the byte sequence represented by thebin
argument is a prefix of this Binary object;false
otherwise- Throws:
NullPointerException
- ifbin
isnull
.- See Also:
-
endsWith
Tests if this Binary object ends with the specified suffix.- Parameters:
bin
- the suffix- Returns:
true
if the byte sequence represented by thebin
argument is a suffix of this Binary object;false
otherwise- Throws:
NullPointerException
- ifbin
isnull
.- See Also:
-
indexOf
public int indexOf(byte b) Returns the offset within this Binary object of the first occurrence of the specified byte.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:
-
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.This method is identical in its functionality to the corresponding method in String.
- Parameters:
b
- the byte to search forofFrom
- 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:
-
indexOf
Returns the offset within this Binary object of the first occurrence of the specified Binary.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:
- 3.5
- See Also:
-
indexOf
Returns the offset within this Binary object of the first occurrence of the specified Binary, starting the search at the specified offset.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 forofFrom
- 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:
- 3.5
- See Also:
-
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.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:
-
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.This method is identical in its functionality to the corresponding method in String.
- Parameters:
b
- the byte to search forofFrom
- 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:
-
lastIndexOf
Returns the offset within this Binary object of the last occurrence of the specified Binary.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:
- 3.5
- See Also:
-
lastIndexOf
Returns the offset within this Binary object of the last occurrence of the specified Binary, starting the search at the specified offset.This method is identical in its functionality to the corresponding method in String.
- Parameters:
bin
- the Binary to search forofFrom
- 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:
- 3.5
- See Also:
-
replace
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 replacebNew
- 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
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 replacebinNew
- 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
Replace a region within this Binary with another Binary.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 Binarycb
- the length of the range to replace in bytesbinNew
- 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:
- 3.5
-
concat
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:
- 3.5
-
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:
- 3.5
-
split
Split a Binary into an array of Binaries each of which does not exceed the specified size.- Parameters:
nSize
- the size of result Binaries- Returns:
- an array of Binaries
- Since:
- 12.2.1.4
-
toBinary
Return a new Binary object that holds the complete contents of this ReadBuffer.This is the equivalent of
toBinary(0, length())
.- Specified by:
toBinary
in interfaceByteSequence
- Specified by:
toBinary
in interfaceReadBuffer
- Overrides:
toBinary
in classAbstractByteArrayReadBuffer
- Returns:
- the contents of this ReadBuffer as a Binary object
-
toBinary
Return a Binary object that holds the specified portion of this ReadBuffer.This method is an equivalent of
getReadBuffer(of, cb).toBinary()
.- Specified by:
toBinary
in interfaceReadBuffer
- Overrides:
toBinary
in classAbstractByteArrayReadBuffer
- Parameters:
of
- the beginning index, inclusivecb
- the number of bytes to include in the Binary object- Returns:
- a Binary object containing the specified portion of this ReadBuffer
-
instantiateReadBuffer
Factory method: Instantiate a ReadBuffer for a portion of this ReadBuffer.- Specified by:
instantiateReadBuffer
in classAbstractReadBuffer
- Parameters:
of
- the beginning index, inclusivecb
- 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 classAbstractByteArrayReadBuffer
- Returns:
- true iff the underlying data should not ever be exposed by this object
-
clone
Create a clone of this Binary object.- Specified by:
clone
in interfaceReadBuffer
- Overrides:
clone
in classAbstractReadBuffer
- Returns:
- a Binary object with the same contents as this Binary object
-
toString
Provide a human-readable representation of the 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.The Binary object uses a CRC32 algorithm to determine the hash code.
-
equals
Compares this Binary object with another object for equality.- Specified by:
equals
in interfaceReadBuffer
- Overrides:
equals
in classAbstractByteArrayReadBuffer
- 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
-
calculateNaturalPartition
public int calculateNaturalPartition(int cPartitions) Calculate the partition ID to which the specified Binary should be naturally assigned. This calculation should not be applied to Binary objectsdecorated
with artificially assigned partitions.The resulting partition ID will be in the range [0..cPartitions).
Note: if the specified partition count is zero, this method will return a hash code fo the binary, thus allowing clients that don't have a concept of partitioning or knowledge of the partition count to defer the partition id calculation until the partition count is known.
- Parameters:
cPartitions
- the partition count- Returns:
- the partition that the this Binary is naturally assigned to or a natural hash code if the partition count is not specified
-
compareTo
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 interfaceComparable
- 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:
ClassCastException
- if the specified object's type prevents it from being compared to this ObjectNullPointerException
- if the specified object isnull
-
readExternal
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 interfaceExternalizable
- Parameters:
in
- the stream to read data from in order to restore the object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
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 interfaceExternalizable
- Parameters:
out
- the stream to write the object to- Throws:
IOException
- if an I/O exception occurs
-
readExternal
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in interfaceExternalizableLite
- Parameters:
in
- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
Write the contents of the specified ReadBuffer to the specified DataOutput stream in a format that can be restored as a Binary viareadExternal(java.io.ObjectInput)
- Parameters:
out
- the DataOutput stream to write tobuf
- the ReadBuffer to write the contents of- Throws:
IOException
- if an I/O exception occurs
-
getInputStream
Get an InputStream to read the Binary object's contents from.- Returns:
- an InputStream backed by this Binary object
-
readBinary
public static Binary readBinary(FileChannel channel, long of, int cb, byte[] ab2) throws IOException Read a Binary of the specified length at the specified offset from the specified FileChannel.- Parameters:
channel
- the FileChannel to read fromof
- the offset within the FileChannel to read fromcb
- the number of bytes to read from the FileChannel, which will be the length of the Binaryab2
- reserved; pass in null- Returns:
- a Binary containing the specified sequence of bytes from the channel
- Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
readBinary
Read a Binary from the specified InputStream.- Parameters:
in
- the InputStream to read from- Returns:
- a Binary containing all the bytes from the specified InputStream
- Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
readBinary
Read a Binary from the specified InputStream.- Parameters:
in
- the InputStream to read fromcb
- the exact number of bytes to read from the stream- Returns:
- a Binary containing
cb
bytes - Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
readBinary
Read a Binary from the specified File.- Parameters:
file
- the File to read from- Returns:
- a Binary containing all the bytes from the specified file
- Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
readBinary
Read a Binary from the specified URL.- Parameters:
url
- the URL to read from- Returns:
- a Binary containing all the bytes from the specified URL
- Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
readBinary
Read a Binary from the specified DataInput.- Parameters:
input
- the DataInput to read from- Returns:
- a Binary containing all the bytes from the specified DataInput
- Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
readBinary
Read a Binary from the specified DataInputStream.- Parameters:
in
- the DataInputStream to read from- Returns:
- a Binary containing all the bytes from the specified DataInputStream
- Throws:
IOException
- if an I/O exception or unexpected EOF occurs
-
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 abHaystackcbHaystack
- the size in bytes of the binary region within abHaystackbNeedle
- 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:
- 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 abHaystackcbHaystack
- the size in bytes of the binary region within abHaystackbNeedle
- the byte to search for (a "needle")fBackwards
- pass false to find the first occurrence, 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:
- 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 abHaystackcbHaystack
- the size in bytes of the binary region within abHaystackabNeedle
- the byte array containing the binary region to search for (a "needle")ofNeedle
- the offset of the binary region within abNeedlecbNeedle
- 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:
- 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 abHaystackcbHaystack
- the size in bytes of the binary region within abHaystackabNeedle
- the byte array containing the binary region to search for (a "needle")ofNeedle
- the offset of the binary region within abNeedlecbNeedle
- the size in bytes of the binary region within abNeedlefBackwards
- pass false to find the first occurrence, 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:
- 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 compareof1
- the offset of the binary region within ab1cb1
- the size in bytes of the binary region within ab1ab2
- the byte array containing the second binary region to compareof2
- the offset of the binary region within ab2cb2
- 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:
- 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 itself, 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 fromofSrc
- the offset of the binary region within abSrcabDest
- the byte array containing the binary region to copy toofDest
- the offset of the binary region within abDestcbCopy
- the size in bytes of the binary region to copy- Since:
- 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 compareof1
- the offset of the binary region within ab1ab2
- the byte array containing the second binary region to compareof2
- the offset of the binary region within ab2cb
- 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:
- 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 fromof
- the offset of the binary region within abcb
- the size in bytes of the binary region to copy- Returns:
- a copy of the specified binary region
- Since:
- 3.5
-
toString
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:
- 3.5
-
join
Join an array of Binaries into a single Binary.- Parameters:
aBinaries
- an array of Binaries to join- Since:
- 12.2.1.4
-