|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gate.util.AbstractFeatureBearer | +--gate.persist.SerialDataStore
A data store based on Java serialisation.
Field Summary | |
protected boolean |
autoSaving
Flag for autosaving behaviour. |
protected static String |
currentProtocolVersion
The protocol version of the currently open data store |
private Vector |
datastoreListeners
|
private static boolean |
DEBUG
Debug flag |
protected String[] |
protocolVersionNumbers
List of valid protocol version numbers. |
protected static Random |
randomiser
Random number generator |
protected File |
storageDir
The directory used for the serialised classes. |
protected static String |
versionFileName
The name of the version file |
protected String |
versionNumber
Version number for variations in the storage protocol. |
Fields inherited from class gate.util.AbstractFeatureBearer |
features |
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. |
protected String |
constructPersistenceId(String lrName)
Create a persistent store Id from the name of a resource. |
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. |
protected void |
fireResourceAdopted(DatastoreEvent e)
|
protected void |
fireResourceDeleted(DatastoreEvent e)
|
protected void |
fireResourceWritten(DatastoreEvent e)
|
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. |
protected File |
getVersionFile()
Get a File for the protocol version file. |
int |
hashCode()
Calculate a hash code based on the class and the storage dir. |
boolean |
isAutoSaving()
Get the autosaving behaviour of the LR. |
protected boolean |
isValidProtocolVersion(String versionNumber)
Check a version number for validity. |
void |
open()
Open a connection to the data store. |
protected static int |
random()
Generate a random integer between 0 and 9999 for file naming. |
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 |
|
Methods inherited from interface gate.util.FeatureBearer |
getFeatures, getName, setFeatures, setName |
Field Detail |
private static final boolean DEBUG
protected File storageDir
protected static String versionFileName
protected static String currentProtocolVersion
protected String versionNumber
protected String[] protocolVersionNumbers
protected boolean autoSaving
protected static Random randomiser
private transient Vector datastoreListeners
Constructor Detail |
public SerialDataStore(URL storageDirUrl) throws PersistenceException
public SerialDataStore()
Method Detail |
public void setStorageDir(File storageDir)
public File getStorageDir()
public void setStorageUrl(URL storageUrl) throws PersistenceException
setStorageUrl
in interface DataStore
public URL getStorageUrl()
getStorageUrl
in interface DataStore
public void create() throws PersistenceException
create
in interface DataStore
protected File getVersionFile() throws IOException
protected boolean isValidProtocolVersion(String versionNumber)
public void delete() throws PersistenceException
delete
in interface DataStore
public void delete(String lrClassName, String dataStoreInstanceId) throws PersistenceException
delete
in interface DataStore
gate.DataStore
lrId
- a data-store specific unique identifier for the resourcelrClassName
- class name of the type of resourcepublic LanguageResource adopt(LanguageResource lr) throws PersistenceException
adopt
in interface DataStore
public void open() throws PersistenceException
open
in interface DataStore
public void close() throws PersistenceException
close
in interface DataStore
public void sync(LanguageResource lr) throws PersistenceException
sync
in interface DataStore
protected String constructPersistenceId(String lrName)
public LanguageResource getLr(String lrClassName, String dataStoreInstanceId) throws PersistenceException
getLr
in interface DataStore
public List getLrTypes() throws PersistenceException
getLrTypes
in interface DataStore
public List getLrIds(String lrType) throws PersistenceException
getLrIds
in interface DataStore
public List getLrNames(String lrType) throws PersistenceException
getLrNames
in interface DataStore
public String getLrName(String lrId)
getLrName
in interface DataStore
public void setAutoSaving(boolean autoSaving) throws UnsupportedOperationException
setAutoSaving
in interface DataStore
public boolean isAutoSaving()
isAutoSaving
in interface DataStore
protected static int random()
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public void removeDatastoreListener(DatastoreListener l)
DataStore
DatastoreListener
from the list listeners for this datastoreremoveDatastoreListener
in interface DataStore
public void addDatastoreListener(DatastoreListener l)
DataStore
DatastoreListener
with this datastoreaddDatastoreListener
in interface DataStore
protected void fireResourceAdopted(DatastoreEvent e)
protected void fireResourceDeleted(DatastoreEvent e)
protected void fireResourceWritten(DatastoreEvent e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |