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.
|
void | clear() - Clears all values from the collection.
|
Object | clone() - Returns a clone of this object.
|
boolean | equals(Object obj) - Tests this object for equality with an arbitrary object.
|
int | getIndex(Comparable key) - Returns the index for a given key, or
-1 .
|
int | getItemCount() - Returns the number of items (values) in the collection.
|
Comparable | getKey(int index) - Returns the key at the specified position in the list.
|
List | getKeys() - Returns a list containing all the keys in the list.
|
Object | getObject(Comparable key) - Returns the object for a given key.
|
Object | getObject(int item) - Returns an object from the list.
|
int | hashCode() - Returns a hash code.
|
void | insertValue(int position, Comparable key, Object 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 | 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.
clear
public void clear()
Clears all values from the collection.
clone
public Object clone()
throws CloneNotSupportedException
Returns a clone of this object. Keys in the list should be immutable
and are not cloned. Objects in the list are cloned only if they
implement PublicCloneable
.
equals
public boolean equals(Object obj)
Tests this object for equality with an arbitrary object.
obj
- the object (null
permitted).
getIndex
public int getIndex(Comparable key)
Returns the index for a given key, or -1
.
key
- the key (null
not permitted).
- 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 the key at the specified position in the list.
index
- the item index (zero-based).
getKeys
public List getKeys()
Returns a list containing all the keys in the list.
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 from the list.
item
- the item index (zero-based).
- The object (possibly
null
).
hashCode
public int hashCode()
Returns a hash code.
insertValue
public void insertValue(int position,
Comparable key,
Object 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.
position
- the position (in the range 0
to
getItemCount()
).key
- the key (null
not permitted).value
- the value (null
permitted).
removeValue
public void removeValue(Comparable key)
Removes a value from the collection.
key
- the key (null
not permitted).
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 (null
not permitted).object
- the object.