1 38 39 package org.jfree.data; 40 41 import java.io.Serializable ; 42 43 import org.jfree.util.ObjectUtils; 44 45 50 public class DefaultKeyedValueDataset extends AbstractDataset 51 implements KeyedValueDataset, Serializable { 52 53 54 private KeyedValue data; 55 56 59 public DefaultKeyedValueDataset() { 60 61 this(null); 62 63 } 64 65 71 public DefaultKeyedValueDataset(Comparable key, Number value) { 72 this(new DefaultKeyedValue(key, value)); 73 } 74 75 80 public DefaultKeyedValueDataset(KeyedValue data) { 81 82 this.data = data; 83 84 } 85 86 91 public Comparable getKey() { 92 return this.data.getKey(); 93 } 94 95 100 public Number getValue() { 101 return this.data.getValue(); 102 } 103 104 109 public void updateValue(Number value) { 110 if (this.data == null) { 111 throw new RuntimeException ("updateValue: can't update null."); 112 } 113 setValue(this.data.getKey(), value); 114 } 115 116 123 public void setValue(Comparable key, Number value) { 124 this.data = new DefaultKeyedValue(key, value); 125 notifyListeners(new DatasetChangeEvent(this, this)); 126 } 127 128 135 public boolean equals(Object obj) { 136 137 if (obj == null) { 138 return false; 139 } 140 141 if (obj == this) { 142 return true; 143 } 144 145 if (obj instanceof KeyedValueDataset) { 146 KeyedValueDataset kvd = (KeyedValueDataset) obj; 147 boolean b0 = ObjectUtils.equal(this.data.getKey(), kvd.getKey()); 148 boolean b1 = ObjectUtils.equal(this.data.getValue(), kvd.getValue()); 149 return b0 && b1; 150 } 151 152 return false; 153 } 154 155 163 public Object clone() throws CloneNotSupportedException { 164 DefaultKeyedValueDataset clone = (DefaultKeyedValueDataset) super.clone(); 165 return clone; 166 } 167 168 } 169 | Popular Tags |