Package oracle.jdbc.xa

## Class OracleXid

- java.lang.Object
- - oracle.jdbc.xa.OracleXid

All Implemented Interfaces:
  `java.io.Serializable`, `javax.transaction.xa.Xid`

    public class OracleXid
    extends java.lang.Object
    implements javax.transaction.xa.Xid, java.io.Serializable

The OracleXid class:

See Also:
  Serialized Form

### Field Summary

Fields
`static int` `MAXBQUALSIZE`
`static int` `MAXGTRIDSIZE`

### Constructor Summary

Constructors
`OracleXid​(int fId, byte[] gId, byte[] bId)` OracleXid() -- The constructor that constructs an OracleXid with given formatId, global transaction Id and branch qualifier.
`OracleXid​(int fId, byte[] gId, byte[] bId, byte[] context)` OracleXid() -- The constructor that constructs an OracleXid with given formatId, global transaction Id and branch qualifier, and transaction context.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `equals​(java.lang.Object xid)`
`byte[]` `getBranchQualifier()` getBranchQualifier() -- Obtain the txn branch qualifier of the XID
`protected oracle.jdbc.internal.OracleConnection` `getConnectionDuringExceptionHandling()` Compares the given transaction identifiers with this.
`int` `getFormatId()` getFormatId() -- Obtain the format identifier part of the Xid.
`byte[]` `getGlobalTransactionId()` getGlobalTransactionId() -- Obtain the global txn id of the XID
`int` `hashCode()`
`static boolean` `isLocalTransaction​(javax.transaction.xa.Xid xid)`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MAXGTRIDSIZE

    public static final int MAXGTRIDSIZE

See Also:
  Constant Field Values

#### MAXBQUALSIZE

    public static final int MAXBQUALSIZE

See Also:
  Constant Field Values

### Constructor Detail

#### OracleXid

    public OracleXid​(int fId,
                     byte[] gId,
                     byte[] bId)
              throws javax.transaction.xa.XAException

OracleXid() -- The constructor that constructs an OracleXid with given formatId, global transaction Id and branch qualifier.

Parameters:
  `fId` - format ID
  `gId` - global transaction ID (no copy performed)
  `bId` - branch Qualifier (no copy performed)
Throws:
  `javax.transaction.xa.XAException` - if the size of gId or bId is more than 64 bytes

#### OracleXid

    public OracleXid​(int fId,
                     byte[] gId,
                     byte[] bId,
                     byte[] context)
              throws javax.transaction.xa.XAException

OracleXid() -- The constructor that constructs an OracleXid with given formatId, global transaction Id and branch qualifier, and transaction context.

Parameters:
  `fId` - format ID
  `gId` - global transaction ID (no copy performed)
  `bId` - branch Qualifier (no copy performed)
  `context` - transaction context (no copy performed)
Throws:
  `javax.transaction.xa.XAException` - if the size of gId or bId is more than 64 bytes

### Method Detail

#### getFormatId

    public int getFormatId()

getFormatId() -- Obtain the format identifier part of the Xid.

Specified by:
  `getFormatId` in interface `javax.transaction.xa.Xid`
Returns:
  Format identifier. 0 means the OSI CCR format.

#### getGlobalTransactionId

    public byte[] getGlobalTransactionId()

getGlobalTransactionId() -- Obtain the global txn id of the XID

Specified by:
  `getGlobalTransactionId` in interface `javax.transaction.xa.Xid`
Returns:
  A byte array containing the global transaction identifier.

#### getBranchQualifier

    public byte[] getBranchQualifier()

getBranchQualifier() -- Obtain the txn branch qualifier of the XID

Specified by:
  `getBranchQualifier` in interface `javax.transaction.xa.Xid`
Returns:
  A byte array containing the branch qualifier of the transaction.

#### isLocalTransaction

    public static final boolean isLocalTransaction​(javax.transaction.xa.Xid xid)

#### equals

    public boolean equals​(java.lang.Object xid)

Overrides:
  `equals` in class `java.lang.Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`

#### getConnectionDuringExceptionHandling

    protected oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()

Compares the given transaction identifiers with this. If the format is different or any byte in the global transaction if or the branch qualifier differs from this, then false is returned. public boolean equals(Object obj) { if(obj==this) return true; OracleXid xid =null; try { xid = (OracleXid)obj; } catch(ClassCastException e){ return false; } if(formatId != xid.getFormatId()) return false; byte[] gtridB = xid.getGlobalTransactionId(); byte[] bqualB = xid.getBranchQualifier(); if(gtrid != gtridB){ if( (gtrid == null && gtridB != null) || (gtridB == null && gtrid != null) ) return false; if(gtridB!=null){ if(gtridB.length != gtrid.length) return false; for(int i=0;i<gtrid.length;i++){ if(gtridB[i] != gtrid[i]) return false; } } } if(bqual != bqualB){ if( ( bqualB == null && bqual != null) || (bqual == null && bqualB != null) ) return false; if(bqualB!=null){ if(bqualB.length != bqual.length) return false; for(int i=0;i<bqualB.length;i++){ if(bqualB[i] != bqual[i]) return false; } } } return true; } public int hashCode() { int ret = formatId; int temp = 0; for(int i=0;i<gtrid.length/4;i++){ temp = (int)gtrid[i] + ((int)(gtrid[i+1]<<8))&0xff00 + ((int)(gtrid[i+2]<<16))&0xff0000 + ((int)(gtrid[i+3]<<24))&0xff000000; ret += temp; } for(int i=0;i<bqual.length/4;i++){ temp = (int)bqual[i] + ((int)(bqual[i+1]<<8))&0xff00 + ((int)(bqual[i+2]<<16))&0xff0000 + ((int)(bqual[i+3]<<24))&0xff000000; ret += temp; } return ret; }</div>