JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource.jdbc
Class DataTable

java.lang.Object
  |
  +--javax.swing.tree.DefaultMutableTreeNode
        |
        +--com.klg.jclass.datasource.DataSourceTreeNode
              |
              +--com.klg.jclass.datasource.BaseDataTable
                    |
                    +--com.klg.jclass.datasource.jdbc.DataTable
All Implemented Interfaces:
Cloneable, DataTableAbstractionLayer, DataTableModel, MutableTreeNode, Serializable, TreeNode

public class DataTable
extends BaseDataTable

A copy of the data returned in a JDBC result table will be copied into one of these result tables so the data can be cached. Rows can then be added, deleted or updated through this DataTable.

All operations can access data through row/column idxToBookmarkMap rather than indexes. This facilitates sorting of rows and or columns.

See Also:
Serialized Form

Field Summary
protected  int columns
           
protected  com.klg.jclass.datasource.jdbc.MetaData metaData
           
protected static int NO_ROWS_CHANGED
           
protected static int ONE_ROW_CHANGED
           
protected  PreparedStatement statement
           
 
Fields inherited from class com.klg.jclass.datasource.BaseDataTable
bookmark, currentColumn, cursor, eventQueue, initialHashtableSize, insertedRows, internalData, logicallyDeletedRows, parentRow, rowCaches, rowIndexBeforeEvent, store, updatedRows, userData
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Fields inherited from interface com.klg.jclass.datasource.DataTableModel
COMMITTED, CURSOR_BEFORE_FIRST, DELETED, INSERTED, NONEXISTENT, ROOT_BOOKMARK, ROW_NOT_FOUND, UPDATED
 
Method Summary
 Object createNewRow()
          Creates a new row, called by addRow().
protected  void finalize()
          Free any lingering jdbc resources.
 Object getCell(long bookmark, String col_id)
          For internal use only.
protected  Object[] getRowFromServer(String table, String query, long bookmark)
          Sends the query to the server, fetches and returns the row.
 com.klg.jclass.datasource.DataTableModel materializeTable(com.klg.jclass.datasource.DataModelListener originator, long bookmark, TreeNode node)
          Called by DataTableModel.createTable to create a new table based on the input criteria.
 void refreshRow(long bookmark)
          For internal use only.
 com.klg.jclass.datasource.DataTableModel requeryLevel()
          For internal use only.
 void requeryTable(com.klg.jclass.datasource.DataModelListener originator)
          Requery all rows in this table and collapse its child nodes.
 void restoreRow(long bookmark)
          For internal use only.
 void saveRow(long bookmark)
          For internal use only.
protected  void setParameter(int number, Object value, int columnType)
          Sets parameters in the requery.
 
Methods inherited from class com.klg.jclass.datasource.BaseDataTable
absolute, addInternalRow, addInternalRow, addRow, addRow, addRow, addRow, afterLast, beforeFirst, cancelAllRowChanges, cancelChanges, cancelRowChanges, clearEventQueue, cloneRow, columnModified, commitAll, commitRow, commitSubTree, conditionallyCommitYourselfAndChildren, createDataTableModelFromProviderData, createTable, deleteCacheChildren, deleteRow, fireDataModelEvent, fireOriginatorDataModelEvent, first, getAncestors, getCurrentBookmark, getCursor, getDeletedRow, getDeletedRowBookmarks, getInsertedRowBookmarks, getInternalData, getMetaData, getNextBookmark, getOriginalRow, getParentBookmark, getResultData, getRootAncestorBookmark, getRowCount, getRowFromCache, getRowIdentifier, getRowIndex, getRowStatus, getTable, getUpdatedRowBookmarks, getUserData, hasValueChanged, isAfterLast, isBeforeFirst, isModified, isSubTreeModified, isTableOrChildrenModified, last, moveCursorToRow, moveToRow, next, originalCellWasNull, prepareCellUpdate, previous, processEventQueue, recursivelyDeleteChildren, relative, removeRowFromInsertedTable, removeRowFromLogicallyDeletedTable, removeRowFromOriginalRowTable, removeRowFromUpdatedTable, requeryRow, requeryRowAndDetails, setInternalData, setRowDirty, setUserData, setValueAt, tableIsAncestor, updateCell
 
Methods inherited from class com.klg.jclass.datasource.DataSourceTreeNode
getChildren, getFirstChild, getIterator, getIterator, getIterator, getIterator, getLastChild, getNextChild, getPreviousChild, hasChildren, insert, isChildOf, toString
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstLeaf, getIndex, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ROWS_CHANGED

protected static final int NO_ROWS_CHANGED
See Also:
Constant Field Values

ONE_ROW_CHANGED

protected static final int ONE_ROW_CHANGED
See Also:
Constant Field Values

columns

protected int columns

statement

protected transient PreparedStatement statement

metaData

protected com.klg.jclass.datasource.jdbc.MetaData metaData
Method Detail

getCell

public Object getCell(long bookmark,
                      String col_id)
               throws DataModelException
For internal use only. Call DataTableModel.getResultData(..) instead. Returns a value for a given row/column idxToBookmarkMap.

Specified by:
getCell in interface DataTableAbstractionLayer
Overrides:
getCell in class BaseDataTable
Parameters:
bookmark - a unique long representing a row
col_id - a unique String representing a column
Returns:
an Object which is the value at row/column
Throws:
DataModelException - If get fails.
See Also:
DataTableModel.getResultData(long, java.lang.String)

materializeTable

public com.klg.jclass.datasource.DataTableModel materializeTable(com.klg.jclass.datasource.DataModelListener originator,
                                                                 long bookmark,
                                                                 TreeNode node)
                                                          throws DataModelException
Called by DataTableModel.createTable to create a new table based on the input criteria.

Specified by:
materializeTable in interface DataTableAbstractionLayer
Overrides:
materializeTable in class BaseDataTable
Parameters:
bookmark - a long which uniquely identifies a row
originator - the DataModelListener which initiated this action
Throws:
DataModelException - If materializeTable fails.

createNewRow

public Object createNewRow()
Creates a new row, called by addRow(). An implementation-specific method for creating a new (blank) row, it must be implemented in the derived class of BaseDataTable.

Specified by:
createNewRow in interface DataTableModel
Overrides:
createNewRow in class BaseDataTable
Returns:
an Object which is the new row just added.

saveRow

public void saveRow(long bookmark)
             throws DataModelException
For internal use only. Call DataTableModel.commitRow or DataModel.updateAll() instead. Saves row changes to originating data source. Called by BaseDataTable.commitRow().

Specified by:
saveRow in interface DataTableAbstractionLayer
Overrides:
saveRow in class BaseDataTable
Parameters:
bookmark - a unique long indicating which row to commit to the datasource.
Throws:
DataModelException - If save fails.
See Also:
BaseDataTable.commitRow(com.klg.jclass.datasource.DataModelListener, long), DataModel.updateAll(com.klg.jclass.datasource.DataModelListener)

requeryLevel

public com.klg.jclass.datasource.DataTableModel requeryLevel()
                                                      throws DataModelException
For internal use only. Repopulates this DataTable by re-reading rows from the originating data source. Previous bookmarks are invalid and need to be re-read. Resets the cursor to the first row.

Specified by:
requeryLevel in interface DataTableModel
Overrides:
requeryLevel in class BaseDataTable
Throws:
DataModelException - If root level requery fails.

restoreRow

public void restoreRow(long bookmark)
For internal use only. Call DataTableModel.cancelRowChanges(..) or DataModel.cancelAll() instead. Restores a row's original values. Called by cancelRowChanges(bookmark). An implementation-specific method for restoring cell values, it must be implemented in the derived class of BaseDataTable.

Specified by:
restoreRow in interface DataTableAbstractionLayer
Overrides:
restoreRow in class BaseDataTable
Parameters:
bookmark - a long which uniquely identifies a row
See Also:
DataTableModel.cancelRowChanges(com.klg.jclass.datasource.DataModelListener, long), DataModel.cancelAll(com.klg.jclass.datasource.DataModelListener)

refreshRow

public void refreshRow(long bookmark)
                throws DataModelException
For internal use only. Call DataTableModel.requeryRow(..) instead. Re-reads a row from the originating data source. Called by BaseDataTable.requeryRow(). An implementation-specific method for refetching a row, it must be implemented in the derived class of BaseDataTable.

Specified by:
refreshRow in interface DataTableAbstractionLayer
Overrides:
refreshRow in class BaseDataTable
Parameters:
bookmark - a long which uniquely identifies a row
Throws:
DataModelException - If requery from data source fails.
See Also:
DataTableModel.requeryRow(com.klg.jclass.datasource.DataModelListener, long)

requeryTable

public void requeryTable(com.klg.jclass.datasource.DataModelListener originator)
                  throws DataModelException
Requery all rows in this table and collapse its child nodes. Overrides BaseDataTable.requeryTable. If this is the root, this method calls DataTableModel.requeryAll().

Specified by:
requeryTable in interface DataTableModel
Overrides:
requeryTable in class BaseDataTable
Parameters:
originator - the DataModelListener which initiated this action
Throws:
DataModelException - If requery fails.
See Also:
TreeData.requeryAll(com.klg.jclass.datasource.DataModelListener)

getRowFromServer

protected Object[] getRowFromServer(String table,
                                    String query,
                                    long bookmark)
                             throws DataModelException
Sends the query to the server, fetches and returns the row.

Throws:
DataModelException - If requery from data source fails.

setParameter

protected void setParameter(int number,
                            Object value,
                            int columnType)
                     throws DataModelException
Sets parameters in the requery.

Parameters:
number - the ordinal of the column in the statement
value - the Object value to be set
columnType - one of the java.sql.Types constants
Throws:
DataModelException - If setParameter fails.

finalize

protected void finalize()
Free any lingering jdbc resources.

Overrides:
finalize in class Object

Copyright © 2004 Quest Software Inc..
All rights reserved.