|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectat.spardat.xma.mdl.util.TransAtomTable
Manages a two dimensional arrays of Atom objects. Each row is uniquely identified by a String-key. No two rows may have the same key. Besides accessing rows by a zero-based row index, rows may be accessed using the key.
Rows are specified using arrays of Atoms. Whereever a Atom array is provided as method parameter (e.g., adding a row), a copy of the array is stored internally. So the caller may freely reuse the array.
This class relies on the fact that class Atom is immutable. Making Atom non immutable would break this class.
Columns are specified with zero-based column indexes. The number of columns a table has is specified at construction time.
A TransAtomTable supports transactional behaviour, so its changes made since the last syncpoint (construction, commit, rollback) may be undone. To support this, the syncpoint state is saved if modifications are done. The modifications themselves are also kept in a list up to a point where the size of the changes approaches the size of the table. In this case, changes are discarded which effects serialization.
Serialization is supported (methods externalize and internalize). The caller may choose to externalize deltas or the complete state. This class internally decides up to which point changes are tracked based on heuristics (actually if the cumulated serialized size of changes approaches the serialized size of the complete state). Thus the caller merely may express its wish that changes should be externalized.
| Nested Class Summary | |
class |
TransAtomTable.AddRowChangeEvent
Adds a row to the table |
class |
TransAtomTable.ClearEvent
Clears the table |
class |
TransAtomTable.RemoveRowChangeEvent
Removes a row at a given index from this. |
class |
TransAtomTable.ReplaceAtomChangeEvent
Replaces an Atom (table cell) in the table. |
class |
TransAtomTable.ReplaceRowChangeEvent
Replaces a row at a given index with a new row. |
class |
TransAtomTable.TableChangeEvent
Base class for change events on TransAtomTables. |
| Constructor Summary | |
TransAtomTable(int numCols)
Constructor. |
|
| Method Summary | |
boolean |
add(int rowIndex,
java.lang.String key,
Atom[] atoms)
Adds a row to this at a provided index. |
boolean |
add(java.lang.String key,
Atom[] atoms)
Adds a row at the end of this. |
boolean |
changed()
Yields true if this WidgetModel has changed since the last syncpoint. |
void |
clear()
Removes all rows from this. |
void |
commit()
This method clears the change history. |
boolean |
containsKey(java.lang.String key)
Returns true if this table contains a row with the provided key. |
void |
describe(DNode n)
describe puts all relevant information about this into the provided node. |
boolean |
equals(java.lang.Object obj)
Debugging purpose. |
void |
externalize(XmaOutput xo,
boolean ignoreDeltas)
Externalizing this either serializes the actual state of this or the accumulated changes. |
Atom |
get(int rowIndex,
int colIndex)
Returns an Atom by providing row and column indexes. |
Atom |
get(java.lang.String key,
int colIndex)
Returns an Atom by providing a row key and a column index. |
Atom[] |
getAtoms(java.lang.String key)
Returns a copy of the Atom array for a particular key or null, if this has no row with the provided key. |
java.lang.String |
getKey(int rowIndex)
Returns the key at a provided row index. |
int |
indexOf(java.lang.String key)
Returns the index of the row whose key equals the one provided. |
void |
internalize(XmaInput in)
Updates the state of this with information of the given XmaInput. |
void |
remove(int index)
Removes a row for at a given index from this. |
boolean |
remove(java.lang.String key)
Removes a row for a given key from this. |
void |
replace(int index,
Atom[] row)
Replaces a row at a given index. |
void |
replace(int rowIndex,
int colIndex,
Atom cell)
Replaces a particular cell in the table. |
void |
rollback()
This method restores this Widget Model to its last syncpoint (which also becomes the new syncpoint). |
int |
size()
Returns the number of rows in this |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TransAtomTable(int numCols)
numCols - number of columns in this table.| Method Detail |
public boolean changed()
Transactional
changed in interface TransactionalTransactional.changed()public void rollback()
Transactional
rollback in interface TransactionalTransactional.rollback()public void commit()
Transactional
commit in interface TransactionalTransactional.commit()public int size()
public Atom get(int rowIndex,
int colIndex)
rowIndex - the index of the rowcolIndex - the index of the column
java.lang.ArrayIndexOutOfBoundsException - if a provided index is invalid
public Atom get(java.lang.String key,
int colIndex)
key - the key of the rowcolIndex - the index of the columns
java.lang.ArrayIndexOutOfBoundsException - if colIndex is invalid.public Atom[] getAtoms(java.lang.String key)
key - of the wanted row
public int indexOf(java.lang.String key)
This is a time consuming operation of O(n).
key - the key of the entry whose row is wanted.
public java.lang.String getKey(int rowIndex)
java.lang.ArrayIndexOutOfBoundsException - if index out of range.
public boolean add(int rowIndex,
java.lang.String key,
Atom[] atoms)
rowIndex - the index at which the row should be added. Must
lie in the range [0, size()].key - the key of the newly inserted rowatoms - an array of Atoms.
java.lang.IllegalArgumentException - if rowIndex out of range
or the length of atoms is unequal to the number
of columns provided at construction time.
public boolean add(java.lang.String key,
Atom[] atoms)
key - the key of the newly inserted rowatoms - an array of Atoms.
java.lang.IllegalArgumentException - if the length of atoms
is unequal to the number
of columns provided at construction time.public boolean remove(java.lang.String key)
key - the key whose row should be removed
public void remove(int index)
index - the index of the row that should be removed.
java.lang.ArrayIndexOutOfBoundsException - if index out of range
public void replace(int index,
Atom[] row)
index - the index at which the row is to be replaced.row - the new row
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds.
java.lang.IllegalArgumentException - if the length of atoms is unequal to the number
of columns provided at construction time.
public void replace(int rowIndex,
int colIndex,
Atom cell)
rowIndex - the row index at which the new cell is to be replacedcolIndex - the column index of the cellcell - the new Atom
java.lang.ArrayIndexOutOfBoundsException - if rowIndex or colIndex
are out of bounds.public boolean containsKey(java.lang.String key)
public void clear()
public void externalize(XmaOutput xo,
boolean ignoreDeltas)
throws java.io.IOException
externalize in interface Synchronizationxo - the serialization destinationignoreDeltas - if true, the actual state of this (all rows) is written
and deltas are ignored.
java.io.IOException - on serialization errors
public void internalize(XmaInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
In either case, the state after calling internalize is !changed().
internalize in interface Synchronizationin - the XmaInput.
java.io.IOException - on serialization errors
java.lang.ClassNotFoundException - on serialization errorspublic void describe(DNode n)
Descriptive
describe in interface Descriptiven - the node going to hold information about this.Descriptive.describe(at.spardat.xma.mdl.util.DNode)public boolean equals(java.lang.Object obj)
Object.equals(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||