public class

DefaultKeyedValues

extends Object
implements Serializable Cloneable KeyedValues
java.lang.Object
   ↳ org.jfree.data.DefaultKeyedValues

Class Overview

An ordered list of (key, value) items. This class provides a default implementation of the KeyedValues interface.

Summary

Public Constructors
DefaultKeyedValues()
Creates a new collection (initially empty).
Public Methods
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(int item)
Returns a value.
Number getValue(Comparable key)
Returns the value for a given key.
int hashCode()
Returns a hash code.
void insertValue(int position, Comparable key, double value)
Inserts a new value at the specified position in the dataset or, if there is an existing item with the specified key, updates the value for that item and moves it to the specified position.
void insertValue(int position, Comparable key, Number value)
Inserts a new value at the specified position in the dataset or, if there is an existing item with the specified key, updates the value for that item and moves it to the specified position.
void removeValue(Comparable key)
Removes a value from the collection.
void removeValue(int index)
Removes a value from the collection.
void setValue(Comparable key, double value)
Updates an existing value, or adds a new value to the collection.
void setValue(Comparable key, Number 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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.jfree.data.KeyedValues
From interface org.jfree.data.Values

Public Constructors

public DefaultKeyedValues ()

Creates a new collection (initially empty).

Public Methods

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.

Parameters
key the key (null not permitted).
value the value (null permitted).

public void addValue (Comparable key, double value)

Updates an existing value, or adds a new value to the collection.

Parameters
key the key (null not permitted).
value the value.

public void clear ()

Clears all values from the collection.

public Object clone ()

Returns a clone.

Returns
  • A clone.
Throws
CloneNotSupportedException this class will not throw this exception, but subclasses might.

public boolean equals (Object obj)

Tests if this object is equal to another.

Parameters
obj the object (null permitted).
Returns
  • A boolean.

public int getIndex (Comparable key)

Returns the index for a given key.

Parameters
key the key (null not permitted).
Returns
  • The index, or -1 if the key is not recognised.
Throws
IllegalArgumentException if key is null.

public int getItemCount ()

Returns the number of items (values) in the collection.

Returns
  • The item count.

public Comparable getKey (int index)

Returns a key.

Parameters
index the item index (zero-based).
Returns
  • The row key.
Throws
IndexOutOfBoundsException if item is out of bounds.

public List getKeys ()

Returns the keys for the values in the collection.

Returns
  • The keys (never null).

public Number getValue (int item)

Returns a value.

Parameters
item the item of interest (zero-based index).
Returns
  • The value (possibly null).
Throws
IndexOutOfBoundsException if item is out of bounds.

public Number getValue (Comparable key)

Returns the value for a given key.

Parameters
key the key (null not permitted).
Returns
  • The value (possibly null).
Throws
UnknownKeyException if the key is not recognised.
See Also

public int hashCode ()

Returns a hash code.

Returns
  • A hash code.

public void insertValue (int position, Comparable key, double value)

Inserts a new value at the specified position in the dataset or, if there is an existing item with the specified key, updates the value for that item and moves it to the specified position.

Parameters
position the position (in the range 0 to getItemCount()).
key the key (null not permitted).
value the value.

public void insertValue (int position, Comparable key, Number value)

Inserts a new value at the specified position in the dataset or, if there is an existing item with the specified key, updates the value for that item and moves it to the specified position.

Parameters
position the position (in the range 0 to getItemCount()).
key the key (null not permitted).
value the value (null permitted).

public void removeValue (Comparable key)

Removes a value from the collection.

Parameters
key the item key (null not permitted).
Throws
IllegalArgumentException if key is null.
UnknownKeyException if key is not recognised.

public void removeValue (int index)

Removes a value from the collection.

Parameters
index the index of the item to remove (in the range 0 to getItemCount() - 1).
Throws
IndexOutOfBoundsException if index is not within the specified range.

public void setValue (Comparable key, double value)

Updates an existing value, or adds a new value to the collection.

Parameters
key the key (null not permitted).
value the value.

public void setValue (Comparable key, Number value)

Updates an existing value, or adds a new value to the collection.

Parameters
key the key (null not permitted).
value the value (null permitted).

public void sortByKeys (SortOrder order)

Sorts the items in the list by key.

Parameters
order the sort order (null not permitted).

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.

Parameters
order the sort order (null not permitted).