com.workingdogs.village
Class Schema

java.lang.Object
  extended bycom.workingdogs.village.Schema

public final class Schema
extends java.lang.Object

The Schema object represents the Columns in a database table. It contains a collection of Column objects.

Author:
Jon S. Stevens jon@latchkey.com, John D. McNally

Field Summary
private  Column[] columns
           
private  java.lang.String columnsAttribute
           
private  int numberOfColumns
           
private static java.util.Hashtable schemaCache
           
private  boolean singleTable
           
private  java.util.Hashtable tableHash
          This attribute is used to complement columns in the event that this schema represents more than one table.
private  java.lang.String tableName
           
 
Constructor Summary
Schema()
          A blank Schema object
 
Method Summary
(package private)  void appendTableName(java.lang.String app)
          Appends data to the tableName that this schema was first created with.
 java.lang.String attributes()
          List of columns to select from the table
 Column column(int i)
          Returns the requested Column object at index i
 Column column(java.lang.String colName)
          Returns the requested Column object by name
 java.lang.String[] getAllTableNames()
          returns all table names that this Schema represents
 Column getColumn(java.lang.String colName)
          Returns the requested Column object by name
 Column getColumn(java.lang.String tableName, java.lang.String colName)
          Returns the requested Column object belonging to the specified table by name
(package private)  Column[] getColumns()
          Returns an array of columns
 java.lang.String getTableName()
          returns the table name that this Schema represents
 int index(java.lang.String colName)
          Gets the index position of a named column.
 int index(java.lang.String tableName, java.lang.String colName)
          Gets the index position of a named column.
 boolean isSingleTable()
          Checks to see if this DataSet represents one table in the database.
 int numberOfColumns()
          Gets the number of columns in this Schema
(package private)  void populate(java.sql.ResultSetMetaData meta, java.lang.String tableName)
          Internal method which populates this Schema object with Columns.
 Schema schema(java.sql.Connection conn, java.lang.String tableName)
          Creates a Schema with all columns
 Schema schema(java.sql.Connection conn, java.lang.String tableName, java.lang.String columnsAttribute)
          Creates a Schema with the named columns in the columnsAttribute
(package private)  void setAttributes(java.lang.String attributes)
          Sets the columns to select from the table
(package private)  void setTableName(java.lang.String tableName)
          Sets the table name that this Schema represents
 java.lang.String tableName()
          returns the table name that this Schema represents
 java.lang.String toString()
          This returns a representation of this Schema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tableName

private java.lang.String tableName

columnsAttribute

private java.lang.String columnsAttribute

numberOfColumns

private int numberOfColumns

columns

private Column[] columns

schemaCache

private static java.util.Hashtable schemaCache

tableHash

private java.util.Hashtable tableHash
This attribute is used to complement columns in the event that this schema represents more than one table. Its keys are String contains table names and its elements are Hashtables containing columns.


singleTable

private boolean singleTable
Constructor Detail

Schema

public Schema()
A blank Schema object

Method Detail

schema

public Schema schema(java.sql.Connection conn,
                     java.lang.String tableName)
              throws java.sql.SQLException,
                     DataSetException
Creates a Schema with all columns

Parameters:
conn -
tableName -
Returns:
an instance of myself
Throws:
java.sql.SQLException
DataSetException

schema

public Schema schema(java.sql.Connection conn,
                     java.lang.String tableName,
                     java.lang.String columnsAttribute)
              throws java.sql.SQLException,
                     DataSetException
Creates a Schema with the named columns in the columnsAttribute

Parameters:
conn -
tableName -
columnsAttribute -
Returns:
an instance of myself
Throws:
java.sql.SQLException
DataSetException

appendTableName

void appendTableName(java.lang.String app)
Appends data to the tableName that this schema was first created with.

Parameters:
app - String to append to tableName
See Also:
TableDataSet.tableQualifier(java.lang.String)

attributes

public java.lang.String attributes()
List of columns to select from the table

Returns:
the list of columns to select from the table

column

public Column column(int i)
              throws DataSetException
Returns the requested Column object at index i

Parameters:
i -
Returns:
the requested column
Throws:
DataSetException

column

public Column column(java.lang.String colName)
              throws DataSetException
Returns the requested Column object by name

Parameters:
colName -
Returns:
the requested column
Throws:
DataSetException

getColumn

public Column getColumn(java.lang.String colName)
                 throws DataSetException
Returns the requested Column object by name

Parameters:
colName -
Returns:
the requested column
Throws:
DataSetException

getColumn

public Column getColumn(java.lang.String tableName,
                        java.lang.String colName)
                 throws DataSetException
Returns the requested Column object belonging to the specified table by name

Parameters:
tableName -
colName -
Returns:
the requested column, null if a column by the specified name does not exist.
Throws:
DataSetException

getColumns

Column[] getColumns()
Returns an array of columns

Returns:
an array of columns

getTableName

public java.lang.String getTableName()
                              throws DataSetException
returns the table name that this Schema represents

Returns:
the table name that this Schema represents
Throws:
DataSetException

getAllTableNames

public java.lang.String[] getAllTableNames()
returns all table names that this Schema represents

Returns:
the table names that this Schema represents

index

public int index(java.lang.String colName)
          throws DataSetException
Gets the index position of a named column. If multiple tables are represented and they have columns with the same name, this method returns the first one listed, if the table name is not specified.

Parameters:
colName -
Returns:
the requested column index integer
Throws:
DataSetException

index

public int index(java.lang.String tableName,
                 java.lang.String colName)
          throws DataSetException
Gets the index position of a named column.

Parameters:
tableName -
colName -
Returns:
the requested column index integer
Throws:
DataSetException

isSingleTable

public boolean isSingleTable()
Checks to see if this DataSet represents one table in the database.

Returns:
true if only one table is represented, false otherwise.

numberOfColumns

public int numberOfColumns()
Gets the number of columns in this Schema

Returns:
integer number of columns

populate

void populate(java.sql.ResultSetMetaData meta,
              java.lang.String tableName)
        throws java.sql.SQLException,
               DataSetException
Internal method which populates this Schema object with Columns.

Parameters:
meta - The meta data of the ResultSet used to build this Schema.
tableName - The name of the table referenced in this schema, or null if unknown or multiple tables are involved.
Throws:
java.sql.SQLException
DataSetException

setAttributes

void setAttributes(java.lang.String attributes)
Sets the columns to select from the table

Parameters:
attributes - comma separated list of column names

setTableName

void setTableName(java.lang.String tableName)
Sets the table name that this Schema represents

Parameters:
tableName -

tableName

public java.lang.String tableName()
                           throws DataSetException
returns the table name that this Schema represents

Returns:
the table name that this Schema represents
Throws:
DataSetException

toString

public java.lang.String toString()
This returns a representation of this Schema

Returns:
a string


Copyright © 1999-2002 Share.Whichever.com All Rights Reserved.