Package org.jfree.data
Class KeyedObjects
java.lang.Object
org.jfree.data.KeyedObjects
- All Implemented Interfaces:
Serializable,Cloneable,org.jfree.util.PublicCloneable
public class KeyedObjects extends Object implements Cloneable, org.jfree.util.PublicCloneable, Serializable
A collection of (key, object) pairs.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description KeyedObjects()Creates a new collection (initially empty). -
Method Summary
Modifier and Type Method Description voidaddObject(Comparable key, Object object)Adds a new object to the collection, or overwrites an existing object.Objectclone()Returns a clone of this object.booleanequals(Object o)Tests if this object is equal to another.intgetIndex(Comparable key)Returns the index for a given key.intgetItemCount()Returns the number of items (values) in the collection.ComparablegetKey(int index)Returns a key.ListgetKeys()Returns the keys.ObjectgetObject(int item)Returns an object.ObjectgetObject(Comparable key)Returns the object for a given key.voidremoveValue(int index)Removes a value from the collection.voidremoveValue(Comparable key)Removes a value from the collection.voidsetObject(Comparable key, Object object)Replaces an existing object, or adds a new object to the collection.
-
Constructor Details
-
KeyedObjects
public KeyedObjects()Creates a new collection (initially empty).
-
-
Method Details
-
getItemCount
public int getItemCount()Returns the number of items (values) in the collection.- Returns:
- the item count.
-
getObject
Returns an object.- Parameters:
item- the item index (zero-based).- Returns:
- The object (
nullif the index is out of range).
-
getKey
Returns a key.- Parameters:
index- the item index (zero-based).- Returns:
- the row key.
-
getIndex
Returns the index for a given key.- Parameters:
key- the key.- Returns:
- the index.
-
getKeys
Returns the keys.- Returns:
- the keys.
-
getObject
Returns the object for a given key. If the key is not recognised, the method should returnnull.- Parameters:
key- the key.- Returns:
- The object (possibly
null).
-
addObject
Adds a new object to the collection, or overwrites an existing object.This is the same as the setObject(...) method.
- Parameters:
key- the key.object- the object.
-
setObject
Replaces an existing object, or adds a new object to the collection.This is the same as the addObject(...) method.
- Parameters:
key- the key.object- the object.
-
removeValue
public void removeValue(int index)Removes a value from the collection.- Parameters:
index- the index of the item to remove.
-
removeValue
Removes a value from the collection.- Parameters:
key- the key of the item to remove.
-
clone
Returns a clone of this object.- Specified by:
clonein interfaceorg.jfree.util.PublicCloneable- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if there is a problem cloning.
-
equals
Tests if this object is equal to another.
-