ccs.cdb
Class ChromeCache

java.lang.Object
  extended by ccs.cdb.ChromeCache

public class ChromeCache
extends java.lang.Object

This class retrives a file - frequently these files are "chrome" of some kind, hence the name - from a CDB you've previously given it.


Constructor Summary
ChromeCache()
          Build a new ChromeCache.
 
Method Summary
 boolean cacheContains(java.lang.String dbID)
          Check whether the specified CDB is in the cache.
 CDBeeTree cdbFor(java.lang.String dbID)
          Returns the cached CDB itself.
 SwappingBuffer chromeFor(java.lang.String dbID, java.lang.String objectID)
          Obtain a "chrome" - or indeed, any other - file, from a cached CDB.
 SwappingBuffer chromeFor(java.lang.String dbID, java.lang.String objectID, java.util.Date modified)
          Obtain a "chrome" - or indeed, any other - file, from a cached CDB.
 SwappingBuffer commonChromeFor(java.lang.String objectID)
          As well as application-specific chrome, we maintain a CDB of "common chrome".
 SwappingBuffer commonChromeFor(java.lang.String objectID, java.util.Date modified)
          As well as application-specific chrome, we maintain a CDB of "common chrome".
 java.lang.String[] directoryFor(java.lang.String dbID, java.lang.String objectID)
          Obtains a directory entry in a CDB filesystem.
 void expire(java.lang.String dbID)
          Remove a CDB from the cache.
 void precache(java.lang.String dbID, CDBeeTree cdbt)
          Add a CDB to the cache.
 void touch(java.lang.String dbID)
          Set the last-modified date for the specified CDB to right now, if the CDB is already cached; does nothing if it isn't.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChromeCache

public ChromeCache()
Build a new ChromeCache.

Method Detail

precache

public void precache(java.lang.String dbID,
                     CDBeeTree cdbt)
Add a CDB to the cache.

Parameters:
dbID - An ID for the database (your invention). To avoid potential namespace conflicts, make sure your IDs do not include '/' characters.
cdbt - The CDB itself.

expire

public void expire(java.lang.String dbID)
Remove a CDB from the cache.


cacheContains

public boolean cacheContains(java.lang.String dbID)
Check whether the specified CDB is in the cache.

Parameters:
dbID - The database ID to check for.
Returns:
Whether there is a CDB with the specified ID.

chromeFor

public SwappingBuffer chromeFor(java.lang.String dbID,
                                java.lang.String objectID)
                         throws java.io.FileNotFoundException,
                                java.io.IOException
Obtain a "chrome" - or indeed, any other - file, from a cached CDB. Don't use this to retrieve the directory entries of the CDB filesystem.

Parameters:
dbID - The database ID.
objectID - The ID (i.e. "path") of the file within the CDB.
Returns:
A SwappingBuffer containing the file. Note that this has a null mimeType field; your app should use its own MimeRegistry, or some other means, to determine the MIME type.
Throws:
java.io.FileNotFoundException - if there is no such object in the CDB.
java.io.IOException - if something goes wrong with the transaction.

chromeFor

public SwappingBuffer chromeFor(java.lang.String dbID,
                                java.lang.String objectID,
                                java.util.Date modified)
                         throws java.io.FileNotFoundException,
                                java.io.IOException
Obtain a "chrome" - or indeed, any other - file, from a cached CDB. Don't use this to retrieve the directory entries of the CDB filesystem.

Parameters:
dbID - The database ID.
objectID - The ID (i.e. "path") of the file within the CDB.
modified - The modification date. If present, the result will only be returned if it has been modified after this time; if it's unmodified, returns null.
Returns:
A SwappingBuffer containing the file. Note that this has a null mimeType field; your app should use its own MimeRegistry, or some other means, to determine the MIME type.
Throws:
java.io.FileNotFoundException - if there is no such object in the CDB.
java.io.IOException - if something goes wrong with the transaction.

commonChromeFor

public SwappingBuffer commonChromeFor(java.lang.String objectID)
                               throws java.io.IOException
As well as application-specific chrome, we maintain a CDB of "common chrome". This contains chrome used by Pasiphae itself (exception handler, filemage, DefaultSessionHandler), as well as CSS and furniture which is available to any app which wishes to use it.

Throws:
java.io.IOException

commonChromeFor

public SwappingBuffer commonChromeFor(java.lang.String objectID,
                                      java.util.Date modified)
                               throws java.io.IOException
As well as application-specific chrome, we maintain a CDB of "common chrome". This contains chrome used by Pasiphae itself (exception handler, filemage, DefaultSessionHandler), as well as CSS and furniture which is available to any app which wishes to use it.

Parameters:
modified - The modification date. If present, the result will only be returned if it has been modified after this time; if it's unmodified, returns null.
Throws:
java.io.IOException

touch

public void touch(java.lang.String dbID)
           throws java.io.FileNotFoundException
Set the last-modified date for the specified CDB to right now, if the CDB is already cached; does nothing if it isn't.

Parameters:
dbID - The database ID.
Throws:
java.io.FileNotFoundException - if the specified CDB is not cached.

directoryFor

public java.lang.String[] directoryFor(java.lang.String dbID,
                                       java.lang.String objectID)
                                throws java.io.FileNotFoundException,
                                       java.io.IOException
Obtains a directory entry in a CDB filesystem.

Parameters:
dbID - The database ID.
objectID - The ID (i.e. "path") of the directory within the CDB.
Returns:
The partial objectIDs of the objects contained within the directory. To obtain the complete objectID, append the partial objectID to the objectID of the directory entry. These are in random order.
Throws:
java.io.FileNotFoundException - if there is no such object in the CDB.
java.io.IOException - if something goes wrong with the transaction.

cdbFor

public CDBeeTree cdbFor(java.lang.String dbID)
                 throws java.io.FileNotFoundException
Returns the cached CDB itself.

Parameters:
dbID - The database ID.
Returns:
The CDB.
Throws:
java.io.FileNotFoundException - if there is no such object in the CDB.
java.io.IOException - if something goes wrong with the transaction.