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

org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema Class Reference

Collaboration diagram for org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SchedulerDatabaseSchema (DatabaseSchema schema)
void addTable (SchedulerDatabaseTable table)
void removeTable (SchedulerDatabaseTable table)
void mergeSchema (SchedulerDatabaseSchema databaseSchema)
ArrayList getTables ()
SchedulerDatabaseTable getTable (String tableName)
boolean hasTable (String tableName)
TransactionExclusiveLock getLock ()
boolean equals (Object other)
String getInformation (boolean longFormat)

Detailed Description

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

Author:
Emmanuel Cecchet
Version:
1.0

Definition at line 40 of file SchedulerDatabaseSchema.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.SchedulerDatabaseSchema DatabaseSchema  schema  ) 
 

Creates a new SchedulerDatabaseSchema instance by cloning an existing DatabaseSchema.

Parameters:
schema the database schema to clone

Definition at line 53 of file SchedulerDatabaseSchema.java.

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

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


Member Function Documentation

void org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.addTable SchedulerDatabaseTable  table  ) 
 

Adds a SchedulerDatabaseTable describing a table of the database.

Parameters:
table the table to add

Definition at line 75 of file SchedulerDatabaseSchema.java.

Referenced by org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.mergeSchema().

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

boolean org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.equals Object  other  ) 
 

Two SchedulerDatabaseSchema are equals if they have the same tables.

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

Definition at line 185 of file SchedulerDatabaseSchema.java.

References org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.getTables().

00186   {
00187     if (!(other instanceof SchedulerDatabaseSchema))
00188       return false;
00189 
00190     if (tables == null)
00191       return ((SchedulerDatabaseSchema) other).getTables() == null;
00192     else
00193       return tables.equals(((SchedulerDatabaseSchema) other).getTables());
00194   }

String org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.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 203 of file SchedulerDatabaseSchema.java.

References org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseTable.getInformation().

00204   {
00205     StringBuffer result = new StringBuffer();
00206     SchedulerDatabaseTable t;
00207     int size = tables.size();
00208     for (int i = 0; i < size; i++)
00209     {
00210       t = (SchedulerDatabaseTable) tables.get(i);
00211       result.append(t.getInformation(longFormat));
00212       result.append(System.getProperty("line.separator"));
00213     }
00214     return result.toString();
00215   }

TransactionExclusiveLock org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.getLock  ) 
 

Returns the lock for this table.

Returns:
a TransactionExclusiveLock instance
See also:
TransactionExclusiveLock

Definition at line 173 of file SchedulerDatabaseSchema.java.

00174   {
00175     return lock;
00176   }

SchedulerDatabaseTable org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.getTable String  tableName  ) 
 

Returns the SchedulerDatabaseTable object matching the given table name or null if not found. Matching is case insensitive.

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

Definition at line 135 of file SchedulerDatabaseSchema.java.

References org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseTable.getName().

Referenced by org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.mergeSchema().

00136   {
00137     SchedulerDatabaseTable t;
00138     int size = tables.size();
00139     for (int i = 0; i < size; i++)
00140     {
00141       t = (SchedulerDatabaseTable) tables.get(i);
00142       if (tableName.equalsIgnoreCase(t.getName()))
00143         return t;
00144     }
00145     return null;
00146   }

ArrayList org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.getTables  ) 
 

Returns an ArrayList of SchedulerDatabaseTable objects describing the database.

Returns:
an ArrayList of SchedulerDatabaseTable

Definition at line 123 of file SchedulerDatabaseSchema.java.

Referenced by org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.equals(), and org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.mergeSchema().

00124   {
00125     return tables;
00126   }

boolean org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.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 155 of file SchedulerDatabaseSchema.java.

References org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseTable.getName().

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

void org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.mergeSchema SchedulerDatabaseSchema  databaseSchema  ) 
 

Merge the given schema with the current one. All missing tables 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

Definition at line 98 of file SchedulerDatabaseSchema.java.

References org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.addTable(), org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseTable.getName(), org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.getTable(), and org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.getTables().

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

void org.objectweb.cjdbc.controller.scheduler.schema.SchedulerDatabaseSchema.removeTable SchedulerDatabaseTable  table  ) 
 

Removes a SchedulerDatabaseTable describing a table of the database.

Parameters:
table the table to remove

Definition at line 86 of file SchedulerDatabaseSchema.java.

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


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