uk.ac.kcl.cch.jb.pliny.model
Class ResourceCache
java.lang.Object
uk.ac.kcl.cch.rdb2java.dynData.Rdb2javaCache
uk.ac.kcl.cch.jb.pliny.model.ResourceCache
- public class ResourceCache
- extends Rdb2javaCache
overrides the Rdb2javaCache
used
by other rdb2java managed objects to meet the special needs of the
Resource
class. These special needs are two:
- The
NoteLucened
item is derived from the base Resource
class and needs special handling so that if the item if fetched from
its DB key only that a NoteLucened object is returned rather than a
base Resource object.
- Similarly, other Pliny related plugins can have their own derived
version of the Resource class. The
IResourceExtensionProcessor
provides a method to request the generation of such a class that the
rdb2java code can then fill with data, and ensures that the cache will
return this class rather than the base Resource class.
The fact that this Resource is a special type needs to be indicated in the
DB data -- and this task is managed by the reference to the ObjectType
.
- Author:
- John Bradley
Method Summary |
Object |
getItem(int key)
this fetches a Resource when only the DB key for it is known. |
Object |
getItem(int key,
int type)
gets an item when both the DB key and the ObjectType associated
with it is known. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ResourceCache
public ResourceCache(IObjectFetcher myDataType)
getItem
public Object getItem(int key,
int type)
- gets an item when both the DB key and the
ObjectType
associated
with it is known. This will fetch the data from the
NoteLucened
cache if it is a Note type, will fetch
the item from the cache if it is there, and if it is not
will fetch the data from the DB (storing it in the cache), and
using the object provided to it by
IResourceExtensionProcessor.makeMyResource()
if applicable.
- Parameters:
key
- DB key for the resource item.type
- type of item (key for the linked ObjectType.
- Returns:
- Resource-derived object with given key and type, or null
if data for given key is not in the DB.
getItem
public Object getItem(int key)
- this fetches a Resource when only the DB key for it is known.
Note that if the Resource is a
NoteLucened
(has its
ObjectType reference set as a Note) that this involves double
read of the DB -- first to fetch it as a standard Resource, then,
upon discovery that it is a Note, a second DB to get all the
data for the NoteLucened version.
- Overrides:
getItem
in class Rdb2javaCache