Source for org.jfree.data.KeyedValues

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2006, 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-2006, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: KeyedValues.java,v 1.3.2.3 2006/11/24 10:27:33 mungady Exp $
  36:  *
  37:  * Changes:
  38:  * --------
  39:  * 23-Oct-2002 : Version 1 (DG);
  40:  * 12-Jan-2005 : Updated Javadocs to specify new behaviour when key
  41:  *               is not recognised (DG);
  42:  * ------------- JFREECHART 1.0.0 ---------------------------------------------
  43:  * 02-May-2006 : Updated API docs (DG);
  44:  *
  45:  */
  46: 
  47: package org.jfree.data;
  48: 
  49: import java.util.List;
  50: 
  51: /**
  52:  * An ordered list of (key, value) items where the keys are unique and 
  53:  * non-<code>null</code>.
  54:  *
  55:  * @see Values
  56:  * @see DefaultKeyedValues
  57:  */
  58: public interface KeyedValues extends Values {
  59: 
  60:     /**
  61:      * Returns the key associated with the item at a given position.  Note 
  62:      * that some implementations allow re-ordering of the data items, so the
  63:      * result may be transient.
  64:      *
  65:      * @param index  the item index (in the range <code>0</code> to 
  66:      *     <code>getItemCount() - 1</code>).
  67:      *
  68:      * @return The key (never <code>null</code>).
  69:      * 
  70:      * @throws IndexOutOfBoundsException if <code>index</code> is not in the 
  71:      *     specified range.
  72:      */
  73:     public Comparable getKey(int index);
  74: 
  75:     /**
  76:      * Returns the index for a given key.
  77:      *
  78:      * @param key  the key (<code>null</code> not permitted).
  79:      *
  80:      * @return The index, or <code>-1</code> if the key is unrecognised.
  81:      * 
  82:      * @throws IllegalArgumentException if <code>key</code> is 
  83:      *     <code>null</code>.
  84:      */
  85:     public int getIndex(Comparable key);
  86: 
  87:     /**
  88:      * Returns the keys for the values in the collection.  Note that you can 
  89:      * access the values in this collection by key or by index.  For this 
  90:      * reason, the key order is important - this method should return the keys
  91:      * in order.  The returned list may be unmodifiable.
  92:      *
  93:      * @return The keys (never <code>null</code>).
  94:      */
  95:     public List getKeys();
  96: 
  97:     /**
  98:      * Returns the value for a given key.
  99:      *
 100:      * @param key  the key.
 101:      *
 102:      * @return The value (possibly <code>null</code>).
 103:      * 
 104:      * @throws UnknownKeyException if the key is not recognised.
 105:      */
 106:     public Number getValue(Comparable key);
 107: 
 108: }