com.healthmarketscience.sqlbuilder.dbspec.basic
Class DbSchema

java.lang.Object
  extended by com.healthmarketscience.sqlbuilder.dbspec.basic.DbObject<DbObject<?>>
      extended by com.healthmarketscience.sqlbuilder.dbspec.basic.DbSchema

public class DbSchema
extends DbObject<DbObject<?>>

Representation of a database schema, for aggregating tables, indexes, and function packages.

Author:
James Ahlborn

Constructor Summary
DbSchema(DbSpec spec, String name)
           
 
Method Summary
 DbFunctionPackage addDefaultFunctionPackage()
          Creates and adds a package with no name to this spec (often referred to as the default package).
 DbFunctionPackage addFunctionPackage(String name)
          Creates and adds a package with the given name to this spec.
<T extends DbFunctionPackage>
T
addFunctionPackage(T functionPackage)
          Adds the given functionPackage to this schema.
 DbIndex addIndex(String name, String tableName, String... colNames)
          Creates and adds a index with the given parameters to this schema.
<T extends DbIndex>
T
addIndex(T index)
          Adds the given index to this schema.
 DbTable addTable(String name)
          Creates and adds a table with the given name to this schema.
<T extends DbTable>
T
addTable(T table)
          Adds the given table to this schema.
 DbFunctionPackage findFunctionPackage(String name)
           
 DbIndex findIndex(String name)
           
 DbTable findTable(String name)
           
 DbFunctionPackage getDefaultFunctionPackage()
           
 List<DbFunctionPackage> getFunctionPackages()
           
 List<DbIndex> getIndexs()
           
 DbSpec getSpec()
          Default implementation returns the parent's spec.
 List<DbTable> getTables()
           
 
Methods inherited from class com.healthmarketscience.sqlbuilder.dbspec.basic.DbObject
addObjects, checkOwnership, checkOwnership, findObject, getAbsoluteName, getName, getParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DbSchema

public DbSchema(DbSpec spec,
                String name)
Method Detail

getSpec

public DbSpec getSpec()
Description copied from class: DbObject
Default implementation returns the parent's spec.

Overrides:
getSpec in class DbObject<DbObject<?>>
Returns:
the db spec this db object is associated with

getTables

public List<DbTable> getTables()

getIndexs

public List<DbIndex> getIndexs()

getFunctionPackages

public List<DbFunctionPackage> getFunctionPackages()

findTable

public DbTable findTable(String name)
Parameters:
name - name of the table to find
Returns:
the table previously added to this schema with the given name, or null if none.

addTable

public DbTable addTable(String name)
Creates and adds a table with the given name to this schema.

Note, no effort is made to make sure the given name is unique.

Parameters:
name - the name of the new table
Returns:
the freshly created table

addTable

public <T extends DbTable> T addTable(T table)
Adds the given table to this schema.

Note, no effort is made to make sure the given table is unique.

Parameters:
table - the table to be added
Returns:
the given table

findIndex

public DbIndex findIndex(String name)
Parameters:
name - name of the index to find
Returns:
the index previously added to this schema with the given name, or null if none.

addIndex

public DbIndex addIndex(String name,
                        String tableName,
                        String... colNames)
Creates and adds a index with the given parameters to this schema.

Note, no effort is made to make sure the given name is unique.

Parameters:
name - the name of the new index
tableName - name of the table indexed
colNames - names of the columns indexed in the given table
Returns:
the freshly created index

addIndex

public <T extends DbIndex> T addIndex(T index)
Adds the given index to this schema.

Note, no effort is made to make sure the given index is unique.

Parameters:
index - the index to be added
Returns:
the given index

getDefaultFunctionPackage

public DbFunctionPackage getDefaultFunctionPackage()
Returns:
the default package previously added to this spec, or null if none.

findFunctionPackage

public DbFunctionPackage findFunctionPackage(String name)
Parameters:
name - name of the package to find
Returns:
the package previously added to this spec with the given name, or null if none.

addDefaultFunctionPackage

public DbFunctionPackage addDefaultFunctionPackage()
Creates and adds a package with no name to this spec (often referred to as the default package).

Note, no effort is made to make sure the package is unique.

Returns:
the freshly created default package

addFunctionPackage

public DbFunctionPackage addFunctionPackage(String name)
Creates and adds a package with the given name to this spec.

Note, no effort is made to make sure the given name is unique.

Parameters:
name - the name of the new package
Returns:
the freshly created package

addFunctionPackage

public <T extends DbFunctionPackage> T addFunctionPackage(T functionPackage)
Adds the given functionPackage to this schema.

Note, no effort is made to make sure the given functionPackage is unique.

Parameters:
functionPackage - the functionPackage to be added
Returns:
the given functionPackage


Copyright © 2006–2017 Health Market Science. All rights reserved.