Package org.jfree.data
Interface KeyedValues<K extends java.lang.Comparable<K>>
-
- Type Parameters:
K
- the key type (String
is a good default).
- All Superinterfaces:
Values
- All Known Subinterfaces:
KeyedValuesDataset
,PieDataset<K>
- All Known Implementing Classes:
CategoryToPieDataset
,DefaultKeyedValues
,DefaultKeyedValuesDataset
,DefaultPieDataset
,JDBCPieDataset
public interface KeyedValues<K extends java.lang.Comparable<K>> extends Values
An ordered list of (key, value) items where the keys are unique and non-null
.- See Also:
Values
,DefaultKeyedValues
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getIndex(K key)
Returns the index for a given key.K
getKey(int index)
Returns the key associated with the item at a given position.java.util.List<K>
getKeys()
Returns the keys for the values in the collection.java.lang.Number
getValue(K key)
Returns the value for a given key.-
Methods inherited from interface org.jfree.data.Values
getItemCount, getValue
-
-
-
-
Method Detail
-
getKey
K getKey(int index)
Returns the key associated with the item at a given position. Note that some implementations allow re-ordering of the data items, so the result may be transient.- Parameters:
index
- the item index (in the range0
togetItemCount() - 1
).- Returns:
- The key (never
null
). - Throws:
java.lang.IndexOutOfBoundsException
- ifindex
is not in the specified range.
-
getIndex
int getIndex(K key)
Returns the index for a given key.- Parameters:
key
- the key (null
not permitted).- Returns:
- The index, or
-1
if the key is unrecognised. - Throws:
java.lang.IllegalArgumentException
- ifkey
isnull
.
-
getKeys
java.util.List<K> getKeys()
Returns the keys for the values in the collection. Note that you can access the values in this collection by key or by index. For this reason, the key order is important - this method should return the keys in order. The returned list may be unmodifiable.- Returns:
- The keys (never
null
).
-
getValue
java.lang.Number getValue(K key)
Returns the value for a given key.- Parameters:
key
- the key.- Returns:
- The value (possibly
null
). - Throws:
UnknownKeyException
- if the key is not recognised.
-
-