org.jfree.data.category

Class DefaultCategoryDataset

Implemented Interfaces:
CategoryDataset, Cloneable, Dataset, KeyedValues2D, ObjectInputValidation, Serializable, Values2D
Known Direct Subclasses:
DefaultKeyedValues2DDataset, JDBCCategoryDataset

public class DefaultCategoryDataset
extends AbstractDataset
implements CategoryDataset, Serializable

A default implementation of the CategoryDataset interface.

Constructor Summary

DefaultCategoryDataset()
Creates a new (empty) dataset.

Method Summary

void
addValue(Number value, Comparable rowKey, Comparable columnKey)
Adds a value to the table.
void
addValue(double value, Comparable rowKey, Comparable columnKey)
Adds a value to the table.
void
clear()
Clears all data from the dataset and sends a DatasetChangeEvent to all registered listeners.
Object
clone()
Returns a clone of the dataset.
boolean
equals(Object obj)
Tests this dataset for equality with an arbitrary object.
int
getColumnCount()
Returns the number of columns in the table.
int
getColumnIndex(Comparable key)
Returns the column index for a given key.
Comparable
getColumnKey(int column)
Returns a column key.
List
getColumnKeys()
Returns the column keys.
int
getRowCount()
Returns the number of rows in the table.
int
getRowIndex(Comparable key)
Returns the row index for a given key.
Comparable
getRowKey(int row)
Returns a row key.
List
getRowKeys()
Returns the row keys.
Number
getValue(Comparable rowKey, Comparable columnKey)
Returns the value for a pair of keys.
Number
getValue(int row, int column)
Returns a value from the table.
int
hashCode()
Returns a hash code for the dataset.
void
incrementValue(double value, Comparable rowKey, Comparable columnKey)
Adds the specified value to an existing value in the dataset (if the existing value is null, it is treated as if it were 0.0).
void
removeColumn(Comparable columnKey)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.
void
removeColumn(int columnIndex)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.
void
removeRow(Comparable rowKey)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.
void
removeRow(int rowIndex)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.
void
removeValue(Comparable rowKey, Comparable columnKey)
Removes a value from the dataset and sends a DatasetChangeEvent to all registered listeners.
void
setValue(Number value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.
void
setValue(double value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.

Methods inherited from class org.jfree.data.general.AbstractDataset

addChangeListener, clone, fireDatasetChanged, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObject

Constructor Details

DefaultCategoryDataset

public DefaultCategoryDataset()
Creates a new (empty) dataset.

Method Details

addValue

public void addValue(Number value,
                     Comparable rowKey,
                     Comparable columnKey)
Adds a value to the table. Performs the same function as setValue().
Parameters:
value - the value.
rowKey - the row key.
columnKey - the column key.

addValue

public void addValue(double value,
                     Comparable rowKey,
                     Comparable columnKey)
Adds a value to the table.
Parameters:
value - the value.
rowKey - the row key.
columnKey - the column key.

clear

public void clear()
Clears all data from the dataset and sends a DatasetChangeEvent to all registered listeners.

clone

public Object clone()
            throws CloneNotSupportedException
Returns a clone of the dataset.
Overrides:
clone in interface AbstractDataset
Returns:
A clone.

equals

public boolean equals(Object obj)
Tests this dataset for equality with an arbitrary object.
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.
Specified by:
getColumnCount in interface Values2D
Returns:
The column count.
See Also:
getRowCount()

getColumnIndex

public int getColumnIndex(Comparable key)
Returns the column index for a given key.
Specified by:
getColumnIndex in interface KeyedValues2D
Parameters:
key - the column key.
Returns:
The column index.

getColumnKey

public Comparable getColumnKey(int column)
Returns a column key.
Specified by:
getColumnKey in interface KeyedValues2D
Parameters:
column - the column index (zero-based).
Returns:
The column key.

getColumnKeys

public List getColumnKeys()
Returns the column keys.
Specified by:
getColumnKeys in interface KeyedValues2D
Returns:
The keys.

getRowCount

public int getRowCount()
Returns the number of rows in the table.
Specified by:
getRowCount in interface Values2D
Returns:
The row count.

getRowIndex

public int getRowIndex(Comparable key)
Returns the row index for a given key.
Specified by:
getRowIndex in interface KeyedValues2D
Parameters:
key - the row key.
Returns:
The row index.

getRowKey

public Comparable getRowKey(int row)
Returns a row key.
Specified by:
getRowKey in interface KeyedValues2D
Parameters:
row - the row index (zero-based).
Returns:
The row key.

getRowKeys

public List getRowKeys()
Returns the row keys.
Specified by:
getRowKeys in interface KeyedValues2D
Returns:
The keys.

getValue

public Number getValue(Comparable rowKey,
                       Comparable columnKey)
Returns the value for a pair of keys.
Specified by:
getValue in interface KeyedValues2D
Parameters:
rowKey - the row key (null not permitted).
columnKey - the column key (null not permitted).
Returns:
The value (possibly null).

getValue

public Number getValue(int row,
                       int column)
Returns a value from the table.
Specified by:
getValue in interface Values2D
Parameters:
row - the row index (zero-based).
column - the column index (zero-based).
Returns:
The value (possibly null).

hashCode

public int hashCode()
Returns a hash code for the dataset.
Returns:
A hash code.

incrementValue

public void incrementValue(double value,
                           Comparable rowKey,
                           Comparable columnKey)
Adds the specified value to an existing value in the dataset (if the existing value is null, it is treated as if it were 0.0).
Parameters:
value - the value.
rowKey - the row key (null not permitted).
columnKey - the column key (null not permitted).

removeColumn

public void removeColumn(Comparable columnKey)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.
Parameters:
columnKey - the column key.

removeColumn

public void removeColumn(int columnIndex)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.
Parameters:
columnIndex - the column index.

removeRow

public void removeRow(Comparable rowKey)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.
Parameters:
rowKey - the row key.

removeRow

public void removeRow(int rowIndex)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.
Parameters:
rowIndex - the row index.

removeValue

public void removeValue(Comparable rowKey,
                        Comparable columnKey)
Removes a value from the dataset and sends a DatasetChangeEvent to all registered listeners.
Parameters:
rowKey - the row key.
columnKey - the column key.

setValue

public void setValue(Number value,
                     Comparable rowKey,
                     Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.
Parameters:
value - the value (null permitted).
rowKey - the row key (null not permitted).
columnKey - the column key (null not permitted).

setValue

public void setValue(double value,
                     Comparable rowKey,
                     Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.
Parameters:
value - the value.
rowKey - the row key (null not permitted).
columnKey - the column key (null not permitted).