org.opengroup.arm40.transaction

Interface ArmToken

public interface ArmToken extends ArmInterface

An abstract interface serving as a superclass of ArmCorrelator, ArmSystemAddress, and ArmID.

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:

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.

Author: ARM Working Group of The Open Group

Method Summary
booleancopyBytes(byte[] dest)
Copies the token to a byte array that is already allocated.
booleancopyBytes(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.
intgetLength()
Gets the length of the byte array part.

Method Detail

copyBytes

public boolean copyBytes(byte[] dest)
Copies the token to a byte array that is already allocated.

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.

copyBytes

public boolean copyBytes(byte[] dest, int offset)
Copies the token to a byte array that is already allocated.

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.

getBytes

public byte[] getBytes()
Returns a newly allocated byte array into which the token is copied.

This is equivalent to creating a byte array of length 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.

getLength

public int getLength()
Gets the length of the byte array part.

Returns: the size of the byte array part of the token.