org.objectweb.cjdbc.controller.cache.result.schema
Class CacheDatabaseTable

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable

public class CacheDatabaseTable
extends java.lang.Object

A CacheDatabaseTable represents a database table and its associated cache entries. It has an array of CacheDatabaseColumn objects.

Keep it mind that ArrayList and HashMap are not synchronized...

Version:
1.0
Author:
Emmanuel Cecchet , Sara Bouchenak

Field Summary
private  java.util.ArrayList cacheEntries
           
private  java.util.ArrayList columns
           
private  java.lang.String name
           
private  java.util.HashMap pkCacheEntries
           
 
Constructor Summary
CacheDatabaseTable(DatabaseTable databaseTable)
          Creates a new CacheDatabaseTable instance.
 
Method Summary
 void addCacheEntry(AbstractResultCacheEntry ce)
          Adds an AbstractResultCacheEntry object whose consistency depends on this table.
 void addColumn(CacheDatabaseColumn column)
          Adds a CacheDatabaseColumn object to this table.
 void addPkCacheEntry(java.lang.String pk, AbstractResultCacheEntry ce)
          Adds an AbstractResultCacheEntry object associated to a pk entry.
 boolean equals(java.lang.Object other)
          Two CacheDatabaseColumn are equals if they have the same name and the same columns.
 CacheDatabaseColumn getColumn(java.lang.String columnName)
          Returns the CacheDatabaseColumn object matching the given column name or null if not found.
 java.util.ArrayList getColumns()
          Returns a list of CacheDatabaseColumn objects describing the columns of this table.
 java.lang.String getInformation(boolean longFormat)
          Returns information about the database table and its columns.
 java.lang.String getName()
          Gets the name of the table.
 AbstractResultCacheEntry getPkResultCacheEntry(java.lang.String pk)
          Gets a CacheEntry object associated to a pk entry.
 void invalidateAll()
          Invalidates all cache entries of every column of this table.
 void invalidateAllExceptPk()
          Invalidates all cache entries of every column of this table.
 void mergeColumns(CacheDatabaseTable t)
          Merge the given table's columns with the current table.
 void removePkResultCacheEntry(java.lang.Object pk)
          Remove a CacheEntry object associated to a pk entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name

columns

private java.util.ArrayList columns

cacheEntries

private java.util.ArrayList cacheEntries

pkCacheEntries

private java.util.HashMap pkCacheEntries
Constructor Detail

CacheDatabaseTable

public CacheDatabaseTable(DatabaseTable databaseTable)
Creates a new CacheDatabaseTable instance.

Parameters:
databaseTable - the database table to cache
Method Detail

getName

public java.lang.String getName()
Gets the name of the table.

Returns:
the table name

addColumn

public void addColumn(CacheDatabaseColumn column)
Adds a CacheDatabaseColumn object to this table.

Warning! The underlying ArrayList is not synchronized.

Parameters:
column - a CacheDatabaseColumn value

mergeColumns

public void mergeColumns(CacheDatabaseTable t)
                  throws java.sql.SQLException
Merge the given table's columns with the current table. All missing columns are added if no conflict is detected. An exception is thrown if the given table columns conflicts with the current one.

Parameters:
t - the table to merge
Throws:
java.sql.SQLException - if the schemas conflict

getColumns

public java.util.ArrayList getColumns()
Returns a list of CacheDatabaseColumn objects describing the columns of this table.

Warning! The underlying ArrayList is not synchronized.

Returns:
an ArrayList of CacheDatabaseColumn

getColumn

public CacheDatabaseColumn getColumn(java.lang.String columnName)
Returns the CacheDatabaseColumn object matching the given column name or null if not found.

Parameters:
columnName - column name to look for
Returns:
a CacheDatabaseColumn value or null

equals

public boolean equals(java.lang.Object other)
Two CacheDatabaseColumn are equals if they have the same name and the same columns.

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

addCacheEntry

public void addCacheEntry(AbstractResultCacheEntry ce)
Adds an AbstractResultCacheEntry object whose consistency depends on this table.

Parameters:
ce - an AbstractResultCacheEntry value

addPkCacheEntry

public void addPkCacheEntry(java.lang.String pk,
                            AbstractResultCacheEntry ce)
Adds an AbstractResultCacheEntry object associated to a pk entry.

Parameters:
pk - the pk entry
ce - an AbstractResultCacheEntry value

getPkResultCacheEntry

public AbstractResultCacheEntry getPkResultCacheEntry(java.lang.String pk)
Gets a CacheEntry object associated to a pk entry.

Parameters:
pk - the pk entry
Returns:
the corresponding cache entry if any or null if nothing is found

removePkResultCacheEntry

public void removePkResultCacheEntry(java.lang.Object pk)
Remove a CacheEntry object associated to a pk entry.

Parameters:
pk - the pk entry

invalidateAll

public void invalidateAll()
Invalidates all cache entries of every column of this table. This does also affect the entries based on pk values.


invalidateAllExceptPk

public void invalidateAllExceptPk()
Invalidates all cache entries of every column of this table. This does not affect the entries based on pk values.


getInformation

public java.lang.String getInformation(boolean longFormat)
Returns information about the database table and its columns.

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


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