public class KeyedObjects extends java.lang.Object implements java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable
Constructor and Description |
---|
KeyedObjects()
Creates a new collection (initially empty).
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(java.lang.Comparable key,
java.lang.Object object)
Adds a new object to the collection, or overwrites an existing object.
|
void |
clear()
Clears all values from the collection.
|
java.lang.Object |
clone()
Returns a clone of this object.
|
boolean |
equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.
|
int |
getIndex(java.lang.Comparable key)
Returns the index for a given key, or
-1 . |
int |
getItemCount()
Returns the number of items (values) in the collection.
|
java.lang.Comparable |
getKey(int index)
Returns the key at the specified position in the list.
|
java.util.List |
getKeys()
Returns a list containing all the keys in the list.
|
java.lang.Object |
getObject(java.lang.Comparable key)
Returns the object for a given key.
|
java.lang.Object |
getObject(int item)
Returns an object from the list.
|
int |
hashCode()
Returns a hash code.
|
void |
insertValue(int position,
java.lang.Comparable key,
java.lang.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(java.lang.Comparable key)
Removes a value from the collection.
|
void |
removeValue(int index)
Removes a value from the collection.
|
void |
setObject(java.lang.Comparable key,
java.lang.Object object)
Replaces an existing object, or adds a new object to the collection.
|
public KeyedObjects()
public int getItemCount()
public java.lang.Object getObject(int item)
item
- the item index (zero-based).null
).java.lang.IndexOutOfBoundsException
- if item
is out of bounds.public java.lang.Comparable getKey(int index)
index
- the item index (zero-based).java.lang.IndexOutOfBoundsException
- if item
is out of bounds.getIndex(Comparable)
public int getIndex(java.lang.Comparable key)
-1
.key
- the key (null
not permitted).-1
if the key is unrecognised.getKey(int)
public java.util.List getKeys()
null
).public java.lang.Object getObject(java.lang.Comparable key)
null
.key
- the key.null
).addObject(Comparable, Object)
public void addObject(java.lang.Comparable key, java.lang.Object object)
setObject(Comparable, Object)
method.key
- the key.object
- the object.getObject(Comparable)
public void setObject(java.lang.Comparable key, java.lang.Object object)
addObject(Comparable, Object)
method.key
- the key (null
not permitted).object
- the object.getObject(Comparable)
public void insertValue(int position, java.lang.Comparable key, java.lang.Object value)
position
- the position (in the range 0
to
getItemCount()
).key
- the key (null
not permitted).value
- the value (null
permitted).public void removeValue(int index)
index
- the index of the item to remove.removeValue(Comparable)
public void removeValue(java.lang.Comparable key)
key
- the key (null
not permitted).UnknownKeyException
- if the key is not recognised.removeValue(int)
public void clear()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
PublicCloneable
.clone
in interface org.jfree.util.PublicCloneable
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if there is a problem cloning.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object (null
permitted).public int hashCode()
hashCode
in class java.lang.Object