gate.persist
Class SerialDataStore

java.lang.Object
  |
  +--gate.util.AbstractFeatureBearer
        |
        +--gate.persist.SerialDataStore
All Implemented Interfaces:
DataStore, FeatureBearer
Direct Known Subclasses:
Database

public class SerialDataStore
extends AbstractFeatureBearer
implements DataStore

A data store based on Java serialisation.


Constructor Summary
SerialDataStore()
          Default construction.
SerialDataStore(URL storageDirUrl)
          Construction requires a file protocol URL pointing to the storage directory used for the serialised classes.
 
Method Summary
 void addDatastoreListener(DatastoreListener l)
          Registers a new DatastoreListener with this datastore
 LanguageResource adopt(LanguageResource lr)
          Adopt a resource for persistence.
 void close()
          Close the data store.
 void create()
          Create a new data store.
 void delete()
          Delete the data store.
 void delete(String lrClassName, String dataStoreInstanceId)
          Delete a resource from the data store.
 boolean equals(Object other)
          Equality: based on storage dir of other.
 LanguageResource getLr(String lrClassName, String dataStoreInstanceId)
          Get a resource from the persistent store.
 List getLrIds(String lrType)
          Get a list of the IDs of LRs of a particular type that are present.
 String getLrName(String lrId)
          Get the name of an LR from its ID.
 List getLrNames(String lrType)
          Get a list of the names of LRs of a particular type that are present.
 List getLrTypes()
          Get a list of the types of LR that are present in the data store.
 File getStorageDir()
          Get method for storage URL
 URL getStorageUrl()
          Get the URL for the underlying storage mechanism.
 int hashCode()
          Calculate a hash code based on the class and the storage dir.
 boolean isAutoSaving()
          Get the autosaving behaviour of the LR.
 void open()
          Open a connection to the data store.
 void removeDatastoreListener(DatastoreListener l)
          Removes a a previously registered DatastoreListener from the list listeners for this datastore
 void setAutoSaving(boolean autoSaving)
          Set method for the autosaving behaviour of the data store.
 void setStorageDir(File storageDir)
          Set method for storage URL
 void setStorageUrl(URL storageUrl)
          Set the URL for the underlying storage mechanism.
 void sync(LanguageResource lr)
          Save: synchonise the in-memory image of the LR with the persistent image.
 String toString()
          String representation
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, getName, setFeatures, setName
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, getName, setFeatures, setName
 

Constructor Detail

SerialDataStore

public SerialDataStore(URL storageDirUrl)
                throws PersistenceException
Construction requires a file protocol URL pointing to the storage directory used for the serialised classes. NOTE: should not be called except by GATE code.

SerialDataStore

public SerialDataStore()
Default construction. NOTE: should not be called except by GATE code.
Method Detail

setStorageDir

public void setStorageDir(File storageDir)
Set method for storage URL

getStorageDir

public File getStorageDir()
Get method for storage URL

setStorageUrl

public void setStorageUrl(URL storageUrl)
                   throws PersistenceException
Set the URL for the underlying storage mechanism.
Specified by:
setStorageUrl in interface DataStore

getStorageUrl

public URL getStorageUrl()
Get the URL for the underlying storage mechanism.
Specified by:
getStorageUrl in interface DataStore

create

public void create()
            throws PersistenceException
Create a new data store. This tries to create a directory in the local file system. If the directory already exists and is non-empty, or is a file, or cannot be created, PersistenceException is thrown.
Specified by:
create in interface DataStore

delete

public void delete()
            throws PersistenceException
Delete the data store.
Specified by:
delete in interface DataStore

delete

public void delete(String lrClassName,
                   String dataStoreInstanceId)
            throws PersistenceException
Delete a resource from the data store.
Specified by:
delete in interface DataStore
Following copied from interface: gate.DataStore
Parameters:
lrId - a data-store specific unique identifier for the resource
lrClassName - class name of the type of resource

adopt

public LanguageResource adopt(LanguageResource lr)
                       throws PersistenceException
Adopt a resource for persistence.
Specified by:
adopt in interface DataStore

open

public void open()
          throws PersistenceException
Open a connection to the data store.
Specified by:
open in interface DataStore

close

public void close()
           throws PersistenceException
Close the data store.
Specified by:
close in interface DataStore

sync

public void sync(LanguageResource lr)
          throws PersistenceException
Save: synchonise the in-memory image of the LR with the persistent image.
Specified by:
sync in interface DataStore

getLr

public LanguageResource getLr(String lrClassName,
                              String dataStoreInstanceId)
                       throws PersistenceException
Get a resource from the persistent store. Don't use this method - use Factory.createResource with DataStore and DataStoreInstanceId parameters set instead. (Sometimes I wish Java had "friend" declarations...)
Specified by:
getLr in interface DataStore

getLrTypes

public List getLrTypes()
                throws PersistenceException
Get a list of the types of LR that are present in the data store.
Specified by:
getLrTypes in interface DataStore

getLrIds

public List getLrIds(String lrType)
              throws PersistenceException
Get a list of the IDs of LRs of a particular type that are present.
Specified by:
getLrIds in interface DataStore

getLrNames

public List getLrNames(String lrType)
                throws PersistenceException
Get a list of the names of LRs of a particular type that are present.
Specified by:
getLrNames in interface DataStore

getLrName

public String getLrName(String lrId)
Get the name of an LR from its ID.
Specified by:
getLrName in interface DataStore

setAutoSaving

public void setAutoSaving(boolean autoSaving)
                   throws UnsupportedOperationException
Set method for the autosaving behaviour of the data store. NOTE: this type of datastore has no auto-save function, therefore this method throws an UnsupportedOperationException.
Specified by:
setAutoSaving in interface DataStore

isAutoSaving

public boolean isAutoSaving()
Get the autosaving behaviour of the LR.
Specified by:
isAutoSaving in interface DataStore

toString

public String toString()
String representation
Overrides:
toString in class Object

hashCode

public int hashCode()
Calculate a hash code based on the class and the storage dir.
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Equality: based on storage dir of other.
Overrides:
equals in class Object

removeDatastoreListener

public void removeDatastoreListener(DatastoreListener l)
Description copied from interface: DataStore
Removes a a previously registered DatastoreListener from the list listeners for this datastore
Specified by:
removeDatastoreListener in interface DataStore

addDatastoreListener

public void addDatastoreListener(DatastoreListener l)
Description copied from interface: DataStore
Registers a new DatastoreListener with this datastore
Specified by:
addDatastoreListener in interface DataStore