org.apache.qpid.dtx
Class XidImpl

java.lang.Object
  extended by org.apache.qpid.dtx.XidImpl
All Implemented Interfaces:
Xid

public class XidImpl
extends Object
implements Xid

Implements javax.transaction.dtx.Xid


Field Summary
 
Fields inherited from interface javax.transaction.xa.Xid
MAXBQUALSIZE, MAXGTRIDSIZE
 
Constructor Summary
XidImpl()
          Create new Xid.
XidImpl(byte[] branchQualifier, int format, byte[] globalTransactionID)
          Create a new Xid.
XidImpl(String xid)
          Create a new Xid form its String form 4 1 1 g b +---+---+---+---+---+---+---+- -+---+---+- -+---+ | format_id | g | b | txn-id | br-id | +---+---+---+---+---+---+---+- -+---+---+- -+---+ 0 4 5 6 6+g 6+g+b format_id: an implementation specific format identifier

gtrid_length: how many bytes of this form the transaction id

bqual_length: how many bytes of this form the branch id

data: a sequence of octets of at most 128 bytes containing the txn id and the branch id

Note - The sum of the two lengths must equal the length of the data field.

XidImpl(Xid xid)
          Create a new XidImpl from an existing Xid.
 
Method Summary
static Xid convert(Xid xid)
          Convert an Xid into the AMQP String format.
 boolean equals(Object o)
          Indicates whether some other Xid is "equal to" this one.
 byte[] getBranchQualifier()
          Obtain the transaction branch identifier part of XID as an array of bytes.
 int getFormatId()
          Obtain the format identifier part of the XID.
 byte[] getGlobalTransactionId()
          Format identifier.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XidImpl

public XidImpl()
Create new Xid. this is an empty constructor.


XidImpl

public XidImpl(Xid xid)
Create a new XidImpl from an existing Xid.

Usefull for casting external Xids

Parameters:
xid - Foreign Xid.

XidImpl

public XidImpl(byte[] branchQualifier,
               int format,
               byte[] globalTransactionID)
Create a new Xid.

Parameters:
branchQualifier - The transaction branch identifier part of XID as an array of bytes.
format - The format identifier part of the XID.
globalTransactionID - The global transaction identifier part of XID as an array of bytes.

XidImpl

public XidImpl(String xid)
        throws AMQInvalidArgumentException
Create a new Xid form its String form 4 1 1 g b +---+---+---+---+---+---+---+- -+---+---+- -+---+ | format_id | g | b | txn-id | br-id | +---+---+---+---+---+---+---+- -+---+---+- -+---+ 0 4 5 6 6+g 6+g+b format_id: an implementation specific format identifier

gtrid_length: how many bytes of this form the transaction id

bqual_length: how many bytes of this form the branch id

data: a sequence of octets of at most 128 bytes containing the txn id and the branch id

Note - The sum of the two lengths must equal the length of the data field.

Parameters:
xid - an XID STring Form
Throws:
AMQInvalidArgumentException - If the string does not represent a valid Xid
Method Detail

getGlobalTransactionId

public byte[] getGlobalTransactionId()
Format identifier. O means the OSI CCR format.

Specified by:
getGlobalTransactionId in interface Xid
Returns:
Global transaction identifier.

getBranchQualifier

public byte[] getBranchQualifier()
Obtain the transaction branch identifier part of XID as an array of bytes.

Specified by:
getBranchQualifier in interface Xid
Returns:
Branch identifier part of XID.

getFormatId

public int getFormatId()
Obtain the format identifier part of the XID.

Specified by:
getFormatId in interface Xid
Returns:
Format identifier. O means the OSI CCR format.

equals

public boolean equals(Object o)
Indicates whether some other Xid is "equal to" this one.

Two Xids are equal if and only if their three elementary parts are equal

Overrides:
equals in class Object
Parameters:
o - the object to compare this XidImpl against.
Returns:
true if the XidImpl are equal, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

convert

public static Xid convert(Xid xid)
Convert an Xid into the AMQP String format. 4 1 1 g b +---+---+---+---+---+---+---+- -+---+---+- -+---+ | format_id | g | b | txn-id | br-id | +---+---+---+---+---+---+---+- -+---+---+- -+---+ 0 4 5 6 6+g 6+g+b format_id: an implementation specific format identifier

gtrid_length: how many bytes of this form the transaction id

bqual_length: how many bytes of this form the branch id

data: a sequence of octets of at most 128 bytes containing the txn id and the branch id

Note - The sum of the two lengths must equal the length of the data field.

Parameters:
xid - an Xid to convert.
Returns:
The String representation of this Xid


Licensed to the Apache Software Foundation