org.pentaho.reporting.libraries.base.util

Class ObjectTable

public class ObjectTable extends Object implements Serializable

A lookup table for objects. This implementation is not synchronized, it is up to the caller to synchronize it properly.

Author: Thomas Morgner

Constructor Summary
ObjectTable()
Creates a new table.
ObjectTable(int increment)
Creates a new table.
ObjectTable(int rowIncrement, int colIncrement)
Creates a new table.
Method Summary
voidclear()
Clears the table.
voidclearRow(int row)
Clears the row by removing the array that stores the row-data.
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(Object o)
Tests this paint table for equality with another object (typically also an ObjectTable).
intgetColumnCount()
Returns the number of columns in the table.
intgetColumnIncrement()
Returns the column size increment.
protected Object[][]getData()
Returns the data-storage as raw-object.
protected 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.
protected ObjectreadSerializedData(ObjectInputStream stream)
Handles the deserialization of a single element of the table.
protected voidsetData(Object[][] data, int colCount)
Replaces the data in the table with the given two-dimensional array.
protected voidsetObject(int row, int column, Object object)
Sets the object for a cell in the table.
protected voidwriteSerializedData(ObjectOutputStream stream, Object o)
Handles the serialization of an single element of this table.

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

clear

public void clear()
Clears the table.

clearRow

public void clearRow(int row)
Clears the row by removing the array that stores the row-data. This reduces the in-memory size of the table at the cost of possibly having to recreate the row-data-array later.

Parameters: row the row to be deleted.

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) column newColumn 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 row newRow the index of the new row

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.

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.

equals

public boolean equals(Object o)
Tests this paint table for equality with another object (typically also an ObjectTable).

Parameters: o the other object.

Returns: A boolean.

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.

Returns: The column count.

getColumnIncrement

public int getColumnIncrement()
Returns the column size increment.

Returns: the increment.

getData

protected Object[][] getData()
Returns the data-storage as raw-object. You better do not modify the data-storage unless you are absolutely sure about what you are doing.

Returns: the data as raw-object.

getObject

protected 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.

getRowCount

public int getRowCount()
Returns the number of rows in the table.

Returns: The row count.

getRowIncrement

public int getRowIncrement()
Returns the row size increment.

Returns: the increment.

hashCode

public int hashCode()
Returns a hash code value for the object.

Returns: the hashcode

readSerializedData

protected Object readSerializedData(ObjectInputStream stream)
Handles 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: ClassNotFoundException if a class cannot be found. java.io.IOException Any of the usual Input/Output related exceptions.

setData

protected void setData(Object[][] data, int colCount)
Replaces the data in the table with the given two-dimensional array. For performance reasons, the array is added as is without cloning it, so make sure that you either clone it up-front or risk instable objects.

Parameters: data the array to be used as new data array colCount the column count in the array.

UNKNOWN: AssignmentToCollectionOrArrayFieldFromParameter for performance reasons as this is an internal method

setObject

protected void setObject(int row, int column, 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.

writeSerializedData

protected void writeSerializedData(ObjectOutputStream stream, Object o)
Handles the serialization of an single element of this table.

Parameters: stream the stream which should write the object o the object that should be serialized

Throws: java.io.IOException if an IO error occured