org.objectweb.cjdbc.common.sql.schema
Class DatabaseSchema

java.lang.Object
  extended byorg.objectweb.cjdbc.common.sql.schema.DatabaseSchema
All Implemented Interfaces:
java.io.Serializable

public class DatabaseSchema
extends java.lang.Object
implements java.io.Serializable

A DatabaseSchema describes all the tables and columns of a database.

Version:
1.0
Author:
Emmanuel Cecchet , Nicolas Modrzyk
See Also:
Serialized Form

Field Summary
private  java.util.ArrayList procedures
          ArrayList of DatabaseProcedures.
private static long serialVersionUID
           
private  java.util.ArrayList tables
          ArrayList of DatabaseTables.
 
Constructor Summary
DatabaseSchema()
          Creates a new DatabaseSchema instance.
DatabaseSchema(DatabaseSchema schema)
          Creates a new DatabaseSchema instance from an existing database schema (the schema is cloned).
DatabaseSchema(int nbOfTables)
          Creates a new DatabaseSchema instance with a specified number of tables.
 
Method Summary
 void addProcedure(DatabaseProcedure procedure)
          Adds a DatabaseProcedure describing a procedure of the database.
 void addTable(DatabaseTable table)
          Adds a DatabaseTable describing a table of the database.
 boolean equals(java.lang.Object other)
          Two DatabaseSchema are considered equal if they have the same tables and the same procedures.
 DatabaseProcedure getProcedure(java.lang.String procedureName)
          Returns the DatabaseProcedure object matching the given procedure name or null if not found.
 java.util.ArrayList getProcedures()
          Returns an ArrayList of DatabaseProcedure objects describing the database.
 DatabaseTable getTable(java.lang.String tableName)
          Returns the DatabaseTable object matching the given table name or null if not found.
 DatabaseTable getTable(java.lang.String tableName, boolean isCaseSensitive)
          Returns the DatabaseTable object matching the given table name or null if not found.
 java.util.ArrayList getTables()
          Returns an ArrayList of DatabaseTable objects describing the database.
 java.lang.String getXml()
          Get xml information about this schema.
 boolean hasProcedure(java.lang.String procedureName)
          Returns true if the given ProcedureName is found in this schema.
 boolean hasTable(java.lang.String tableName)
          Returns true if the given TableName is found in this schema.
 boolean isCompatibleSubset(DatabaseSchema other)
          Checks if this DatabaseSchema is a compatible subset of a given schema.
 boolean isCompatibleWith(DatabaseSchema other)
          Checks if this DatabaseSchema is compatible with the given schema.
 void mergeSchema(DatabaseSchema databaseSchema)
          Merges the given schema with the current one.
 boolean removeProcedure(DatabaseProcedure procedure)
          removes a DatabaseProcedure describing a procedure of the database.
 boolean removeTable(DatabaseTable table)
          Removes a DatabaseTable describing a table of the database.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

tables

private java.util.ArrayList tables
ArrayList of DatabaseTables.


procedures

private java.util.ArrayList procedures
ArrayList of DatabaseProcedures.

Constructor Detail

DatabaseSchema

public DatabaseSchema()
Creates a new DatabaseSchema instance.


DatabaseSchema

public DatabaseSchema(int nbOfTables)
Creates a new DatabaseSchema instance with a specified number of tables.

Parameters:
nbOfTables - an int value

DatabaseSchema

public DatabaseSchema(DatabaseSchema schema)
Creates a new DatabaseSchema instance from an existing database schema (the schema is cloned).

Parameters:
schema - the existing database schema
Method Detail

addTable

public void addTable(DatabaseTable table)
Adds a DatabaseTable describing a table of the database.

Parameters:
table - the table to add

addProcedure

public void addProcedure(DatabaseProcedure procedure)
Adds a DatabaseProcedure describing a procedure of the database.

Parameters:
procedure - the procedure to add

removeTable

public boolean removeTable(DatabaseTable table)
Removes a DatabaseTable describing a table of the database.

Parameters:
table - the table to remove
Returns:
true if the table was successfully removed

removeProcedure

public boolean removeProcedure(DatabaseProcedure procedure)
removes a DatabaseProcedure describing a procedure of the database.

Parameters:
procedure - to remove
Returns:
true if the procedure was successfully removed

mergeSchema

public void mergeSchema(DatabaseSchema databaseSchema)
                 throws java.sql.SQLException
Merges the given schema with the current one. All missing tables or columns are added if no conflict is detected. An exception is thrown if the given schema definition conflicts with the current one.

Parameters:
databaseSchema - the schema to merge
Throws:
java.sql.SQLException - if the schemas conflict

getTables

public java.util.ArrayList getTables()
Returns an ArrayList of DatabaseTable objects describing the database.

Returns:
an ArrayList of DatabaseTable

getProcedures

public java.util.ArrayList getProcedures()
Returns an ArrayList of DatabaseProcedure objects describing the database.

Returns:
an ArrayList of DatabaseProcedure

getTable

public DatabaseTable getTable(java.lang.String tableName)
Returns the DatabaseTable object matching the given table name or null if not found.

Parameters:
tableName - the table name to look for
Returns:
a DatabaseTable value or null

getProcedure

public DatabaseProcedure getProcedure(java.lang.String procedureName)
Returns the DatabaseProcedure object matching the given procedure name or null if not found.

Parameters:
procedureName - the procedure name to look for
Returns:
a DatabaseProcedure value or null

getTable

public DatabaseTable getTable(java.lang.String tableName,
                              boolean isCaseSensitive)
Returns the DatabaseTable object matching the given table name or null if not found. An extra boolean indicates if table name matching is case sensitive or not.

Parameters:
tableName - the table name to look for
isCaseSensitive - true if name matching must be case sensitive
Returns:
a DatabaseTable value or null

hasTable

public boolean hasTable(java.lang.String tableName)
Returns true if the given TableName is found in this schema.

Parameters:
tableName - the name of the table you are looking for
Returns:
true if the table has been found

hasProcedure

public boolean hasProcedure(java.lang.String procedureName)
Returns true if the given ProcedureName is found in this schema.

Parameters:
procedureName - the name of the procedure you are looking for
Returns:
true if the procedure has been found

isCompatibleSubset

public boolean isCompatibleSubset(DatabaseSchema other)
Checks if this DatabaseSchema is a compatible subset of a given schema. It means that all tables in this schema must be present with the same definition in the other schema.

Parameters:
other - the object to compare with
Returns:
true if the two schemas are compatible

isCompatibleWith

public boolean isCompatibleWith(DatabaseSchema other)
Checks if this DatabaseSchema is compatible with the given schema. It means that all tables in this schema that are common with the other schema must be identical.

Parameters:
other - the object to compare with
Returns:
true if the two schemas are compatible

equals

public boolean equals(java.lang.Object other)
Two DatabaseSchema are considered equal if they have the same tables and the same procedures.

Parameters:
other - the object to compare with
Returns:
true if the schemas are equals

getXml

public java.lang.String getXml()
Get xml information about this schema.

Returns:
xml formatted information on this database schema.


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.