edu.iris.dmc.pdcc.container
Class PdccTableInfo

java.lang.Object
  extended byedu.iris.dmc.pdcc.container.PdccTableInfo

public class PdccTableInfo
extends java.lang.Object

Reports characteristics of PDCC database tables and assists the linkage to Blockette object fields.

Version:
2/7/2003
Author:
Robert Casey, IRIS DMC

Constructor Summary
PdccTableInfo(java.lang.String schemaFile)
          Create an instance that describes the table characteristics represented in the indicated schema file.
 
Method Summary
 int getBlocketteType(java.lang.String tableName)
          return Blockette type associated with the indicated table name.
 java.util.Vector getChildTables(java.lang.String parentTableName)
          return a vector of child table names mapped to the indicated parent table name
 int getCountField(java.lang.String tableName, java.lang.String toTableName)
          return the field number in tableName that refers to the count of toTableName records pointing to it.
 int[] getDKeyTableFields(java.lang.String tableName)
          return an array of field numbers indicating database table fields, starting with field number 0, which are DKEY (database key) fields.
 java.lang.String getDKeyTableName(java.lang.String tableName, int fieldNum)
          return the dictionary table name that this field references, using the DKEY attribute keyword.
 java.lang.String getFieldName(java.lang.String tableName, int fieldNum)
          Get the name of the field for the indicated table and field number.
 java.util.Vector getFieldNames(java.lang.String tableName)
          Get a vector of field names for the given table.
 java.lang.String getFieldType(java.lang.String tableName, int fieldNum)
          Get the data type of the indicated db field from the indicated db table.
 java.util.Vector getFKeyField(java.lang.String tableName)
          return a vector of field numbers as Integers, each pertaining to a field with an FKEY reference to another table.
 int getFKeyField(java.lang.String tableName, java.lang.String toTableName)
          return the field number in tableName that refers to the primary key id of toTableName.
 java.util.Vector getFKeyNames(java.lang.String tableName)
          return the table names of this table's FKEY fields.
 int getNumberFields(java.lang.String tableName)
          Get the number of fields in the indicated table
 int getPKeyField(java.lang.String tableName)
          return the field number, starting with 0 for the first field, that contains the Primary Key for a record in the indicated table.
 int getSeqField(java.lang.String tableName)
          return the field number in tableName that contains a sequence number, used for maintaining list order of a set of related tables.
 java.lang.String getTableName(int blkType, int blkFieldNum)
          return the name of the table that maps to the indicated blockette type and blockette field number.
 java.util.Vector getTablesForBlockette(int blocketteType)
          Get a vector of table names associated with the provided blockette type number.
 java.util.Vector getTableToBlocketteFields(java.lang.String tableName, int blocketteType)
          Returns a vector of Integers indicating the relationship of table fields to blockette fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdccTableInfo

public PdccTableInfo(java.lang.String schemaFile)
              throws java.lang.Exception
Create an instance that describes the table characteristics represented in the indicated schema file.

Parameters:
schemaFile - the schema file to be read and represented by this instance.
Throws:
java.lang.Exception
Method Detail

getFieldNames

public java.util.Vector getFieldNames(java.lang.String tableName)
Get a vector of field names for the given table.

Parameters:
tableName - name of the table in question
Returns:

getNumberFields

public int getNumberFields(java.lang.String tableName)
Get the number of fields in the indicated table

Parameters:
tableName -
Returns:

getFieldName

public java.lang.String getFieldName(java.lang.String tableName,
                                     int fieldNum)
                              throws PdccDbException
Get the name of the field for the indicated table and field number. The field number is the db field as indicated in the registered db schema, where the first field is numbered 0.

Parameters:
tableName - name of the db table
fieldNum - db schema field number counting from 0
Returns:
Throws:
PdccDbException

getFieldType

public java.lang.String getFieldType(java.lang.String tableName,
                                     int fieldNum)
                              throws PdccDbException
Get the data type of the indicated db field from the indicated db table.

Parameters:
tableName -
fieldNum - first fieldNum == 0
Returns:
Throws:
PdccDbException

getBlocketteType

public int getBlocketteType(java.lang.String tableName)
                     throws PdccDbException
return Blockette type associated with the indicated table name. upon failure, return -1.

Throws:
PdccDbException

getTablesForBlockette

public java.util.Vector getTablesForBlockette(int blocketteType)
                                       throws PdccDbException
Get a vector of table names associated with the provided blockette type number.

Parameters:
blocketteType -
Returns:
Throws:
PdccDbException

getTableToBlocketteFields

public java.util.Vector getTableToBlocketteFields(java.lang.String tableName,
                                                  int blocketteType)
                                           throws PdccDbException
Returns a vector of Integers indicating the relationship of table fields to blockette fields. [tField1,bField1,tField2,bField2,...]

Parameters:
tableName - the db table in question
blocketteType - the blockette type in question
Returns:
Throws:
PdccDbException

getPKeyField

public int getPKeyField(java.lang.String tableName)
                 throws PdccDbException
return the field number, starting with 0 for the first field, that contains the Primary Key for a record in the indicated table. return a -1 if not found.

Throws:
PdccDbException

getFKeyNames

public java.util.Vector getFKeyNames(java.lang.String tableName)
                              throws PdccDbException
return the table names of this table's FKEY fields. return null if no FKEY fields present.

Throws:
PdccDbException

getFKeyField

public java.util.Vector getFKeyField(java.lang.String tableName)
                              throws PdccDbException
return a vector of field numbers as Integers, each pertaining to a field with an FKEY reference to another table. Return a null if no fields.

Throws:
PdccDbException

getFKeyField

public int getFKeyField(java.lang.String tableName,
                        java.lang.String toTableName)
                 throws PdccDbException
return the field number in tableName that refers to the primary key id of toTableName. First field == 0. If no reference can be found, return -1.

Throws:
PdccDbException

getCountField

public int getCountField(java.lang.String tableName,
                         java.lang.String toTableName)
                  throws PdccDbException
return the field number in tableName that refers to the count of toTableName records pointing to it. First field == 0; If not found, return -1.

Throws:
PdccDbException

getSeqField

public int getSeqField(java.lang.String tableName)
                throws PdccDbException
return the field number in tableName that contains a sequence number, used for maintaining list order of a set of related tables. the first field would be number 0. return -1 if none found.

Throws:
PdccDbException

getTableName

public java.lang.String getTableName(int blkType,
                                     int blkFieldNum)
                              throws PdccDbException
return the name of the table that maps to the indicated blockette type and blockette field number. If no match is found, return an empty string.

Throws:
PdccDbException

getDKeyTableFields

public int[] getDKeyTableFields(java.lang.String tableName)
                         throws PdccDbException
return an array of field numbers indicating database table fields, starting with field number 0, which are DKEY (database key) fields. If no DKEY fields exist, return null.

Throws:
PdccDbException

getDKeyTableName

public java.lang.String getDKeyTableName(java.lang.String tableName,
                                         int fieldNum)
                                  throws PdccDbException
return the dictionary table name that this field references, using the DKEY attribute keyword. Return null if no dictionary table is referenced. fieldNum for the first field is 0.

Throws:
PdccDbException

getChildTables

public java.util.Vector getChildTables(java.lang.String parentTableName)
return a vector of child table names mapped to the indicated parent table name

Parameters:
parentTableName -
Returns:


brought to you by Incorporated Research Institutions for Seismology
June 29 2006