com.workingdogs.village
Class Schema

java.lang.Object
  extended by com.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.

Version:
$Revision: 568 $
Author:
Jon S. Stevens, John D. McNally

Constructor Summary
Schema()
          A blank Schema object
 
Method Summary
 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
 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.
static void initSchemas(java.sql.Connection conn)
          Initialize all table schemas reachable from this connection
 boolean isSingleTable()
          Checks to see if this DataSet represents one table in the database.
 int numberOfColumns()
          Gets the number of columns in this Schema
 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
 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
 

Constructor Detail

Schema

public Schema()
A blank Schema object

Method Detail

initSchemas

public static void initSchemas(java.sql.Connection conn)
                        throws java.sql.SQLException
Initialize all table schemas reachable from this connection

Parameters:
conn - a database connection
Throws:
java.sql.SQLException - if retrieving the database meta data is unsuccessful

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

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

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 - TODO: DOCUMENT ME!

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

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 - TODO: DOCUMENT ME!

toString

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

Overrides:
toString in class java.lang.Object
Returns:
a string


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.