1 21 22 package org.apache.derby.iapi.store.access; 23 24 25 42 43 public abstract class GlobalXact { 44 45 49 protected int format_id; 50 protected byte[] global_id; 51 protected byte[] branch_id; 52 53 public boolean equals(Object other) 54 { 55 if (other == this) 56 return true; 57 58 if (other instanceof GlobalXact) { 59 60 GlobalXact other_xact = (GlobalXact) other; 61 62 return( 63 java.util.Arrays.equals( 64 other_xact.global_id, 65 this.global_id) && 66 java.util.Arrays.equals( 67 other_xact.branch_id, 68 this.branch_id) && 69 other_xact.format_id == this.format_id); 70 71 } 72 73 return false; 74 } 75 76 public String toString() 77 { 78 String globalhex = ""; 79 String branchhex = ""; 80 if (global_id != null) 81 { 82 int mask = 0; 83 for (int i = 0; i < global_id.length; i++) 84 { 85 mask = (global_id[i] & 0xFF); 86 globalhex += Integer.toHexString(mask); 87 } 88 } 89 90 if (branch_id != null) 91 { 92 int mask = 0; 93 for (int i = 0; i < branch_id.length; i++) 94 { 95 mask = (branch_id[i] & 0xFF); 96 branchhex += Integer.toHexString(mask); 97 } 98 } 99 100 return("(" + format_id + "," + globalhex + "," + branchhex + ")"); 101 102 } 103 104 105 110 public int hashCode() 111 { 112 int hash = global_id.length + branch_id.length + (format_id & 0xFFFFFFF); 115 116 for (int i = 0; i < global_id.length; i++) 117 { 118 hash += global_id[i]; 119 } 120 for (int i = 0; i < branch_id.length; i++) 121 { 122 hash += branch_id[i]; 123 } 124 125 return(hash); 126 } 127 128 } 129 130 131 132 | Popular Tags |