Package org.jfree.util
Class ObjectTable
- java.lang.Object
-
- org.jfree.util.ObjectTable
-
- All Implemented Interfaces:
java.io.Serializable
public class ObjectTable extends java.lang.Object implements java.io.SerializableA lookup table for objects. This implementation is not synchronized, it is up to the caller to synchronize it properly.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private intcolumnIncrementDefines how many object-slots get reserved each time we run out of space.private intcolumnsThe number of columns.private java.lang.Object[][]dataAn array of objects.private introwIncrementDefines how many object-slots get reserved each time we run out of space.private introwsThe number of rows.private static longserialVersionUIDFor serialization.
-
Constructor Summary
Constructors Constructor Description ObjectTable()Creates a new table.ObjectTable(int increment)Creates a new table.ObjectTable(int rowIncrement, int colIncrement)Creates a new table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the table.protected voidcopyColumn(int oldColumn, int newColumn)Copys the contents of the old column to the new column.protected voidcopyRow(int oldRow, int newRow)Copys the contents of the old row to the new row.voidensureCapacity(int row, int column)Ensures that there is storage capacity for the specified item.protected voidensureRowCapacity(int row)Checks that there is storage capacity for the specified row and resizes if necessary.booleanequals(java.lang.Object o)Tests this paint table for equality with another object (typically also anObjectTable).intgetColumnCount()Returns the number of columns in the table.intgetColumnIncrement()Returns the column size increment.protected java.lang.Object[][]getData()Returns the table data.protected java.lang.ObjectgetObject(int row, int column)Returns the object from a particular cell in the table.intgetRowCount()Returns the number of rows in the table.intgetRowIncrement()Returns the row size increment.inthashCode()Returns a hash code value for the object.private voidreadObject(java.io.ObjectInputStream stream)Restores a serialized object.protected java.lang.ObjectreadSerializedData(java.io.ObjectInputStream stream)Handles the deserialization of a single element of the table.protected voidsetData(java.lang.Object[][] data, int colCount)Sets the table data.protected voidsetObject(int row, int column, java.lang.Object object)Sets the object for a cell in the table.private voidwriteObject(java.io.ObjectOutputStream stream)Handles serialization.protected voidwriteSerializedData(java.io.ObjectOutputStream stream, java.lang.Object o)Handles the serialization of an single element of this table.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
rows
private int rows
The number of rows.
-
columns
private int columns
The number of columns.
-
data
private transient java.lang.Object[][] data
An array of objects. The array may containnullvalues.
-
rowIncrement
private int rowIncrement
Defines how many object-slots get reserved each time we run out of space.
-
columnIncrement
private int columnIncrement
Defines how many object-slots get reserved each time we run out of space.
-
-
Constructor Detail
-
ObjectTable
public ObjectTable()
Creates a new table.
-
ObjectTable
public ObjectTable(int increment)
Creates a new table.- Parameters:
increment- the row and column size increment.
-
ObjectTable
public ObjectTable(int rowIncrement, int colIncrement)Creates a new table.- Parameters:
rowIncrement- the row size increment.colIncrement- the column size increment.
-
-
Method Detail
-
getColumnIncrement
public int getColumnIncrement()
Returns the column size increment.- Returns:
- the increment.
-
getRowIncrement
public int getRowIncrement()
Returns the row size increment.- Returns:
- the increment.
-
ensureRowCapacity
protected void ensureRowCapacity(int row)
Checks that there is storage capacity for the specified row and resizes if necessary.- Parameters:
row- the row index.
-
ensureCapacity
public void ensureCapacity(int row, int column)Ensures that there is storage capacity for the specified item.- Parameters:
row- the row index.column- the column index.
-
getRowCount
public int getRowCount()
Returns the number of rows in the table.- Returns:
- The row count.
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Returns:
- The column count.
-
getObject
protected java.lang.Object getObject(int row, int column)Returns the object from a particular cell in the table. Returns null, if there is no object at the given position.Note: throws IndexOutOfBoundsException if row or column is negative.
- Parameters:
row- the row index (zero-based).column- the column index (zero-based).- Returns:
- The object.
-
setObject
protected void setObject(int row, int column, java.lang.Object object)Sets the object for a cell in the table. The table is expanded if necessary.- Parameters:
row- the row index (zero-based).column- the column index (zero-based).object- the object.
-
equals
public boolean equals(java.lang.Object o)
Tests this paint table for equality with another object (typically also anObjectTable).- Overrides:
equalsin classjava.lang.Object- Parameters:
o- the other object.- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashcode
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionHandles serialization.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O problem.
-
writeSerializedData
protected void writeSerializedData(java.io.ObjectOutputStream stream, java.lang.Object o) throws java.io.IOExceptionHandles the serialization of an single element of this table.- Parameters:
stream- the stream which should write the objecto- the object that should be serialized- Throws:
java.io.IOException- if an IO error occured
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionRestores a serialized object.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O problem.java.lang.ClassNotFoundException- if a class cannot be found.
-
readSerializedData
protected java.lang.Object readSerializedData(java.io.ObjectInputStream stream) throws java.lang.ClassNotFoundException, java.io.IOExceptionHandles the deserialization of a single element of the table.- Parameters:
stream- the object input stream from which to read the object.- Returns:
- the deserialized object
- Throws:
java.lang.ClassNotFoundException- if a class cannot be found.java.io.IOException- Any of the usual Input/Output related exceptions.
-
clear
public void clear()
Clears the table.
-
copyColumn
protected void copyColumn(int oldColumn, int newColumn)Copys the contents of the old column to the new column.- Parameters:
oldColumn- the index of the old (source) columnnewColumn- the index of the new column
-
copyRow
protected void copyRow(int oldRow, int newRow)Copys the contents of the old row to the new row. This uses raw access to the data and is remarkably faster than manual copying.- Parameters:
oldRow- the index of the old rownewRow- the index of the new row
-
setData
protected void setData(java.lang.Object[][] data, int colCount)Sets the table data.- Parameters:
data- the data.colCount- the number of columns.
-
getData
protected java.lang.Object[][] getData()
Returns the table data.- Returns:
- The table data.
-
-