org.arm4.arm40.transaction
Class ArmToken

java.lang.Object
  extended by org.arm4.arm40.transaction.ArmInterface
      extended by org.arm4.arm40.transaction.ArmToken
All Implemented Interfaces:
ArmInterface, ArmToken
Direct Known Subclasses:
ArmCorrelator, ArmID, ArmSystemAddress

public class ArmToken
extends ArmInterface
implements ArmToken

The ARM Token can be used as an identifer for a transaction using a set of given bytes. These bytes can be coupled with metadata from a transaction to provide an identification scheme for business transactions.

Version:
$Revision$ $Date$
Author:
dcarter

Field Summary
protected static int HASHKEY_MAX
           
protected  int m_hashkey
           
protected  boolean m_hashkeyGenerated
           
protected  byte[] m_tokenData
           
 
Fields inherited from class org.arm4.arm40.transaction.ArmInterface
m_errorCode, m_factory
 
Constructor Summary
ArmToken(byte[] dataBytes, int offset)
          Create an ARM Token.
ArmToken(byte[] dataBytes, int offset, int length)
          Create an ARM Token.
 
Method Summary
protected  boolean compare(byte[] reference)
          compare two ARM Tokens.
 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.
protected  byte getByte(int offset)
          Get a byte at the offset.
 byte[] getBytes()
          Returns a newly allocated byte array into which the token is copied.
 int getLength()
          Gets the length of the byte array part.
 int hashCode()
           
 
Methods inherited from class org.arm4.arm40.transaction.ArmInterface
getErrorCode, getErrorMessage, getFactory, setErrorCode, setFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opengroup.arm40.transaction.ArmInterface
getErrorCode, getErrorMessage, setErrorCode
 

Field Detail

m_tokenData

protected byte[] m_tokenData

m_hashkey

protected int m_hashkey

m_hashkeyGenerated

protected boolean m_hashkeyGenerated

HASHKEY_MAX

protected static final int HASHKEY_MAX
See Also:
Constant Field Values
Constructor Detail

ArmToken

public ArmToken(byte[] dataBytes,
                int offset)
Create an ARM Token.

Parameters:
dataBytes -
offset -

ArmToken

public ArmToken(byte[] dataBytes,
                int offset,
                int length)
Create an ARM Token.

Parameters:
dataBytes -
offset -
length -
Method Detail

copyBytes

public boolean copyBytes(byte[] dest)
Description copied from interface: ArmToken
Copies the token to a byte array that is already allocated.

Specified by:
copyBytes in interface ArmToken
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)
Description copied from interface: ArmToken
Copies the token to a byte array that is already allocated.

Specified by:
copyBytes in interface ArmToken
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()
Description copied from interface: ArmToken
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.

Specified by:
getBytes in interface ArmToken
Returns:
a byte array containing a copy of the token's byte array part.

getLength

public int getLength()
Description copied from interface: ArmToken
Gets the length of the byte array part.

Specified by:
getLength in interface ArmToken
Returns:
the size of the byte array part of the token.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compare

protected boolean compare(byte[] reference)
compare two ARM Tokens.

Parameters:
reference -
Returns:

getByte

protected byte getByte(int offset)
Get a byte at the offset.

Parameters:
offset -
Returns: