Source for org.jfree.data.KeyedValues

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
   6:  *
   7:  * Project Info:  http://www.jfree.org/jfreechart/index.html
   8:  *
   9:  * This library is free software; you can redistribute it and/or modify it 
  10:  * under the terms of the GNU Lesser General Public License as published by 
  11:  * the Free Software Foundation; either version 2.1 of the License, or 
  12:  * (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but 
  15:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  16:  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
  17:  * License for more details.
  18:  *
  19:  * You should have received a copy of the GNU Lesser General Public
  20:  * License along with this library; if not, write to the Free Software
  21:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
  22:  * USA.  
  23:  *
  24:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  *
  27:  * ----------------
  28:  * KeyedValues.java
  29:  * ----------------
  30:  * (C) Copyright 2002-2007, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * Changes:
  36:  * --------
  37:  * 23-Oct-2002 : Version 1 (DG);
  38:  * 12-Jan-2005 : Updated Javadocs to specify new behaviour when key
  39:  *               is not recognised (DG);
  40:  * ------------- JFREECHART 1.0.0 ---------------------------------------------
  41:  * 02-May-2006 : Updated API docs (DG);
  42:  *
  43:  */
  44: 
  45: package org.jfree.data;
  46: 
  47: import java.util.List;
  48: 
  49: /**
  50:  * An ordered list of (key, value) items where the keys are unique and 
  51:  * non-<code>null</code>.
  52:  *
  53:  * @see Values
  54:  * @see DefaultKeyedValues
  55:  */
  56: public interface KeyedValues extends Values {
  57: 
  58:     /**
  59:      * Returns the key associated with the item at a given position.  Note 
  60:      * that some implementations allow re-ordering of the data items, so the
  61:      * result may be transient.
  62:      *
  63:      * @param index  the item index (in the range <code>0</code> to 
  64:      *     <code>getItemCount() - 1</code>).
  65:      *
  66:      * @return The key (never <code>null</code>).
  67:      * 
  68:      * @throws IndexOutOfBoundsException if <code>index</code> is not in the 
  69:      *     specified range.
  70:      */
  71:     public Comparable getKey(int index);
  72: 
  73:     /**
  74:      * Returns the index for a given key.
  75:      *
  76:      * @param key  the key (<code>null</code> not permitted).
  77:      *
  78:      * @return The index, or <code>-1</code> if the key is unrecognised.
  79:      * 
  80:      * @throws IllegalArgumentException if <code>key</code> is 
  81:      *     <code>null</code>.
  82:      */
  83:     public int getIndex(Comparable key);
  84: 
  85:     /**
  86:      * Returns the keys for the values in the collection.  Note that you can 
  87:      * access the values in this collection by key or by index.  For this 
  88:      * reason, the key order is important - this method should return the keys
  89:      * in order.  The returned list may be unmodifiable.
  90:      *
  91:      * @return The keys (never <code>null</code>).
  92:      */
  93:     public List getKeys();
  94: 
  95:     /**
  96:      * Returns the value for a given key.
  97:      *
  98:      * @param key  the key.
  99:      *
 100:      * @return The value (possibly <code>null</code>).
 101:      * 
 102:      * @throws UnknownKeyException if the key is not recognised.
 103:      */
 104:     public Number getValue(Comparable key);
 105: 
 106: }