org.jfree.data
Class DefaultKeyedValues
java.lang.Object
org.jfree.data.DefaultKeyedValues
- Cloneable, KeyedValues, PublicCloneable, Serializable, Values
extends java.lang.Object
implements KeyedValues, Cloneable, PublicCloneable, Serializable
An ordered list of (key, value) items. This class provides a default
implementation of the
KeyedValues
interface.
void | addValue(Comparable key, Number value) - Adds a new value to the collection, or updates an existing value.
|
void | addValue(Comparable key, double value) - Updates an existing value, or adds a new value to the collection.
|
void | clear() - Clears all values from the collection.
|
Object | clone() - Returns a clone.
|
boolean | equals(Object obj) - Tests if this object is equal to another.
|
int | getIndex(Comparable key) - Returns the index for a given key.
|
int | getItemCount() - Returns the number of items (values) in the collection.
|
Comparable | getKey(int index) - Returns a key.
|
List | getKeys() - Returns the keys for the values in the collection.
|
Number | getValue(Comparable key) - Returns the value for a given key.
|
Number | getValue(int item) - Returns a value.
|
int | hashCode() - Returns a hash code.
|
void | removeValue(Comparable key) - Removes a value from the collection.
|
void | removeValue(int index) - Removes a value from the collection.
|
void | setValue(Comparable key, Number value) - Updates an existing value, or adds a new value to the collection.
|
void | setValue(Comparable key, double value) - Updates an existing value, or adds a new value to the collection.
|
void | sortByKeys(SortOrder order) - Sorts the items in the list by key.
|
void | sortByValues(SortOrder order) - Sorts the items in the list by value.
|
addValue
public void addValue(Comparable key,
Number value)
Adds a new value to the collection, or updates an existing value.
This method passes control directly to the
setValue(Comparable,Number)
method.
key
- the key (null
not permitted).value
- the value (null
permitted).
addValue
public void addValue(Comparable key,
double value)
Updates an existing value, or adds a new value to the collection.
key
- the key (null
not permitted).value
- the value.
clear
public void clear()
Clears all values from the collection.
clone
public Object clone()
throws CloneNotSupportedException
Returns a clone.
equals
public boolean equals(Object obj)
Tests if this object is equal to another.
obj
- the object (null
permitted).
getIndex
public int getIndex(Comparable key)
Returns the index for a given key.
- getIndex in interface KeyedValues
key
- the key (null
not permitted).
- The index, or
-1
if the key is not recognised.
getKey
public Comparable getKey(int index)
Returns a key.
- getKey in interface KeyedValues
index
- the item index (zero-based).
getValue
public Number getValue(Comparable key)
Returns the value for a given key.
- getValue in interface KeyedValues
- The value (possibly
null
).
getValue
public Number getValue(int item)
Returns a value.
- getValue in interface Values
item
- the item of interest (zero-based index).
hashCode
public int hashCode()
Returns a hash code.
removeValue
public void removeValue(Comparable key)
Removes a value from the collection. If there is no item with the
specified key, this method does nothing.
key
- the item key (null
not permitted).
removeValue
public void removeValue(int index)
Removes a value from the collection.
index
- the index of the item to remove (in the range
0
to getItemCount() - 1
).
setValue
public void setValue(Comparable key,
Number value)
Updates an existing value, or adds a new value to the collection.
key
- the key (null
not permitted).value
- the value (null
permitted).
setValue
public void setValue(Comparable key,
double value)
Updates an existing value, or adds a new value to the collection.
key
- the key (null
not permitted).value
- the value.
sortByKeys
public void sortByKeys(SortOrder order)
Sorts the items in the list by key.
order
- the sort order (null
not permitted).
sortByValues
public void sortByValues(SortOrder order)
Sorts the items in the list by value. If the list contains
null
values, they will sort to the end of the list,
irrespective of the sort order.
order
- the sort order (null
not permitted).