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
Object.equals(java.lang.Object) and
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.| Modifier and Type | Method and Description |
|---|---|
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.
|
getErrorCode, getErrorMessage, setErrorCodeboolean copyBytes(byte[] dest)
dest - destination byte array. Its length must be greater
than or equal to the length of the token's byte array.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.boolean copyBytes(byte[] dest,
int offset)
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.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.byte[] getBytes()
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.int getLength()