tyrex.tm.xid
Class XidUtils

java.lang.Object
  extended bytyrex.tm.xid.XidUtils

public final class XidUtils
extends java.lang.Object

Utility class for creating transaction identifiers, importing Xid objects, and converting a transaction identifier to/from a string representation.

Version:
$Revision: 1.2 $
Author:
Assaf Arkin

Field Summary
protected static byte[] EMPTY_ARRAY
          The default branch is always an empty byte array.
static int FORMAT_ID
          Format identifier for all internal Xids or newly created Xids.
protected static char[] HEX_DIGITS
          Efficient mapping from 4 bit value to lower case hexadecimal digit.
static java.lang.String XID_PREFIX
          Prefix for textual identifier.
 
Constructor Summary
XidUtils()
           
 
Method Summary
static javax.transaction.xa.Xid importXid(int formatId, byte[] global, byte[] branch)
          Imports a transaction identifier.
static javax.transaction.xa.Xid importXid(javax.transaction.xa.Xid xid)
          Imports a transaction identifier.
static boolean isBranch(javax.transaction.xa.Xid xid)
          Returns true if the transaction identifier represents a branch transaction.
static boolean isGlobal(javax.transaction.xa.Xid xid)
          Returns true if the transaction identifier represents a global transaction.
static boolean isLocal(javax.transaction.xa.Xid xid)
          Returns true if the transaction identifier represents a local transaction.
static javax.transaction.xa.Xid newBranch(javax.transaction.xa.Xid xid)
          Creates a new transaction branch.
static javax.transaction.xa.Xid newGlobal()
          Create a new global transaction identifier.
static javax.transaction.xa.Xid newLocal()
          Create a new local transaction identifier.
static javax.transaction.xa.Xid parse(java.lang.String identifier)
          Constructs a transaction identifier from a string representation.
static java.lang.String toString(javax.transaction.xa.Xid xid)
          Converts an Xid into a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XID_PREFIX

public static final java.lang.String XID_PREFIX
Prefix for textual identifier.

See Also:
Constant Field Values

FORMAT_ID

public static final int FORMAT_ID
Format identifier for all internal Xids or newly created Xids.

See Also:
Constant Field Values

EMPTY_ARRAY

protected static final byte[] EMPTY_ARRAY
The default branch is always an empty byte array.


HEX_DIGITS

protected static final char[] HEX_DIGITS
Efficient mapping from 4 bit value to lower case hexadecimal digit.

Constructor Detail

XidUtils

public XidUtils()
Method Detail

newLocal

public static javax.transaction.xa.Xid newLocal()
Create a new local transaction identifier.

Returns:
A new local transaction identifier

newGlobal

public static javax.transaction.xa.Xid newGlobal()
Create a new global transaction identifier.

Returns:
A new global transaction identifier

importXid

public static javax.transaction.xa.Xid importXid(javax.transaction.xa.Xid xid)
Imports a transaction identifier. Returns a equivalent transaction identifier that can be converted to/from a string representation and supports the equality test.

Parameters:
xid - An existing transaction identifier
Returns:
An equivalent transaction identifier

importXid

public static javax.transaction.xa.Xid importXid(int formatId,
                                                 byte[] global,
                                                 byte[] branch)
Imports a transaction identifier. Returns a equivalent transaction identifier that can be converted to/from a string representation and supports the equality test.

Parameters:
formatId - The format identifier
global - The global transaction identifier
branch - The branch qualifier
Returns:
An equivalent transaction identifier

newBranch

public static javax.transaction.xa.Xid newBranch(javax.transaction.xa.Xid xid)
Creates a new transaction branch. Returns a transaction identifier that uses the same format identiier and global transaction identifier but includes a new branch qualifier.

Parameters:
xid - An existing transaction identifier
Returns:
A new branch for that transaction

isLocal

public static boolean isLocal(javax.transaction.xa.Xid xid)
Returns true if the transaction identifier represents a local transaction. A local transaction has no global transaction identifier.

Parameters:
xid - A transaction identifier
Returns:
True if a local transaction

isGlobal

public static boolean isGlobal(javax.transaction.xa.Xid xid)
Returns true if the transaction identifier represents a global transaction. A global transaction must have a global transaction identifier.

Parameters:
xid - A transaction identifier
Returns:
True if a global transaction

isBranch

public static boolean isBranch(javax.transaction.xa.Xid xid)
Returns true if the transaction identifier represents a branch transaction. A branch transaction must have a branch qualifier.

Parameters:
xid - A transaction identifier
Returns:
True if a branch transaction

toString

public static java.lang.String toString(javax.transaction.xa.Xid xid)
Converts an Xid into a string representation.

Parameters:
xid - A transaction identifier
Returns:
The string representation

parse

public static javax.transaction.xa.Xid parse(java.lang.String identifier)
                                      throws InvalidXidException
Constructs a transaction identifier from a string representation. The identifier syntax is xid:-[][-]. An exception is thrown if the identifier does not match this format.

Parameters:
identifier - The transaction identifier
Throws:
InvalidXidException - The indentifier is invalid


Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.