com.isti.util
Class BaseValueTableModel

java.lang.Object
  extended by com.isti.util.BaseValueTableModel
All Implemented Interfaces:
ValueTableModel
Direct Known Subclasses:
DelimiterSeparatedValuesTable

public class BaseValueTableModel
extends java.lang.Object
implements ValueTableModel


Constructor Summary
BaseValueTableModel()
          Creates the base values table.
 
Method Summary
protected  void addColumnMapValues(java.lang.Object columnMapKey, java.util.List columnList)
          Adds the column map values.
protected  void addFixedSizeRow(java.util.List columnList)
          Adds the row.
protected  void addReadOnlyColumn(java.lang.String columnName)
          Adds a read-only column.
protected  void addRow(java.util.List columnList)
          Adds the row.
protected  void appendErrorMessageString(java.lang.String str)
          Appends to the error message string.
 void clearErrorMessageString()
          Clears any current error message.
 void clearLists()
          Clears the lists by setting them to empty immutable lists.
 void clearRows()
          Clears all rows and creates the lists if they have not already been created.
 boolean columnsExist()
          Determines if the columns exist.
protected  java.util.Map createColumnMap()
          Creates a new column map.
protected  java.util.List createColumnNamesList()
          Create a new column names list.
protected  java.util.List createFixedSizeList(java.util.Collection c)
          Create a new fixed size list.
protected  java.util.List createFixedSizeList(int size)
          Create a new emtpy fixed size list.
protected  java.util.List createList()
          Create a new list.
 void createLists()
          Creates new lists.
protected  java.util.Map createMap()
          Creates a new map.
protected  java.util.List createRowsList()
          Creates the new rows list.
 java.lang.Class getColumnClass(int columnIndex)
          Returns the Class for all Object instances in the specified column.
 int getColumnCount()
          Returns the number of columns in the model.
 int getColumnIndex(java.lang.String columnName)
          Gets the column index for the specified column name.
protected  java.lang.Object getColumnMapKey(java.util.List columnList)
          Gets the column map key.
protected  java.util.List getColumnMapValues(java.lang.Object columnMapKey)
          Gets the column map values.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of a column in the model.
protected  java.util.List getColumnNames()
          Gets an unmodifiable column names list.
protected  java.lang.String getDefaultColumnName(int columnIndex)
          Gets the default column name for the specified column.
 boolean getErrorMessageFlag()
          Returns the status of the error message.
 java.lang.String getErrorMessageString()
          Returns the current error message (if any).
 java.lang.Object getRawValueAt(int rowIndex, int columnIndex)
          Returns the value (Object) at a particular cell in the table.
protected  java.util.List getRow(int rowIndex)
          Gets an unmodifiable row.
 int getRowCount()
          Returns the number of rows in the model.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value (Object) at a particular cell in the table.
 void importValues(ValueTableModel vtm)
          Import the values from the value table model for all rows.
protected  void importValues(ValueTableModel vtm, int rowIndex)
          Import the values from the value table model for the specifed row.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the specified cell is editable, and false if it is not.
 boolean isEditable()
          Returns true if the model is editable by default, and false if it is not.
protected  boolean isNull(java.lang.Object valueObj)
          Determines if the value is null.
protected  void setColumnNames(int numColumns)
          Set the column names list to the default values.
protected  boolean setColumnNames(java.util.List l)
          Sets the column names list.
protected  void setColumnNames(ValueTableModel vtm)
          Sets the column names list.
 void setEditable(boolean flag)
          Determines whether the model is editable by default.
protected  void setErrorMessageString(java.lang.String str)
          Sets the error message.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets the value at a particular cell in the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseValueTableModel

public BaseValueTableModel()
Creates the base values table.

Method Detail

clearErrorMessageString

public void clearErrorMessageString()
Clears any current error message.


clearLists

public final void clearLists()
Clears the lists by setting them to empty immutable lists.


clearRows

public void clearRows()
Clears all rows and creates the lists if they have not already been created.


columnsExist

public boolean columnsExist()
Determines if the columns exist.

Returns:
true if the columns exist, false otherwise.

createLists

public void createLists()
Creates new lists.


getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns the Class for all Object instances in the specified column.

Specified by:
getColumnClass in interface ValueTableModel
Parameters:
columnIndex - the column index.
Returns:
The class.

getColumnCount

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

Specified by:
getColumnCount in interface ValueTableModel
Returns:
The column count

getColumnIndex

public int getColumnIndex(java.lang.String columnName)
Gets the column index for the specified column name.

Specified by:
getColumnIndex in interface ValueTableModel
Parameters:
columnName - the column name.
Returns:
the column index or -1 if none.

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of a column in the model.

Specified by:
getColumnName in interface ValueTableModel
Parameters:
columnIndex - the column index.
Returns:
The column name.

getErrorMessageFlag

public boolean getErrorMessageFlag()
Returns the status of the error message.

Returns:
true if an error message is set; false if not.

getErrorMessageString

public java.lang.String getErrorMessageString()
Returns the current error message (if any).

Returns:
The current error message, or null if no errors have occurred.

getRowCount

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

Specified by:
getRowCount in interface ValueTableModel
Returns:
The row count.

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns the value (Object) at a particular cell in the table.

Specified by:
getValueAt in interface ValueTableModel
Parameters:
rowIndex - the row index.
columnIndex - the column index.
Returns:
The value at the specified cell.

getRawValueAt

public java.lang.Object getRawValueAt(int rowIndex,
                                      int columnIndex)
Returns the value (Object) at a particular cell in the table.

Parameters:
rowIndex - the row index.
columnIndex - the column index.
Returns:
The value at the specified cell.

importValues

public void importValues(ValueTableModel vtm)
Import the values from the value table model for all rows.

Specified by:
importValues in interface ValueTableModel
Parameters:
vtm - the value table model.

importValues

protected void importValues(ValueTableModel vtm,
                            int rowIndex)
Import the values from the value table model for the specifed row. The lists should be created (via the 'createLists' method) first.

Parameters:
vtm - the value table model.
rowIndex - the row index.
See Also:
createLists

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns true if the specified cell is editable, and false if it is not.

Specified by:
isCellEditable in interface ValueTableModel
Parameters:
rowIndex - the row index of the cell.
columnIndex - the column index of the cell.
Returns:
true if the cell is editable, false otherwise.

addReadOnlyColumn

protected void addReadOnlyColumn(java.lang.String columnName)
Adds a read-only column.

Parameters:
columnName - the column name.

isEditable

public final boolean isEditable()
Returns true if the model is editable by default, and false if it is not.

Returns:
true if the model is editable, false otherwise.

setEditable

public final void setEditable(boolean flag)
Determines whether the model is editable by default.

Parameters:
flag - true if the model is editable, false otherwise.

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value at a particular cell in the table.

Specified by:
setValueAt in interface ValueTableModel
Parameters:
aValue - the value (null permitted).
rowIndex - the row index.
columnIndex - the column index.

addRow

protected void addRow(java.util.List columnList)
Adds the row.

Parameters:
columnList - the list of columns for the row.

addFixedSizeRow

protected void addFixedSizeRow(java.util.List columnList)
Adds the row.

Parameters:
columnList - the list of columns for the row.

getColumnMapKey

protected java.lang.Object getColumnMapKey(java.util.List columnList)
Gets the column map key.

Parameters:
columnList - the list of columns for the row.
Returns:
the column map key or null if none.

addColumnMapValues

protected void addColumnMapValues(java.lang.Object columnMapKey,
                                  java.util.List columnList)
Adds the column map values.

Parameters:
columnMapKey - the column map key.
columnList - the list of columns for the row.

getColumnMapValues

protected java.util.List getColumnMapValues(java.lang.Object columnMapKey)
Gets the column map values.

Parameters:
columnMapKey - the column map key.
Returns:
the list of columns for the row or null if none.

appendErrorMessageString

protected void appendErrorMessageString(java.lang.String str)
Appends to the error message string.

Parameters:
str - the error message to append.

createFixedSizeList

protected java.util.List createFixedSizeList(int size)
Create a new emtpy fixed size list.

Parameters:
size - the size of the list.
Returns:
the new list.

createFixedSizeList

protected java.util.List createFixedSizeList(java.util.Collection c)
Create a new fixed size list.

Parameters:
c - the collection whose elements are to be placed into this list.
Returns:
the new list.

createColumnMap

protected java.util.Map createColumnMap()
Creates a new column map.

Returns:
the new map.

createColumnNamesList

protected java.util.List createColumnNamesList()
Create a new column names list.

Returns:
the new list.

createList

protected java.util.List createList()
Create a new list.

Returns:
the new list.

createMap

protected java.util.Map createMap()
Creates a new map.

Returns:
the new map.

createRowsList

protected java.util.List createRowsList()
Creates the new rows list.

Returns:
the new list.

getColumnNames

protected java.util.List getColumnNames()
Gets an unmodifiable column names list.

Returns:
an unmodifiable column names list.

getDefaultColumnName

protected java.lang.String getDefaultColumnName(int columnIndex)
Gets the default column name for the specified column.

Parameters:
columnIndex - the column index.
Returns:
the default column name.

getRow

protected java.util.List getRow(int rowIndex)
Gets an unmodifiable row.

Parameters:
rowIndex - the row index.
Returns:
the unmodifiable list of columns for the row.

isNull

protected boolean isNull(java.lang.Object valueObj)
Determines if the value is null.

Parameters:
valueObj - the value object.
Returns:
true if the value is null, false otherwise.

setColumnNames

protected void setColumnNames(int numColumns)
Set the column names list to the default values. The lists should be created (via the 'createLists' method) first.

Parameters:
numColumns - the number of columns.
See Also:
createLists

setColumnNames

protected boolean setColumnNames(java.util.List l)
Sets the column names list. The lists should be created (via the 'createLists' method) first.

Parameters:
l - the column names list.
Returns:
true if the column names list was set, false if error.
See Also:
createLists

setColumnNames

protected void setColumnNames(ValueTableModel vtm)
Sets the column names list. The lists should be created (via the 'createLists' method) first.

Parameters:
vtm - the value table model.
See Also:
createLists

setErrorMessageString

protected void setErrorMessageString(java.lang.String str)
Sets the error message. Any previously set error message is overwritten.

Parameters:
str - the error message text to set.