Fields Summary |
---|
private int | formatIDThe format identifier for the XID. A value of -1 indicates
that the NULLXID. |
private int | gtrid_lengthThe number of bytes in the global transaction identfier |
private int | bqual_lengthThe number of bytes in the branch qualifier |
private byte[] | dataThe data for the XID.
The XID is made up of two contiguous parts. The first (of size
gtrid_length) is the global transaction identfier and the second
(of size bqual_length) is the branch qualifier.
If the formatID is -1, indicating the NULLXID,
the data is ignored. |
private byte[] | cachedBqual |
private byte[] | cachedGtrid |
private static final int | XIDDATASIZEThe size of data. |
public static final int | MAXGTRIDSIZEThe maximum size of the global transaction identifier. |
public static final int | MAXBQUALSIZEThe maximum size of the branch qualifier. |
private static final String | hextab |
static Logger | _logger |
Methods Summary |
---|
public void | copy(com.sun.jts.jtsxa.XID from)Initialize an XID using another XID as the source of data.
int i;
formatID = -1; // Default, null transaction
if (from == null) // If source is physically null
{
return; // Return the NULL transaction
}
if (from.formatID == (-1)) // If source is a NULL transaction
{
return; // Return the NULL transaction
}
gtrid_length= from.gtrid_length;
bqual_length= from.bqual_length;
if (data != null && from.data != null) {
System.arraycopy(from.data, 0, data, 0, XIDDATASIZE);
}
formatID= from.formatID; // Last, in case of failure
|
public void | copy(otid_t from)Initialize an XID using an omg otid_t as the source of data.
int i;
int L;
formatID= -1; // Default, null transaction
if (from == null) // If source is physically null
{
return; // Return the NULL transaction
}
if (from.formatID == (-1)) // If source is a NULL transaction
{
return; // Return the NULL transaction
}
L= from.tid.length;
gtrid_length= L - from.bqual_length;
bqual_length= from.bqual_length;
if (data != null && from.tid != null) {
System.arraycopy(from.tid, 0, data, 0, L);
}
formatID= from.formatID; // Last, in case of failure
|
public boolean | equals(java.lang.Object o)Determine whether or not two objects of this type are equal.
XID other; // The "other" XID
int L; // Combined gtrid_length + bqual_length
int i;
if (!(o instanceof XID)) // If the other XID isn't an XID
{
return false; // It can't be equal
}
other = (XID)o; // The other XID, now properly cast
if (formatID == (-1) && other.formatID == (-1))
{
return true;
}
if (formatID != other.formatID
||gtrid_length != other.gtrid_length
||bqual_length != other.bqual_length) {
return false;
}
L = gtrid_length + bqual_length;
for (i = 0; i < L; i++) {
if (data[i] != other.data[i]) {
return false;
}
}
return true;
|
public byte[] | getBranchQualifier()Returns the branch qualifier for this XID.
if (cachedBqual != null) {
return cachedBqual;
}
byte[] bqual = new byte[bqual_length];
System.arraycopy(data,gtrid_length,bqual,0,bqual_length);
return bqual;
|
public int | getFormatID()Obtain the format identifier part of the XID.
return formatID;
|
public int | getFormatId()
return getFormatID();
|
public byte[] | getGlobalTransactionId()
return getGlobalTransactionIdentifier();
|
public byte[] | getGlobalTransactionIdentifier()Returns the global transaction identifier for this XID.
if (cachedGtrid != null) {
return cachedGtrid;
}
byte[] gtrid = new byte[gtrid_length];
System.arraycopy(data, 0, gtrid, 0, gtrid_length);
cachedGtrid = gtrid;
return gtrid;
|
public int | hashCode()Compute the hash code.
if (formatID == (-1)) {
return (-1);
}
return formatID + gtrid_length - bqual_length;
|
public boolean | isEqualBranchQualifier(byte[] data)Compares the input parameter with the branch qualifier for equality.
int L = data.length > MAXBQUALSIZE?MAXBQUALSIZE:data.length;
int i;
if (L != bqual_length) {
return false;
}
for (i = 0; i < L; i++) {
if (data[i] != this.data[gtrid_length + i]) {
return false;
}
}
return true;
|
public boolean | isEqualGtrid(com.sun.jts.jtsxa.XID xid)Return whether the Gtrid of this is equal to the Gtrid of xid
if (this.gtrid_length != xid.gtrid_length) {
return false;
}
for (int i=0; i<gtrid_length; i++) {
if (this.data[i] != xid.data[i]) {
return false;
}
}
return true;
|
public void | setBranchQualifier(byte[] qual)Set the branch qualifier for this XID.
bqual_length = qual.length > MAXBQUALSIZE ? MAXBQUALSIZE : qual.length;
System.arraycopy(qual, 0, data, gtrid_length, bqual_length);
cachedBqual = qual;
|
public void | setFormatID(int formatID)Set the format identifier part of the XID.
this.formatID = formatID;
return;
|
public java.lang.String | toString()Return a string representing this XID.
/* toString() method is slightly expensive and this needs to be done because
* some of the drivers XAResource methods have the "trace("some thing " + xid)"
* kind of code which is executing this method resulting in performance degradation.
*/
if (_logger.isLoggable(Level.FINE)) {
StringBuffer d; // Data String, in Hexidecimal
String s; // Resultant String
int i;
int v;
int L;
L= gtrid_length + bqual_length;
d= new StringBuffer(L + L);
// Convert data string to hex
for (i = 0; i < L; i++) {
v = data[i] & 0xff;
d.append(hextab.charAt(v/16));
d.append(hextab.charAt(v&15));
if ((i+1) % 4 == 0 && (i+1) < L) {
d.append(" ");
}
}
s = new String("{XID: " +
"formatID(" + formatID + "), " +
"gtrid_length(" + gtrid_length + "), " +
"bqual_length(" + bqual_length + "), " +
"data(" + d + ")" +
"}"/*#Frozen*/);
return s;
}
else
return null;
|