public final class BinaryToken extends Object implements ScalarToken, Comparable<BinaryToken>
BinaryValued
object.Modifier and Type | Field and Description |
---|---|
static BinaryToken |
NULL
A null valued
BinaryToken |
static BinaryToken |
ZERO
A zero valued
BinaryToken |
static byte[] |
ZERO_VALUE
The byte array representing a zero value, the empty
byte[] . |
Constructor and Description |
---|
BinaryToken(BinaryValued value)
Constructs a new token with the binary
value in the given container.
|
BinaryToken(byte[] value)
Constructs a new token with the given
non-null binary value.
|
BinaryToken(String value)
Constructs a
BinaryToken with the non-null
binary value encoded by the given hexadecimal string. |
Modifier and Type | Method and Description |
---|---|
byte[] |
asBinary()
Gets the contained binary value.
|
byte[] |
asBinaryRef()
Gets a reference to the contained binary value.
|
int |
compareTo(BinaryToken that) |
boolean |
equals(Object obj)
Indicates whether another object is equal to this token.
|
ScalarTokenType |
getType()
Gets the data type of the token.
|
int |
hashCode()
Returns a hash code for the token.
|
boolean |
isNull()
Indicates whether the token is null valued.
|
boolean |
isZero()
Indicates whether the value is the zero value
for the type.
|
static BinaryToken |
parse(String value)
Converts a string representation of a binary value into
a token.
|
boolean |
represents(byte[] otherData)
A 'deep equals' comparison of this token's contents to the provided raw bytes.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getType, isZero
isNull
public static final BinaryToken NULL
BinaryToken
public static final byte[] ZERO_VALUE
byte[]
.public static final BinaryToken ZERO
BinaryToken
public BinaryToken(BinaryValued value)
value
- a BinaryValued
containing the
desired valuepublic BinaryToken(byte[] value)
NULL
.value
- the binary value of the token. A copy
of the array will be made.NullPointerException
- if the supplied array
is null
public BinaryToken(String value)
BinaryToken
with the non-null
binary value encoded by the given hexadecimal string.
If a null valued token is desired, use NULL
.value
- a hexadecimal string representing the
binary valueNullPointerException
- if the supplied hexadecimal
string is null
public int compareTo(BinaryToken that)
compareTo
in interface Comparable<BinaryToken>
public boolean equals(Object obj)
DataToken
TokenComparator.equal(TokenValued,TokenValued)
but makes it possible to store DataToken
s in Map
s.public boolean represents(byte[] otherData)
otherData
- the object that we're comparing topublic int hashCode()
DataToken
TokenConverter.asHashCode(TokenValued)
.public static BinaryToken parse(String value)
value
- a hexadecimal string representing a binary valuepublic final ScalarTokenType getType()
TokenValued
getType
in interface ScalarValued
getType
in interface TokenValued
getType
in interface ScalarTyped
getType
in interface TokenTyped
public final byte[] asBinary()
BinaryValued
The array returned is a copy of the binary data contained in
the object. To avoid this overhead, use BinaryValued.asBinaryRef()
instead.
asBinary
in interface BinaryValued
byte[]
. If
null valued, as indicated by TokenValued.isNull()
,
null
is returned.public final byte[] asBinaryRef()
BinaryValued
While this call avoids the overhead seen with BinaryValued.asBinary()
,
the caller must guarantee that the returned array will not be
modified. Failure to comply may result in the dataflow exhibiting
unexpected behavior, as other operators may (or may not)
see the modified value.
asBinaryRef
in interface BinaryValued
byte[]
holding the contained
value. If null valued, as indicated by TokenValued.isNull()
,
null
is returned.public final boolean isZero()
ScalarValued
isZero
in interface ScalarValued
true
if the value is the zero value,
false
otherwise.public final boolean isNull()
TokenValued
isNull
in interface TokenValued
true
if the token is null valued,
false
otherwiseCopyright © 2024 Actian Corporation. All rights reserved.