01: /**********************************************************************
02: Copyright (c) 2007 Erik Bengtson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: ...
17: **********************************************************************/package org.jpox.transaction;
18:
19: public class XidImpl implements javax.transaction.xa.Xid {
20: byte[] branchQualifierBytes;
21: int formatId;
22: byte[] globalTransactionIdBytes;
23:
24: public XidImpl(int branchQualifierBytes, int formatId,
25: byte[] globalTransactionIdBytes) {
26: byte[] buf = new byte[4];
27: buf[0] = (byte) ((branchQualifierBytes >>> 24) & 0xFF);
28: buf[1] = (byte) ((branchQualifierBytes >>> 16) & 0xFF);
29: buf[2] = (byte) ((branchQualifierBytes >>> 8) & 0xFF);
30: buf[3] = (byte) (branchQualifierBytes & 0xFF);
31: this .branchQualifierBytes = buf;
32: this .formatId = formatId;
33: this .globalTransactionIdBytes = globalTransactionIdBytes;
34: }
35:
36: public XidImpl(int branchQualifierBytes, int formatId,
37: int globalTransactionIdBytes) {
38: byte[] buf = new byte[4];
39: buf[0] = (byte) ((branchQualifierBytes >>> 24) & 0xFF);
40: buf[1] = (byte) ((branchQualifierBytes >>> 16) & 0xFF);
41: buf[2] = (byte) ((branchQualifierBytes >>> 8) & 0xFF);
42: buf[3] = (byte) (branchQualifierBytes & 0xFF);
43: this .branchQualifierBytes = buf;
44: this .formatId = formatId;
45: buf = new byte[4];
46: buf[0] = (byte) ((globalTransactionIdBytes >>> 24) & 0xFF);
47: buf[1] = (byte) ((globalTransactionIdBytes >>> 16) & 0xFF);
48: buf[2] = (byte) ((globalTransactionIdBytes >>> 8) & 0xFF);
49: buf[3] = (byte) (globalTransactionIdBytes & 0xFF);
50: this .globalTransactionIdBytes = buf;
51: }
52:
53: public byte[] getBranchQualifier() {
54: return branchQualifierBytes;
55: }
56:
57: public int getFormatId() {
58: return formatId;
59: }
60:
61: public byte[] getGlobalTransactionId() {
62: return globalTransactionIdBytes;
63: }
64:
65: public String toString() {
66: return "Xid=" + new String(globalTransactionIdBytes);
67: }
68: }
|