Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema Class Reference

List of all members.

Public Member Functions

 CacheDatabaseSchema (DatabaseSchema dbs)
void addTable (CacheDatabaseTable table)
void removeTable (CacheDatabaseTable table)
void mergeSchema (CacheDatabaseSchema databaseSchema) throws SQLException
ArrayList getTables ()
CacheDatabaseTable getTable (String tableName)
boolean hasTable (String tableName)
boolean equals (Object other)
String getInformation (boolean longFormat)

Detailed Description

A CacheDatabaseSchema describes all the tables and columns of a database and its associated cache entries.

Author:
Emmanuel Cecchet
Version:
1.0

Definition at line 41 of file CacheDatabaseSchema.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.CacheDatabaseSchema DatabaseSchema  dbs  ) 
 

Creates a new CacheDatabaseSchema instance by cloning an existing DatabaseSchema.

Parameters:
dbs the DatabaseSchema to clone

Definition at line 52 of file CacheDatabaseSchema.java.

References org.objectweb.cjdbc.common.sql.schema.DatabaseSchema.getTables().

00053   {
00054     if (dbs == null)
00055     {
00056       tables = new ArrayList();
00057       return;
00058     }
00059 
00060     // Clone the tables
00061     ArrayList origTables = dbs.getTables();
00062     int size = origTables.size();
00063     tables = new ArrayList(size);
00064     for (int i = 0; i < size; i++)
00065       tables.add(new CacheDatabaseTable((DatabaseTable) origTables.get(i)));
00066   }


Member Function Documentation

void org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.addTable CacheDatabaseTable  table  ) 
 

Adds a CacheDatabaseTable describing a table of the database.

Parameters:
table the table to add

Definition at line 74 of file CacheDatabaseSchema.java.

Referenced by org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.mergeSchema().

00075   {
00076     tables.add(table);
00077   }

boolean org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.equals Object  other  ) 
 

Two CacheDatabaseSchema are equals if they have the same tables.

Parameters:
other the object to compare with
Returns:
true if the 2 objects are the same.

Definition at line 176 of file CacheDatabaseSchema.java.

References org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable.equals(), and org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.getTables().

00177   {
00178     if (!(other instanceof CacheDatabaseSchema))
00179       return false;
00180 
00181     if (tables == null)
00182       return ((CacheDatabaseSchema) other).getTables() == null;
00183     else
00184       return tables.equals(((CacheDatabaseSchema) other).getTables());
00185   }

String org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.getInformation boolean  longFormat  ) 
 

Returns information about the database schema.

Parameters:
longFormat true for a long format, false for a short summary
Returns:
a String value

Definition at line 194 of file CacheDatabaseSchema.java.

References org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable.getInformation().

00195   {
00196     String result = "";
00197     int size = tables.size();
00198     for (int i = 0; i < size; i++)
00199     {
00200       CacheDatabaseTable t = (CacheDatabaseTable) tables.get(i);
00201       result += t.getInformation(longFormat) + "\n";
00202     }
00203     return result;
00204   }

CacheDatabaseTable org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.getTable String  tableName  ) 
 

Returns the CacheDatabaseTable object matching the given table name or null if not found.

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

Definition at line 138 of file CacheDatabaseSchema.java.

References org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable.getName().

Referenced by org.objectweb.cjdbc.controller.cache.result.ResultCacheColumnUnique.isUpdateNecessary(), org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.mergeSchema(), org.objectweb.cjdbc.controller.cache.result.ResultCacheTable.processAddToCache(), org.objectweb.cjdbc.controller.cache.result.ResultCacheColumnUnique.processAddToCache(), org.objectweb.cjdbc.controller.cache.result.ResultCacheColumn.processAddToCache(), org.objectweb.cjdbc.controller.cache.result.ResultCacheTable.processWriteNotify(), org.objectweb.cjdbc.controller.cache.result.ResultCacheColumnUnique.processWriteNotify(), and org.objectweb.cjdbc.controller.cache.result.ResultCacheColumn.processWriteNotify().

00139   {
00140     int size = tables.size();
00141     for (int i = 0; i < size; i++)
00142     {
00143       CacheDatabaseTable t = (CacheDatabaseTable) tables.get(i);
00144       if (t.getName().compareTo(tableName) == 0)
00145         return t;
00146     }
00147     return null;
00148   }

ArrayList org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.getTables  ) 
 

Returns an ArrayList of CacheDatabaseTable objects describing the database.

Returns:
an ArrayList of CacheDatabaseTable

Definition at line 126 of file CacheDatabaseSchema.java.

Referenced by org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.equals().

00127   {
00128     return tables;
00129   }

boolean org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.hasTable 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

Definition at line 157 of file CacheDatabaseSchema.java.

References org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable.getName().

00158   {
00159     int size = tables.size();
00160     for (int i = 0; i < size; i++)
00161     {
00162       CacheDatabaseTable t = (CacheDatabaseTable) tables.get(i);
00163       if (tableName.equals(t.getName()))
00164         return true;
00165     }
00166     return false;
00167   }

void org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.mergeSchema CacheDatabaseSchema  databaseSchema  )  throws SQLException
 

Merge 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
Exceptions:
SQLException if the schemas conflict

Definition at line 98 of file CacheDatabaseSchema.java.

References org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.addTable(), org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable.getName(), org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.getTable(), org.objectweb.cjdbc.common.sql.schema.DatabaseSchema.getTables(), and org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable.mergeColumns().

00100   {
00101     if (databaseSchema == null)
00102       return;
00103 
00104     ArrayList otherTables = databaseSchema.getTables();
00105     if (otherTables == null)
00106       return;
00107 
00108     int size = otherTables.size();
00109     for (int i = 0; i < size; i++)
00110     {
00111       CacheDatabaseTable t = (CacheDatabaseTable) otherTables.get(i);
00112       CacheDatabaseTable original = getTable(t.getName());
00113       if (original == null)
00114         addTable(t);
00115       else
00116         original.mergeColumns(t);
00117     }
00118   }

void org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseSchema.removeTable CacheDatabaseTable  table  ) 
 

Removes a CacheDatabaseTable describing a table of the database.

Parameters:
table the table to remove

Definition at line 85 of file CacheDatabaseSchema.java.

00086   {
00087     tables.remove(table);
00088   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:37 2005 for C-JDBC by  doxygen 1.3.9.1