org.opengroup.arm40.transaction
public interface ArmToken extends ArmInterface
ArmToken
expresses the common part of the above interfaces.
It is abstract in the sense that any ArmToken
object
returned by any method in this specification satisfies one of the
subclass interfaces. Objects of these identify particular entities.
These objects contain a byte array data token, plus optionally other
identifying data, which together comprise the value of the object.
The data token is always immutable. Subclasses of ArmToken
can be thought of as wrappers around the data token.
To make it possible to compare the values of these tokens, and to
use these tokens as hashkeys (so that the user can associate data with
a particular token), this specification requires that any
class implementing any of these types override the methods
java.lang.Object#equals(java.lang.Object) and
java.lang.Object#hashCode().
The behavior of these methods must be the following.
a.equals(b)
returns true
if the
ArmToken objects a
and b
have the
same value (internal data is byte-for-byte identical in two objects).
That is, a.equals(b)
is true if and only if:
-
a
and b
implement the same interface
ArmCorrelator
, ArmSystemAddress
,
or ArmID
.
-
a.getBytes()
and b.getBytes()
would return
byte arrays of identical lengths and contents.
-
If a subclass of
ArmToken
defines other data values
(specifically, ArmSystemAddress
defines a short field
named format
), these other data values are all identical.
If a.equals(b)==true
, a.hashCode()
and
b.hashCode()
will return the same value. The
hashCode()
value is implementation-defined. In other words,
hashcode values are not necessarily portable. A hashcode generated on
one system by one implementation may not equal a hashcode value generated
on another system by a different implementation, even if
a.equals(b)==true
.
Method Summary | |
---|---|
boolean | copyBytes(byte[] dest)
Copies the token to a byte array that is already allocated.
|
boolean | copyBytes(byte[] dest, int offset)
Copies the token to a byte array that is already allocated.
|
byte[] | getBytes()
Returns a newly allocated byte array into which the token is copied.
|
int | getLength()
Gets the length of the byte array part. |
Parameters: dest destination byte array. Its length must be greater than or equal to the length of the token's byte array.
Returns: true
if the operation was successful,
false
otherwise. If false
, the contents of
the target array are undetermined. The most likely errors are an
attempt to copy into a null pointer or into an array that is not
long enough to hold the entire token.
Parameters: dest destination byte array. (dest.length-offset)
must be greater than or equal to the length of the token's byte array.
offset offset in dest
to copying at.
Returns: true
if the operation was successful,
false
otherwise. If false
, the contents of
the target array are undetermined. The most likely errors are an
attempt to copy into a null pointer or into an array that is not
long enough to hold the entire token.
getLength()
and then executing copyBytes()
into the new array. The ARM implementation would typically not keep
a reference to the array, because that would interfere with garbage
collection.
Returns: a byte array containing a copy of the token's byte array part.
Returns: the size of the byte array part of the token.