1 2 17 18 19 package org.apache.poi.util; 20 21 class LocalTestNode 22 implements Comparable 23 { 24 private Comparable _key; 25 private Comparable _value; 26 27 32 33 LocalTestNode(final int key) 34 { 35 _key = new Integer (key); 36 _value = String.valueOf(key); 37 } 38 39 42 43 void setKey(Comparable key) 44 { 45 _key = key; 46 } 47 48 51 52 Comparable getKey() 53 { 54 return _key; 55 } 56 57 60 61 void setValue(Comparable value) 62 { 63 _value = value; 64 } 65 66 69 70 Comparable getValue() 71 { 72 return _value; 73 } 74 75 82 83 public int compareTo(Object o) 84 { 85 LocalTestNode other = ( LocalTestNode ) o; 86 int rval = getKey().compareTo(other.getKey()); 87 88 if (rval == 0) 89 { 90 rval = getValue().compareTo(other.getValue()); 91 } 92 return rval; 93 } 94 95 102 103 public boolean equals(Object o) 104 { 105 if (o == null) 106 { 107 return false; 108 } 109 if (!(o.getClass().equals(this.getClass()))) 110 { 111 return false; 112 } 113 LocalTestNode node = ( LocalTestNode ) o; 114 115 return (getKey().equals(node.getKey()) 116 && getValue().equals(node.getValue())); 117 } 118 119 122 123 public int hashCode() 124 { 125 return getKey().hashCode() ^ getValue().hashCode(); 126 } 127 } 128 | Popular Tags |