org.jfree.data
Class KeyedObjects
java.lang.Object
org.jfree.data.KeyedObjects
- Cloneable, PublicCloneable, Serializable
extends java.lang.Object
implements Cloneable, PublicCloneable, Serializable
A collection of (key, object) pairs.
void | addObject(Comparable key, Object object) - Adds a new object to the collection, or overwrites an existing object.
|
Object | clone() - Returns a clone of this object.
|
boolean | equals(Object o) - 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.
|
Object | getObject(Comparable key) - Returns the object for a given key.
|
Object | getObject(int item) - Returns an object.
|
void | removeValue(Comparable key) - Removes a value from the collection.
|
void | removeValue(int index) - Removes a value from the collection.
|
void | setObject(Comparable key, Object object) - Replaces an existing object, or adds a new object to the collection.
|
KeyedObjects
public KeyedObjects()
Creates a new collection (initially empty).
addObject
public void addObject(Comparable key,
Object object)
key
- the key.object
- the object.
clone
public Object clone()
throws CloneNotSupportedException
Returns a clone of this object.
equals
public boolean equals(Object o)
Tests if this object is equal to another.
getIndex
public int getIndex(Comparable key)
Returns the index for a given key.
- The index, or
-1
if the key is unrecognised.
getItemCount
public int getItemCount()
Returns the number of items (values) in the collection.
getKey
public Comparable getKey(int index)
Returns a key.
index
- the item index (zero-based).
getKeys
public List getKeys()
Returns the keys.
getObject
public Object getObject(Comparable key)
Returns the object for a given key. If the key is not recognised, the
method should return null
.
- The object (possibly
null
).
getObject
public Object getObject(int item)
Returns an object.
item
- the item index (zero-based).
- The object (
null
if the index is out of range).
removeValue
public void removeValue(Comparable key)
Removes a value from the collection.
key
- the key of the item to remove.
removeValue
public void removeValue(int index)
Removes a value from the collection.
index
- the index of the item to remove.
setObject
public void setObject(Comparable key,
Object object)
key
- the key.object
- the object.