1 6 7 package com.jofti.btree; 8 9 16 class IndexNodeEntry implements NodeEntry { 17 18 21 private static final long serialVersionUID = 6905415196213618087L; 22 23 private Node childNode = null; 24 private Node containingNode = null; 25 Comparable value=null; 26 27 private volatile int hashCode =0; 28 29 30 31 IndexNodeEntry() { 32 } 33 34 35 36 void updateValue(){ 37 this.value = childNode.getRightValue(); 38 } 39 40 41 45 Node getChildNode() { 46 return childNode; 47 } 48 49 53 void setChildNode(Node childNode) { 54 this.childNode = childNode; 55 } 56 57 58 62 Node getContainingNode() { 63 return containingNode; 64 } 65 66 70 void setContainingNode(Node containingNode) { 71 this.containingNode = containingNode; 72 } 73 74 112 public int compareTo(Object o) 113 { 114 115 return value.compareTo(((IndexNodeEntry)o).value); 116 117 } 118 119 122 public boolean equals(Object o) 123 { 124 if (o instanceof IndexNodeEntry) 125 { 126 return compareTo((IndexNodeEntry)o) == 0; 127 } else { 128 return false; 129 } 130 } 131 132 133 136 public int hashCode(){ 137 if (hashCode ==0){ 138 int result = 17; 139 result = 37*result + value.hashCode(); 140 hashCode = result; 141 } 142 return hashCode; 143 } 144 145 148 public String toString() { 149 StringBuffer buf = new StringBuffer (); 150 buf.append(" Value:" + value); 151 buf.append(" ChildNode:" + childNode); 152 return buf.toString(); 153 } 154 155 156 157 158 159 160 161 164 public Comparable getValue() 165 { 166 return value; 167 } 168 169 170 171 172 173 174 175 178 public void setValue(Comparable value) 179 { 180 this.value = value; 181 182 } 183 184 } 185 | Popular Tags |