public class KeyedObjects2D extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
| Constructor and Description |
|---|
KeyedObjects2D()
Creates a new instance (initially empty).
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObject(java.lang.Object object,
java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
Adds an object to the table.
|
void |
clear()
Clears all the data and associated keys.
|
java.lang.Object |
clone()
Returns a clone.
|
boolean |
equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.
|
int |
getColumnCount()
Returns the column count.
|
int |
getColumnIndex(java.lang.Comparable key)
Returns the column index for a given key, or
-1 if the key
is not recognised. |
java.lang.Comparable |
getColumnKey(int column)
Returns the key for a given column.
|
java.util.List |
getColumnKeys()
Returns the column keys.
|
java.lang.Object |
getObject(java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
Returns the object for the given row and column keys.
|
java.lang.Object |
getObject(int row,
int column)
Returns the object for a given row and column.
|
int |
getRowCount()
Returns the row count.
|
int |
getRowIndex(java.lang.Comparable key)
Returns the row index for a given key, or
-1 if the key
is not recognised. |
java.lang.Comparable |
getRowKey(int row)
Returns the key for a given row.
|
java.util.List |
getRowKeys()
Returns the row keys.
|
int |
hashCode()
Returns a hashcode for this object.
|
void |
removeColumn(java.lang.Comparable columnKey)
Removes an entire column from the table.
|
void |
removeColumn(int columnIndex)
Removes an entire column from the table.
|
void |
removeObject(java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
Removes an object from the table by setting it to
null. |
void |
removeRow(java.lang.Comparable rowKey)
Removes an entire row from the table.
|
void |
removeRow(int rowIndex)
Removes an entire row from the table.
|
void |
setObject(java.lang.Object object,
java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
Adds or updates an object.
|
public KeyedObjects2D()
public int getRowCount()
getColumnCount()public int getColumnCount()
getRowCount()public java.lang.Object getObject(int row, int column)
row - the row index (in the range 0 to getRowCount() - 1).column - the column index (in the range 0 to getColumnCount() - 1).null).getObject(Comparable, Comparable)public java.lang.Comparable getRowKey(int row)
row - the row index (zero based).getRowIndex(Comparable)public int getRowIndex(java.lang.Comparable key)
-1 if the key
is not recognised.key - the key (null not permitted).getRowKey(int)public java.util.List getRowKeys()
null).getRowKeys()public java.lang.Comparable getColumnKey(int column)
column - the column.getColumnIndex(Comparable)public int getColumnIndex(java.lang.Comparable key)
-1 if the key
is not recognised.key - the key (null not permitted).getColumnKey(int)public java.util.List getColumnKeys()
null).getRowKeys()public java.lang.Object getObject(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
rowKey - the row key (null not permitted).columnKey - the column key (null not permitted).null).java.lang.IllegalArgumentException - if rowKey or
columnKey is null.UnknownKeyException - if rowKey or
columnKey is not recognised.public void addObject(java.lang.Object object, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
object - the object.rowKey - the row key (null not permitted).columnKey - the column key (null not permitted).public void setObject(java.lang.Object object, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
object - the object.rowKey - the row key (null not permitted).columnKey - the column key (null not permitted).public void removeObject(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
null. If
all the objects in the specified row and/or column are now
null, the row and/or column is removed from the table.rowKey - the row key (null not permitted).columnKey - the column key (null not permitted).addObject(Object, Comparable, Comparable)public void removeRow(int rowIndex)
rowIndex - the row index.removeColumn(int)public void removeRow(java.lang.Comparable rowKey)
rowKey - the row key (null not permitted).UnknownKeyException - if rowKey is not recognised.removeColumn(Comparable)public void removeColumn(int columnIndex)
columnIndex - the column index.removeRow(int)public void removeColumn(java.lang.Comparable columnKey)
columnKey - the column key (null not permitted).UnknownKeyException - if rowKey is not recognised.removeRow(Comparable)public void clear()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to test (null permitted).public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - this class will not throw this
exception, but subclasses (if any) might.