001/* ===========================================================
002 * Orson Charts : a 3D chart library for the Java(tm) platform
003 * ===========================================================
004 * 
005 * (C)opyright 2013-2016, by Object Refinery Limited.  All rights reserved.
006 * 
007 * http://www.object-refinery.com/orsoncharts/index.html
008 * 
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as published by
011 * the Free Software Foundation, either version 3 of the License, or
012 * (at your option) any later version.
013 *
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 *
019 * You should have received a copy of the GNU General Public License
020 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
021 * 
022 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
023 * Other names may be trademarks of their respective owners.]
024 * 
025 * If you do not wish to be bound by the terms of the GPL, an alternative
026 * commercial license can be purchased.  For details, please see visit the
027 * Orson Charts home page:
028 * 
029 * http://www.object-refinery.com/orsoncharts/index.html
030 * 
031 */
032
033package com.orsoncharts.data;
034
035import java.util.List;
036
037/**
038 * A two dimensional grid of data values where each value is uniquely 
039 * identified by two keys (the {@code rowKey} and the 
040 * {@code columnKey}).  Any instance of {@code Comparable} can be 
041 * used as a key ({@code String} objects are instances of 
042 * {@code Comparable}, making them convenient key objects).
043 * 
044 * @param <T>  The value type.
045 */
046public interface KeyedValues2D<T> extends Values2D<T> {
047
048    /**
049     * Returns the row key with the specified index.
050     * 
051     * @param rowIndex  the row index.
052     * 
053     * @return The key. 
054     */
055    public Comparable<?> getRowKey(int rowIndex);
056
057    /**
058     * Returns the column key with the specified index.
059     * 
060     * @param columnIndex  the index.
061     * 
062     * @return The key. 
063     */
064    public Comparable<?> getColumnKey(int columnIndex);
065
066    /**
067     * Returns the index of the specified key, or {@code -1} if there
068     * is no such key.
069     * 
070     * @param rowKey  the row key ({@code null} not permitted).
071     * 
072     * @return The index, or {@code -1}. 
073     */
074    public int getRowIndex(Comparable<?> rowKey);
075
076    /**
077     * Returns the index of the specified key, or {@code -1} if there
078     * is no such key.
079     * 
080     * @param columnKey  the column key ({@code null} not permitted).
081     * 
082     * @return The index, or {@code -1}. 
083     */
084    public int getColumnIndex(Comparable<?> columnKey);
085  
086    /**
087     * Returns a list of the row keys (the order is significant, since data 
088     * values can be accessed by index as well as by key).
089     * <br><br>
090     * NOTE: this method must be implemented so that modifications to the
091     * returned list do not impact the underlying data structure.
092     * 
093     * @return A list of row keys.
094     */
095    public List<Comparable<?>> getRowKeys();
096
097    /**
098     * Returns a list of the column keys (the order is significant, since data 
099     * values can be accessed by index as well as by key).
100     * <br><br>
101     * NOTE: this method must be implemented so that modifications to the
102     * returned list do not impact the underlying data structure.
103     * 
104     * @return A list of column keys.
105     */
106    public List<Comparable<?>> getColumnKeys();
107
108    /**
109     * Returns the value (possibly {@code null}) associated with the 
110     * specified keys.  If either or both of the keys is not defined in this
111     * data structure, a runtime exception will be thrown.
112     * 
113     * @param rowKey  the row key ({@code null} not permitted).
114     * @param columnKey  the column key ({@code null} not permitted).
115     * 
116     * @return The value (possibly {@code null}). 
117     */
118    public T getValue(Comparable<?> rowKey, Comparable<?> columnKey);
119
120}