org.rimudb
Class TableMetaData

java.lang.Object
  extended by org.rimudb.TableMetaData

public class TableMetaData
extends java.lang.Object

This class contains the meta data for a table. Since the data is very static, and there is only one instance of this class per Table, it caches almost all calculated values.

Author:
Simon Ritchie

Constructor Summary
TableMetaData()
           
 
Method Summary
 void add(ColumnMetaData columnMetaData)
           
 void checkForNulledPrimaryKey(java.util.List<java.lang.String> modifiedToNullPropertyList)
          Check the list of nulled properties for a primary key.
 void clearCachedValues()
          Clear the cached values.
 void disableAutoIncrement()
          Disable auto increment keys.
 java.util.List<ColumnMetaData> getAllColumns()
          Return a List of ColumnMetaData instances for the key columns.
 ColumnMetaData getAutoIncrementColumn()
          Return the auto increment column.
 int getColumnCount()
          Return the number of columns in the table.
 ColumnMetaData getColumnMetaData(int index)
          Return the ColumnMetaData for a given index
 java.lang.String getColumnNameFromPropertyName(java.lang.String propertyName)
          Return the column name for a given property name.
 java.lang.String[] getColumnNames()
          Return an array of all the columns names
 java.util.List<java.lang.String> getColumnNamesFromPropertyNames(java.util.List<java.lang.String> nullPropertyList)
           
 java.lang.String getDatabaseProductName()
           
 java.lang.String getDelimitedColumnNames(boolean includeAutoIncrement, ColumnQuoter quoter)
          Return a comma delimited String of column names, excluding auto-increment keys.
 java.lang.String getDelimitedColumnNamesWithParameterMarkers(java.util.List<java.lang.String> propertyNameList, OptimisticLocking optimisticLocking, ColumnQuoter quoter)
          Return a comma delimited String of column names and parameter markers.
 java.lang.String getDelimitedMarkers()
          Return a String of parameter markers.
 java.lang.String getDelimitedNonKeyColumnNamesWithParameterMarkers()
          Return a string containing the non-key column names and parameter markers delimited by commas.
 java.lang.String getDelimitedPrimaryKeyColumns(ColumnQuoter quoter)
          Return a comma delimited String of primary key columns.
 java.lang.String getIdentitySequenceName()
          Return the name of the sequence for the auto increment column.
 ColumnMetaData getMetaDataByColumnName(java.lang.String columnName)
          Return the ColumnMetaData for a given columnName.
 ColumnMetaData getMetaDataByPropertyName(java.lang.String propertyName)
          Return the ColumnMetaData for a given propertyName
 java.util.List<ColumnMetaData> getNonPKColumns()
          Return a List of ColumnMetaData instances for the non-key columns.
 ColumnMetaData getPKColumnAt(int keyIndex)
          Return the ColumnMetaData for a given keyIndex.
 int getPKColumnCount()
          Return the number of keys in the primary key
 java.util.List<java.lang.String> getPKColumnNames()
          Return a list of column names
 java.util.List<ColumnMetaData> getPKColumns()
          Return a List of ColumnMetaData instances for the key columns.
 java.lang.String getPrimaryKeyParameterMarkers(ColumnQuoter quoter)
          Return the primary key columns with parameter markers i.e.
 java.lang.String getTableName()
          Return the table name.
 java.lang.String getUpdateParameterMarkers(OptimisticLocking optimisticLocking, java.util.List<java.lang.String> changedPropertyList, java.util.List<java.lang.String> nullColumnList, ColumnQuoter quoter)
           
 ColumnMetaData getVersionColumn()
          Return the version column.
 boolean hasAutoIncrementKeys()
          Return true if one of the columns is auto-increment
 void setDatabaseProductName(java.lang.String databaseProductName)
           
 void setTableName(java.lang.String tableName)
          Set the table name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableMetaData

public TableMetaData()
Method Detail

clearCachedValues

public void clearCachedValues()
Clear the cached values. This is used for testing the MetaData.


add

public void add(ColumnMetaData columnMetaData)

getColumnMetaData

public ColumnMetaData getColumnMetaData(int index)
Return the ColumnMetaData for a given index

Parameters:
index - int
Returns:
ColumnMetaData

getColumnNames

public java.lang.String[] getColumnNames()
Return an array of all the columns names

Returns:
String[]

getDelimitedColumnNames

public java.lang.String getDelimitedColumnNames(boolean includeAutoIncrement,
                                                ColumnQuoter quoter)
Return a comma delimited String of column names, excluding auto-increment keys.

Returns:
String

getPrimaryKeyParameterMarkers

public java.lang.String getPrimaryKeyParameterMarkers(ColumnQuoter quoter)
Return the primary key columns with parameter markers i.e. COLUMN1 = ? AND COLUMN2 = ? and COLUMN3 = ?

Returns:
String

getUpdateParameterMarkers

public java.lang.String getUpdateParameterMarkers(OptimisticLocking optimisticLocking,
                                                  java.util.List<java.lang.String> changedPropertyList,
                                                  java.util.List<java.lang.String> nullColumnList,
                                                  ColumnQuoter quoter)

getColumnCount

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

Returns:
int

getDelimitedNonKeyColumnNamesWithParameterMarkers

public java.lang.String getDelimitedNonKeyColumnNamesWithParameterMarkers()
Return a string containing the non-key column names and parameter markers delimited by commas. This is used on an update statement. i.e. COLUMN1 = ?, COLUMN2 = ?, COLUMN3 = ?

Returns:
String

getNonPKColumns

public java.util.List<ColumnMetaData> getNonPKColumns()
Return a List of ColumnMetaData instances for the non-key columns.

Returns:
List

getPKColumns

public java.util.List<ColumnMetaData> getPKColumns()
Return a List of ColumnMetaData instances for the key columns.

Returns:
List

getPKColumnNames

public java.util.List<java.lang.String> getPKColumnNames()
Return a list of column names

Returns:
List

getAllColumns

public java.util.List<ColumnMetaData> getAllColumns()
Return a List of ColumnMetaData instances for the key columns.

Returns:
List

getDelimitedColumnNamesWithParameterMarkers

public java.lang.String getDelimitedColumnNamesWithParameterMarkers(java.util.List<java.lang.String> propertyNameList,
                                                                    OptimisticLocking optimisticLocking,
                                                                    ColumnQuoter quoter)
Return a comma delimited String of column names and parameter markers.

Parameters:
propertyNameList - List
optimisticLocking - OptimisticLocking
quoter - ColumnQuoter
Returns:
String

getMetaDataByPropertyName

public ColumnMetaData getMetaDataByPropertyName(java.lang.String propertyName)
Return the ColumnMetaData for a given propertyName

Parameters:
propertyName - String
Returns:
ColumnMetaData

getDelimitedMarkers

public java.lang.String getDelimitedMarkers()
Return a String of parameter markers. The number of markers is determined by the number of columns. i.e. ?, ?, ?, ?, ?

Returns:
String

hasAutoIncrementKeys

public boolean hasAutoIncrementKeys()
Return true if one of the columns is auto-increment

Returns:
boolean.

getMetaDataByColumnName

public ColumnMetaData getMetaDataByColumnName(java.lang.String columnName)
Return the ColumnMetaData for a given columnName. The match is case insensitive.

Parameters:
columnName - String
Returns:
ColumnMetaData

getPKColumnAt

public ColumnMetaData getPKColumnAt(int keyIndex)
Return the ColumnMetaData for a given keyIndex.

Parameters:
keyIndex - int
Returns:
ColumnMetaData

getPKColumnCount

public int getPKColumnCount()
Return the number of keys in the primary key

Returns:
int

getColumnNameFromPropertyName

public java.lang.String getColumnNameFromPropertyName(java.lang.String propertyName)
Return the column name for a given property name.

Parameters:
propertyName - String
Returns:
String

getDelimitedPrimaryKeyColumns

public java.lang.String getDelimitedPrimaryKeyColumns(ColumnQuoter quoter)
Return a comma delimited String of primary key columns.

Parameters:
quoter - ColumnQuoter
Returns:
String

getAutoIncrementColumn

public ColumnMetaData getAutoIncrementColumn()
Return the auto increment column. Assume there is only ever a single auto increment column.

Returns:
ColumnMetaData

getVersionColumn

public ColumnMetaData getVersionColumn()
Return the version column. Assume there is only ever a single version column.

Returns:
ColumnMetaData

getIdentitySequenceName

public java.lang.String getIdentitySequenceName()
Return the name of the sequence for the auto increment column.

Returns:
String

setTableName

public void setTableName(java.lang.String tableName)
Set the table name.

Parameters:
tableName - String

getTableName

public java.lang.String getTableName()
Return the table name.

Returns:
String

getColumnNamesFromPropertyNames

public java.util.List<java.lang.String> getColumnNamesFromPropertyNames(java.util.List<java.lang.String> nullPropertyList)
Parameters:
nullPropertyList - List
Returns:
List

checkForNulledPrimaryKey

public void checkForNulledPrimaryKey(java.util.List<java.lang.String> modifiedToNullPropertyList)
                              throws RimuDBException
Check the list of nulled properties for a primary key.

Parameters:
modifiedToNullPropertyList - List
Throws:
RimuDBException

disableAutoIncrement

public void disableAutoIncrement()
Disable auto increment keys.


setDatabaseProductName

public void setDatabaseProductName(java.lang.String databaseProductName)
Parameters:
databaseProductName - the databaseProductName to set

getDatabaseProductName

public java.lang.String getDatabaseProductName()
Returns:
the databaseProductName


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.