JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.datasource
Class BaseMetaData

java.lang.Object
  |
  +--javax.swing.tree.DefaultMutableTreeNode
        |
        +--com.klg.jclass.datasource.DataSourceTreeNode
              |
              +--com.klg.jclass.datasource.BaseMetaData
All Implemented Interfaces:
Cloneable, MetaDataModel, MutableTreeNode, Serializable, TreeNode
Direct Known Subclasses:
IdeMetaData, MetaData

public class BaseMetaData
extends DataSourceTreeNode
implements MetaDataModel

Base implementation of MetaDataModel.

See Also:
Serialized Form

Field Summary
protected  com.klg.jclass.datasource.BindingModel binding
           
protected  int bufferSize
           
protected  boolean cacheChildren
           
protected  Vector columns
           
protected  int commitPolicy
           
protected static int counter
           
protected  long currentBookmark
           
protected  com.klg.jclass.datasource.DataTableModel currentDataTable
           
protected  com.klg.jclass.datasource.DataModel dataModel
           
protected  Hashtable deletePermissions
           
protected  String description
           
protected  Hashtable idxToColumnMap
           
protected  int initialHashtableSize
           
protected  Hashtable insertPermissions
           
protected  int maxRows
           
protected  int metaDataID
           
protected  com.klg.jclass.datasource.ProviderModel provider
           
protected  boolean showDeletedRows
           
protected  Class storeClass
           
protected  Hashtable updatePermissions
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Fields inherited from interface com.klg.jclass.datasource.MetaDataModel
COMMIT_LEAVING_ANCESTOR, COMMIT_LEAVING_RECORD, COMMIT_MANUALLY, TYPE_BIG_DECIMAL, TYPE_BOOLEAN, TYPE_BYTE, TYPE_BYTE_ARRAY, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_SHORT, TYPE_SQL_DATE, TYPE_SQL_TIME, TYPE_SQL_TIMESTAMP, TYPE_STRING, TYPE_UTIL_DATE
 
Constructor Summary
BaseMetaData(com.klg.jclass.datasource.DataModel dataModel)
          Constructor
 
Method Summary
 void addColumn(com.klg.jclass.datasource.ColumnModel column)
          Adds a column to the list of column objects.
 void clear()
          For internal use only.
 void commitTransaction()
          Commits transaction: does nothing here, so it must be overridden.
 byte[] createByteArrayFromBinaryStream(InputStream is)
          Returns a byte array created from an input stream.
 boolean getAutoCommit()
          Default implementation: returns true.
 com.klg.jclass.datasource.BindingModel getBinding()
          Return the BindingModel for this level, creating it if it doesn't already exist.
 int getBufferSize()
          Returns the buffer size used for reading binary data, in bytes.
 boolean getCacheChildren()
          Returns a boolean flag indicating whether subtrees of DataTables rooted at this level are eligible for deletion.
 int getColumnCount()
          Returns number of columns in this result set.
 String getColumnIdentifier(int column_index)
          Returns a string that uniquely identifies this column.
 int getColumnIndex(String name)
          Given a column name, gets its index.
 Hashtable getColumnMap()
          Returns the list which associates an ordinal position with a column name.
 com.klg.jclass.datasource.ColumnModel getColumnObject(String col_id)
          Returns the
 Vector getColumnObjects()
          Returns the list of ColumnModel objects.
 int getCommitPolicy()
          Returns the commit policy for this level.
 long getCurrentBookmark()
          Returns the bookmark of the row currently in focus.
 com.klg.jclass.datasource.DataTableModel getCurrentDataTable()
          Returns the data table which currently has focus.
 com.klg.jclass.datasource.DataModel getDataModel()
          Returns the
 boolean getDeleteAllowed(String table)
          Returns true if this table can be deleted.
 String getDescription()
          Returns the user-assigned description of this instance, or "" if the description has not been set.
 boolean getInsertAllowed(String table)
          Returns true if this table can be inserted into.
 int getJavaColumnType(String column_identifier)
          Returns the Java type for a column, one of MetaDataModel type constants.
 int getMaxRows()
          Returns the maximum number of rows which can be returned by a query.
 int getMetaID()
          Returns an int that uniquely identifies this instance of the
 Object getNativeMetaData()
          Returns the native meta-data object: must be overriden.
 com.klg.jclass.datasource.ProviderModel getProvider()
          Get the provider (if any) for this level.
 boolean getShowDeletedRows()
          Returns whether logically deleted rows should be shown.
 Class getStoreClass()
          Return the class responsible for data storage and retrieval (implements StoreModel).
 boolean getUpdateAllowed(String table)
          Returns true if this table can be updated.
 boolean isUpdateAllowedOnColumn(String column)
          Do permissions on the model allow this column to be editied? Returns true in the base implementation.
 void rollbackTransaction()
          Rolls back the transaction: does nothing here, so it.
 void setAutoCommit(boolean value)
          Default implementation: does nothing.
 void setBinding(com.klg.jclass.datasource.BindingModel binding)
          Set the Binding object associated with this MetaData level.
 void setBufferSize(int bufferSize)
          Binary data (BINARY, VARBINARY, LONGVARBINARY) will be read in chunks of this size.
 void setCacheChildren(boolean cacheChildren)
          Sets a boolean indicating whether subtrees of
 void setCommitPolicy(int commit_policy)
          Sets the commit policy for this level.
 void setCurrentBookmark(long currentBookmark)
           
 void setCurrentDataTable(com.klg.jclass.datasource.DataTableModel currentDataTable)
           
 void setDeleteAllowed(String table, boolean v)
          Sets a boolean indicating whether rows in this table may be deleted.
 void setDescription(String description)
          Sets the user-assigned description of this instance.
 void setInsertAllowed(String table, boolean v)
          Sets a boolean indicating whether this table allows inserts.
 void setMaxRows(int maxRows)
          Sets the maximum number of rows a query at this level can return.
 void setMetaID(int metaDataID)
          For internal use only.
 void setProviderClassName(String providerModelClassName)
          Set the ProviderModel class name which will provide data for this level.
 void setShowDeletedRows(boolean value)
          Indicates whether logically deleted rows showld be shown.
 void setStoreClass(String storeClassName)
          Set an alternate class to handle data storage and retrieval responsibilities.
 void setUpdateAllowed(String table, boolean v)
          Sets a boolean indicating whether updates are allowed in the table mentioned in the first parameter.
 
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.tree.TreeNode
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
 

Field Detail

dataModel

protected com.klg.jclass.datasource.DataModel dataModel

description

protected String description

insertPermissions

protected Hashtable insertPermissions

updatePermissions

protected Hashtable updatePermissions

deletePermissions

protected Hashtable deletePermissions

idxToColumnMap

protected Hashtable idxToColumnMap

columns

protected Vector columns

commitPolicy

protected int commitPolicy

storeClass

protected Class storeClass

initialHashtableSize

protected int initialHashtableSize

metaDataID

protected int metaDataID

counter

protected static int counter

maxRows

protected int maxRows

cacheChildren

protected boolean cacheChildren

showDeletedRows

protected boolean showDeletedRows

currentDataTable

protected transient com.klg.jclass.datasource.DataTableModel currentDataTable

currentBookmark

protected long currentBookmark

bufferSize

protected int bufferSize

binding

protected com.klg.jclass.datasource.BindingModel binding

provider

protected com.klg.jclass.datasource.ProviderModel provider
Constructor Detail

BaseMetaData

public BaseMetaData(com.klg.jclass.datasource.DataModel dataModel)
Constructor

Method Detail

setInsertAllowed

public void setInsertAllowed(String table,
                             boolean v)
Sets a boolean indicating whether this table allows inserts. By default, inserts are allowed.

Specified by:
setInsertAllowed in interface MetaDataModel
Parameters:
table - a String name of the table

setUpdateAllowed

public void setUpdateAllowed(String table,
                             boolean v)
Sets a boolean indicating whether updates are allowed in the table mentioned in the first parameter. The default is to allow updates.

Specified by:
setUpdateAllowed in interface MetaDataModel
Parameters:
table - a String name of the table

setDeleteAllowed

public void setDeleteAllowed(String table,
                             boolean v)
Sets a boolean indicating whether rows in this table may be deleted. The default is to permit the table to be deleted.

Specified by:
setDeleteAllowed in interface MetaDataModel
Parameters:
table - a String name of the table

getInsertAllowed

public boolean getInsertAllowed(String table)
Returns true if this table can be inserted into. The default is to allow inserts.

Specified by:
getInsertAllowed in interface MetaDataModel
Parameters:
table - a String name of the table
Returns:
true if table can be updated

getUpdateAllowed

public boolean getUpdateAllowed(String table)
Returns true if this table can be updated. The default is to allow this.

Specified by:
getUpdateAllowed in interface MetaDataModel
Parameters:
table - a String name of the table
Returns:
true if table can be updated

getDeleteAllowed

public boolean getDeleteAllowed(String table)
Returns true if this table can be deleted. The default is to allow this.

Specified by:
getDeleteAllowed in interface MetaDataModel
Parameters:
table - a String name of the table
Returns:
true if rows in this table can be deleted.

getDataModel

public com.klg.jclass.datasource.DataModel getDataModel()
Returns the
DataModel
which encapsulates this
MetaDataModel
.

Specified by:
getDataModel in interface MetaDataModel
Returns:
the DataModel

getMetaID

public int getMetaID()
Returns an int that uniquely identifies this instance of the
MetaDataModel
. This id is automatically generated.

Specified by:
getMetaID in interface MetaDataModel
Returns:
an int which uniquely identifies this object.
See Also:
MetaDataModel.setMetaID(int)

setMetaID

public void setMetaID(int metaDataID)
For internal use only. Assigns a unique id to a meta data instance

Specified by:
setMetaID in interface MetaDataModel
Parameters:
metaDataID - an int which is the unique id for this instance
See Also:
getMetaID()

getDescription

public String getDescription()
Returns the user-assigned description of this instance, or "" if the description has not been set.

Specified by:
getDescription in interface MetaDataModel
Returns:
a String which describes this instance.

setDescription

public void setDescription(String description)
Sets the user-assigned description of this instance.

Specified by:
setDescription in interface MetaDataModel
Parameters:
description - a String which describles this instance.

getAutoCommit

public boolean getAutoCommit()
                      throws DataModelException
Default implementation: returns true. Must be overridden in specific implementations if transactions are supported and enabled. Returns true if the transaction capabilities of the underlying data source are to be used when saving modifications (transactions are supported and enabled). If the underlying data source supports transactions and this capability has been enabled, data modifications will be wrapped in a transaction which can be committed or rolled back.

Specified by:
getAutoCommit in interface MetaDataModel
Throws:
DataModelException - If the operation fails.
See Also:
commitTransaction(), rollbackTransaction()

setAutoCommit

public void setAutoCommit(boolean value)
                   throws DataModelException
Default implementation: does nothing. Can be overriden in specific implementations, but is not for jdbc/jbuilder since this value is derived from the underlying objects, the
DataTableConnection
object in the case of jdbc. Sets the auto commit flag. If the underlying data source supports transactions and this flag is set to false, a transaction will wrap data modifications. The default is to not attempt to wrap modifications in a transaction.

Specified by:
setAutoCommit in interface MetaDataModel
Parameters:
value - a boolean, true if transactions are to be used, false otherwise.
Throws:
DataModelException - If the operation fails.

rollbackTransaction

public void rollbackTransaction()
                         throws DataModelException
Rolls back the transaction: does nothing here, so it. must be overridden. If the underlying data source supports transactions and transactions have been enabled, calling this method will roll back all pending transactions on the data source.

Specified by:
rollbackTransaction in interface MetaDataModel
Throws:
DataModelException - If rollback fails.
See Also:
MetaDataModel.getAutoCommit()

commitTransaction

public void commitTransaction()
                       throws DataModelException
Commits transaction: does nothing here, so it must be overridden. If the underlying data source supports transactions and transactions have been enabled, calling this method will commit all pending transactions on the data source. Otherwise it is a no-op.

Specified by:
commitTransaction in interface MetaDataModel
Throws:
DataModelException - If commit fails.

setCommitPolicy

public void setCommitPolicy(int commit_policy)
                     throws DataModelException
Sets the commit policy for this level. Determines when changes are permanently written to the originating data source. Must be one of COMMIT_LEAVING_RECORD, COMMIT_LEAVING_PARENT, or COMMIT_MANUALLY.

Commit policy cannot be set to COMMIT_LEAVING_RECORD if getShowDeltedRows() returns false.

Specified by:
setCommitPolicy in interface MetaDataModel
Parameters:
commit_policy - an int, one of COMMIT_LEAVING_RECORD, COMMIT_LEAVING_PARENT, or COMMIT_MANUALLY
Throws:
DataModelException - If set fails.
See Also:
getShowDeletedRows()

getCommitPolicy

public int getCommitPolicy()
Returns the commit policy for this level. Determines when changes are permanently written to the originating data source. Will be one of COMMIT_LEAVING_RECORD, COMMIT_LEAVING_PARENT, or COMMIT_MANUALLY.

Specified by:
getCommitPolicy in interface MetaDataModel
Returns:
an int, one of COMMIT_LEAVING_RECORD, COMMIT_LEAVING_PARENT, or COMMIT_MANUALLY

getColumnObjects

public Vector getColumnObjects()
Returns the list of ColumnModel objects.

Specified by:
getColumnObjects in interface MetaDataModel
Returns:
a vector of ColumnModel objects.
See Also:
ColumnModel

getColumnCount

public int getColumnCount()
Returns number of columns in this result set.

Specified by:
getColumnCount in interface MetaDataModel
Returns:
an int for the number of columns in this table

addColumn

public void addColumn(com.klg.jclass.datasource.ColumnModel column)
               throws DataModelException
Adds a column to the list of column objects.

Specified by:
addColumn in interface MetaDataModel
Throws:
DataModelException - If duplicate column found.
See Also:
ColumnModel

getColumnIdentifier

public String getColumnIdentifier(int column_index)
                           throws DataModelException
Returns a string that uniquely identifies this column. Used to access data rather than column index which can change when columns are sorted.

Specified by:
getColumnIdentifier in interface MetaDataModel
Parameters:
column_index - an int indicating for which column a unique identifier should be returned.
Returns:
a String which uniquely identifies a column
Throws:
DataModelException - If getColumnIdentifier fails.

getJavaColumnType

public int getJavaColumnType(String column_identifier)
                      throws DataModelException
Returns the Java type for a column, one of MetaDataModel type constants.

Specified by:
getJavaColumnType in interface MetaDataModel
Parameters:
column_identifier - an String uniquely identifying a column
Returns:
an int representing the meta column type for this column, will be one of
  • TYPE_BOOLEAN
  • TYPE_SQL_DATE
  • TYPE_DOUBLE
  • TYPE_FLOAT
  • TYPE_INTEGER
  • TYPE_STRING
  • TYPE_BIG_DECIMAL
  • TYPE_LONG
  • TYPE_SQL_TIME
  • TYPE_SQL_TIMESTAMP
  • TYPE_OBJECT
  • TYPE_BYTE
  • TYPE_SHORT
  • TYPE_BYTE_ARRAY
  • TYPE_UTIL_DATE
Throws:
DataModelException - If getJavaColumnType fails.
See Also:
MetaDataModel

getColumnObject

public com.klg.jclass.datasource.ColumnModel getColumnObject(String col_id)
                                                      throws DataModelException
Returns the
ColumnModel
for the given column.

Specified by:
getColumnObject in interface MetaDataModel
Parameters:
col_id - a String which uniquely identifies a column
Returns:
a ColumnModel
Throws:
DataModelException - If get fails.

getColumnIndex

public int getColumnIndex(String name)
                   throws DataModelException
Given a column name, gets its index.

Specified by:
getColumnIndex in interface MetaDataModel
Returns:
an int which is this column's ordinal position in the original result data.
Throws:
DataModelException - If the operation fails.

getColumnMap

public Hashtable getColumnMap()
Returns the list which associates an ordinal position with a column name.


getNativeMetaData

public Object getNativeMetaData()
Returns the native meta-data object: must be overriden. Returns null in the base implementation. This is a DataSet in JBuilder and a RelationView in VisualCafe.

Specified by:
getNativeMetaData in interface MetaDataModel
Returns:
the native meta data object for this level.

isUpdateAllowedOnColumn

public boolean isUpdateAllowedOnColumn(String column)
                                throws DataModelException
Do permissions on the model allow this column to be editied? Returns true in the base implementation.

Specified by:
isUpdateAllowedOnColumn in interface MetaDataModel
Returns:
true if edits are allowed, false otherwise
Throws:
DataModelException - If primary keys cannot be determined.
See Also:
setUpdateAllowed(java.lang.String, boolean), getUpdateAllowed(java.lang.String)

clear

public void clear()
For internal use only. Changes the query for this data control. For customizer use during design-time.

Specified by:
clear in interface MetaDataModel

setShowDeletedRows

public void setShowDeletedRows(boolean value)
                        throws DataModelException
Indicates whether logically deleted rows showld be shown. This attribute can only be set if the commitPolicy is COMMIT_MANUALLY or COMMIT_LEAVING_ANCESTOR, otherwise an exception is thrown.

Specified by:
setShowDeletedRows in interface MetaDataModel
Parameters:
value - a boolean: true to show rows, false otherwise
Throws:
DataModelException - If set fails.

getShowDeletedRows

public boolean getShowDeletedRows()
Returns whether logically deleted rows should be shown.

Specified by:
getShowDeletedRows in interface MetaDataModel
Returns:
show a boolean: true means show rows, false hide them.
See Also:
setShowDeletedRows(boolean), setCommitPolicy(int)

setMaxRows

public void setMaxRows(int maxRows)
Sets the maximum number of rows a query at this level can return. Useful for design time where only a sampling of rows is required. Set to 0 (the default) to have no limit.

Does not apply to ide-specific implmentations. Set the max rows directly on the ide data object instead.

Specified by:
setMaxRows in interface MetaDataModel
Parameters:
maxRows - an int indicating the max rows to be returned
See Also:
getMaxRows()

getMaxRows

public int getMaxRows()
Returns the maximum number of rows which can be returned by a query.

Does not apply to ide-specific implmentations. Set the max rows directly on the ide data object instead.

Specified by:
getMaxRows in interface MetaDataModel
Returns:
the maximum number of rows which can be returned by a query
See Also:
setMaxRows(int)

setCacheChildren

public void setCacheChildren(boolean cacheChildren)
Sets a boolean indicating whether subtrees of
DataTables
rooted at this level are eligible for deletion. The default is false, meaning
DataTableModel.deleteCacheChildren
should be called when a subtree is collapsed.

Specified by:
setCacheChildren in interface MetaDataModel
Parameters:
cacheChildren - a boolean: true means children should be cached, false means dateCacheChildren should be called when a tree is collapsed.
See Also:
getCacheChildren(), DataTableModel.deleteCacheChildren(com.klg.jclass.datasource.DataModelListener)

getCacheChildren

public boolean getCacheChildren()
Returns a boolean flag indicating whether subtrees of DataTables rooted at this level are eligible for deletion.

Specified by:
getCacheChildren in interface MetaDataModel
Returns:
false if deleteCacheChildren should be called on this level when it is collapsed. Return true if the children should be preserved, that is no call should be made to deleteCacheChildren.
See Also:
setCacheChildren(boolean), DataTableModel.deleteCacheChildren(com.klg.jclass.datasource.DataModelListener)

getCurrentDataTable

public com.klg.jclass.datasource.DataTableModel getCurrentDataTable()
Returns the data table which currently has focus.

Specified by:
getCurrentDataTable in interface MetaDataModel
Returns:
a DataTableModel, the one currently in focus.

getCurrentBookmark

public long getCurrentBookmark()
Returns the bookmark of the row currently in focus.

Specified by:
getCurrentBookmark in interface MetaDataModel
Returns:
the bookmark of the row currently in focus.

setCurrentDataTable

public void setCurrentDataTable(com.klg.jclass.datasource.DataTableModel currentDataTable)
Specified by:
setCurrentDataTable in interface MetaDataModel

setCurrentBookmark

public void setCurrentBookmark(long currentBookmark)
Specified by:
setCurrentBookmark in interface MetaDataModel

createByteArrayFromBinaryStream

public byte[] createByteArrayFromBinaryStream(InputStream is)
                                       throws DataModelException
Returns a byte array created from an input stream.

Returns:
the byte array created from that data
Throws:
DataModelException - If the operation fails.

setBufferSize

public void setBufferSize(int bufferSize)
Binary data (BINARY, VARBINARY, LONGVARBINARY) will be read in chunks of this size. The default is 5K.


getBufferSize

public int getBufferSize()
Returns the buffer size used for reading binary data, in bytes.

Returns:
the block size used to read binary data, in bytes.
See Also:
setBufferSize(int)

setStoreClass

public void setStoreClass(String storeClassName)
                   throws DataModelException
Set an alternate class to handle data storage and retrieval responsibilities. A "Class.forName()" will be done to load this alternate class.

If set, BaseDataTable instances will use this instances of this class rather than the default class ("Store") to store and retrieve data.

Specified by:
setStoreClass in interface MetaDataModel
Throws:
DataModelException - If an error occurs loading the class.
See Also:
StoreModel, getStoreClass()

getStoreClass

public Class getStoreClass()
                    throws DataModelException
Return the class responsible for data storage and retrieval (implements StoreModel).

Specified by:
getStoreClass in interface MetaDataModel
Returns:
the class used to store/retrieve data
Throws:
DataModelException - If storeClass is not set and an error occurs while trying to load the default class, com.klg.jclass.datasource.Store.

setBinding

public void setBinding(com.klg.jclass.datasource.BindingModel binding)
Set the Binding object associated with this MetaData level.

Specified by:
setBinding in interface MetaDataModel

getBinding

public com.klg.jclass.datasource.BindingModel getBinding()
Return the BindingModel for this level, creating it if it doesn't already exist.

Specified by:
getBinding in interface MetaDataModel
Returns:
the BindingModel for this level.

getProvider

public com.klg.jclass.datasource.ProviderModel getProvider()
Get the provider (if any) for this level.

Specified by:
getProvider in interface MetaDataModel
Returns:
ProviderModel the class which will provide matrix data for this level

See Also:
ProviderModel.getData(com.klg.jclass.datasource.DataModelListener, long, com.klg.jclass.datasource.MetaDataModel), DataTableModel.createTable(com.klg.jclass.datasource.DataModelListener, long, javax.swing.tree.TreeNode), DataTableModel.getTable(long, javax.swing.tree.TreeNode)

setProviderClassName

public void setProviderClassName(String providerModelClassName)
                          throws DataModelException
Set the ProviderModel class name which will provide data for this level. This class will be instantiated and to provide data. If this is the root level this provider's getData method will actually be called to populate the data root.

Specified by:
setProviderClassName in interface MetaDataModel
Throws:
DataModelException - if the provider fails to be instantiated.

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