EMMA Coverage Report (generated Tue Jul 25 07:27:46 CDT 2006)
[all classes][com.mysql.jdbc.jdbc2.optional]

COVERAGE SUMMARY FOR SOURCE FILE [MysqlXid.java]

nameclass, %method, %block, %line, %
MysqlXid.java100% (1/1)100% (6/6)93%  (124/134)85%  (29/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MysqlXid100% (1/1)100% (6/6)93%  (124/134)85%  (29/34)
equals (Object): boolean 100% (1/1)88%  (74/84)76%  (16/21)
MysqlXid (byte [], byte [], int): void 100% (1/1)100% (15/15)100% (6/6)
getBranchQualifier (): byte [] 100% (1/1)100% (3/3)100% (1/1)
getFormatId (): int 100% (1/1)100% (3/3)100% (1/1)
getGlobalTransactionId (): byte [] 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (26/26)100% (4/4)

1/*
2 Copyright (C) 2005 MySQL AB
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of version 2 of the GNU General Public License as 
6 published by the Free Software Foundation.
7 
8 There are special exceptions to the terms and conditions of the GPL 
9 as it is applied to this software. View the full text of the 
10 exception in file EXCEPTIONS-CONNECTOR-J in the directory of this 
11 software distribution.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 
22*/
23 
24package com.mysql.jdbc.jdbc2.optional;
25 
26import javax.transaction.xa.Xid;
27 
28/**
29 * Implementation of the XID interface for MySQL XA
30 * 
31 * @version $Id: $
32 */
33public class MysqlXid implements Xid {
34 
35        int hash = 0;
36 
37        byte[] myBqual;
38 
39        int myFormatId;
40 
41        byte[] myGtrid;
42 
43        public MysqlXid(byte[] gtrid, byte[] bqual, int formatId) {
44                this.myGtrid = gtrid;
45                this.myBqual = bqual;
46                this.myFormatId = formatId;
47        }
48 
49        public boolean equals(Object another) {
50 
51                if (another instanceof Xid) {
52                        Xid anotherAsXid = (Xid) another;
53 
54                        if (this.myFormatId != anotherAsXid.getFormatId()) {
55                                return false;
56                        }
57 
58                        byte[] otherBqual = anotherAsXid.getBranchQualifier();
59                        byte[] otherGtrid = anotherAsXid.getGlobalTransactionId();
60 
61                        if (otherGtrid != null && otherGtrid.length == this.myGtrid.length) {
62                                int length = otherGtrid.length;
63 
64                                for (int i = 0; i < length; i++) {
65                                        if (otherGtrid[i] != this.myGtrid[i]) {
66                                                return false;
67                                        }
68                                }
69 
70                                if (otherBqual != null && otherBqual.length == myBqual.length) {
71                                        length = otherBqual.length;
72 
73                                        for (int i = 0; i < length; i++) {
74                                                if (otherBqual[i] != this.myBqual[i]) {
75                                                        return false;
76                                                }
77                                        }
78                                } else {
79                                        return false;
80                                }
81 
82                                return true;
83                        } else {
84                                return false;
85                        }
86                } else {
87                        return false;
88                }
89        }
90 
91        public byte[] getBranchQualifier() {
92                return this.myBqual;
93        }
94 
95        public int getFormatId() {
96                return this.myFormatId;
97        };
98 
99        public byte[] getGlobalTransactionId() {
100                return this.myGtrid;
101        }
102 
103        public synchronized int hashCode() {
104                if (this.hash == 0) {
105                        for (int i = 0; i < this.myGtrid.length; i++) {
106                                this.hash = 33 * this.hash + this.myGtrid[i];
107                        }
108                }
109 
110                return this.hash;
111        }
112}

[all classes][com.mysql.jdbc.jdbc2.optional]
EMMA 2.0.4217 (C) Vladimir Roubtsov