Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| # Header And More
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jfree.data
Class DefaultKeyedValues

    java.lang.Object
      org.jfree.data.DefaultKeyedValues

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, KeyedValues, Values, org.jfree.util.PublicCloneable

    public class DefaultKeyedValues

extends java.lang.Object
implements KeyedValues, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable

An ordered list of (key, value) items. This class provides a default implementation of the `KeyedValues` interface.

See Also:
  Serialized Form

Constructor Summary
`DefaultKeyedValues()` Creates a new collection (initially empty).

Method Summary
`void` | `addValue(java.lang.Comparable key, double value)` Updates an existing value, or adds a new value to the collection.
`void` | `addValue(java.lang.Comparable key, java.lang.Number value)` Adds a new value to the collection, or updates an existing value.
`void` | `clear()` Clears all values from the collection.
`java.lang.Object` | `clone()` Returns a clone.
`boolean` | `equals(java.lang.Object obj)` Tests if this object is equal to another.
`int` | `getIndex(java.lang.Comparable key)` Returns the index for a given key.
`int` | `getItemCount()` Returns the number of items (values) in the collection.
`java.lang.Comparable` | `getKey(int index)` Returns a key.
`java.util.List` | `getKeys()` Returns the keys for the values in the collection.
`java.lang.Number` | `getValue(java.lang.Comparable key)` Returns the value for a given key.
`java.lang.Number` | `getValue(int item)` Returns a value.
`int` | `hashCode()` Returns a hash code.
`void` | `insertValue(int position, java.lang.Comparable key, double 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` | `insertValue(int position, java.lang.Comparable key, java.lang.Number 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` | `setValue(java.lang.Comparable key, double value)` Updates an existing value, or adds a new value to the collection.
`void` | `setValue(java.lang.Comparable key, java.lang.Number value)` Updates an existing value, or adds a new value to the collection.
`void` | `sortByKeys(org.jfree.util.SortOrder order)` Sorts the items in the list by key.
`void` | `sortByValues(org.jfree.util.SortOrder order)` Sorts the items in the list by value.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultKeyedValues

    public DefaultKeyedValues()

  Creates a new collection (initially empty).

Method Detail

### getItemCount

    public int getItemCount()

  Returns the number of items (values) in the collection.

  Specified by:
    `getItemCount` in interface `Values`
  Returns:
    The item count.

### getValue

    public java.lang.Number getValue(int item)

  Returns a value.

  Specified by:
    `getValue` in interface `Values`
  Parameters:
    `item` - the item of interest (zero-based index).
  Returns:
    The value (possibly `null`).
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `item` is out of bounds.

### getKey

    public java.lang.Comparable getKey(int index)

  Returns a key.

  Specified by:
    `getKey` in interface `KeyedValues`
  Parameters:
    `index` - the item index (zero-based).
  Returns:
    The row key.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `item` is out of bounds.

### getIndex

    public int getIndex(java.lang.Comparable key)

  Returns the index for a given key.

  Specified by:
    `getIndex` in interface `KeyedValues`
  Parameters:
    `key` - the key (`null` not permitted).
  Returns:
    The index, or `-1` if the key is not recognised.
  Throws:
    `java.lang.IllegalArgumentException` - if `key` is `null`.

### getKeys

    public java.util.List getKeys()

  Returns the keys for the values in the collection.

  Specified by:
    `getKeys` in interface `KeyedValues`
  Returns:
    The keys (never `null`).

### getValue

    public java.lang.Number getValue(java.lang.Comparable key)

  Returns the value for a given key.

  Specified by:
    `getValue` in interface `KeyedValues`
  Parameters:
    `key` - the key (`null` not permitted).
  Returns:
    The value (possibly `null`).
  Throws:
    `UnknownKeyException` - if the key is not recognised.
  See Also:
    `getValue(int)`

### addValue

    public void addValue(java.lang.Comparable key,
                         double value)

  Updates an existing value, or adds a new value to the collection.

  Parameters:
    `key` - the key (`null` not permitted).
    `value` - the value.
  See Also:
    `addValue(Comparable, Number)`

### addValue

    public void addValue(java.lang.Comparable key,
                         java.lang.Number value)

  Adds a new value to the collection, or updates an existing value. This method passes control directly to the `setValue(Comparable, Number)` method.

  Parameters:
    `key` - the key (`null` not permitted).
    `value` - the value (`null` permitted).

### setValue

    public void setValue(java.lang.Comparable key,
                         double value)

  Updates an existing value, or adds a new value to the collection.

  Parameters:
    `key` - the key (`null` not permitted).
    `value` - the value.

### setValue

    public void setValue(java.lang.Comparable key,
                         java.lang.Number value)

  Updates an existing value, or adds a new value to the collection.

  Parameters:
    `key` - the key (`null` not permitted).
    `value` - the value (`null` permitted).

### insertValue

    public void insertValue(int position,
                            java.lang.Comparable key,
                            double 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.

  Parameters:
    `position` - the position (in the range 0 to getItemCount()).
    `key` - the key (`null` not permitted).
    `value` - the value.
  Since:
    1.0.6

### insertValue

    public void insertValue(int position,
                            java.lang.Comparable key,
                            java.lang.Number 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.

  Parameters:
    `position` - the position (in the range 0 to getItemCount()).
    `key` - the key (`null` not permitted).
    `value` - the value (`null` permitted).
  Since:
    1.0.6

### removeValue

    public void removeValue(int index)

  Removes a value from the collection.

  Parameters:
    `index` - the index of the item to remove (in the range `0` to `getItemCount() - 1`).
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `index` is not within the specified range.

### removeValue

    public void removeValue(java.lang.Comparable key)

  Removes a value from the collection.

  Parameters:
    `key` - the item key (`null` not permitted).
  Throws:
    `java.lang.IllegalArgumentException` - if `key` is `null`.
    `UnknownKeyException` - if `key` is not recognised.

### clear

    public void clear()

  Clears all values from the collection.

  Since:
    1.0.2

### sortByKeys

    public void sortByKeys(org.jfree.util.SortOrder order)

  Sorts the items in the list by key.

  Parameters:
    `order` - the sort order (`null` not permitted).

### sortByValues

    public void sortByValues(org.jfree.util.SortOrder order)

  Sorts the items in the list by value. If the list contains `null` values, they will sort to the end of the list, irrespective of the sort order.

  Parameters:
    `order` - the sort order (`null` not permitted).

### equals

    public boolean equals(java.lang.Object obj)

  Tests if this object is equal to another.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - the object (`null` permitted).
  Returns:
    A boolean.

### hashCode

    public int hashCode()

  Returns a hash code.

  Overrides:
    `hashCode` in class `java.lang.Object`
  Returns:
    A hash code.

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Returns a clone.

  Specified by:
    `clone` in interface `org.jfree.util.PublicCloneable`
  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    A clone.
  Throws:
    `java.lang.CloneNotSupportedException` - this class will not throw this exception, but subclasses might.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| # Footer And More
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.