public class SerialDataStore extends AbstractFeatureBearer implements DataStore
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoSaving
Flag for autosaving behaviour.
|
protected String |
currentProtocolVersion
The protocol version of the currently open data store
|
protected String |
name
The name of the datastore
|
protected static String[] |
protocolVersionNumbers
List of valid protocol version numbers.
|
protected File |
storageDir
The directory used for the serialised classes.
|
protected static String |
versionNumber
Version number for variations in the storage protocol.
|
featuresDATASTORE_FEATURE_NAME, LR_ID_FEATURE_NAME| Constructor and Description |
|---|
SerialDataStore()
Default construction.
|
SerialDataStore(String storageDirUrl)
Construction requires a file protocol URL
pointing to the storage directory used for
the serialised classes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDatastoreListener(DatastoreListener l)
Registers a new
DatastoreListener with this datastore |
LanguageResource |
adopt(LanguageResource lr)
Adopt a resource for persistence.
|
boolean |
canReadLR(Object lrID)
Checks if the user (identified by the sessionID)
has read access to the LR
|
boolean |
canWriteLR(Object lrID)
Checks if the user (identified by the sessionID)
has write access to the LR
|
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,
Object lrPersistenceId)
Delete a resource from the data store.
|
boolean |
equals(Object other)
Equality: based on storage dir of other.
|
protected String[] |
filterIgnoredFileNames(String[] fileNames)
This removes the names of all files from a list of file names for which
we know that we want to ignore them.
|
List |
findLrIds(List constraints)
Get a list of LRs that satisfy some set or restrictions
|
List |
findLrIds(List constraints,
String lrType)
Get a list of LRs that satisfy some set or restrictions and are
of a particular type
|
protected void |
fireResourceAdopted(DatastoreEvent e) |
protected void |
fireResourceDeleted(DatastoreEvent e) |
protected void |
fireResourceWritten(DatastoreEvent e) |
String |
getComment()
Returns the comment displayed by the GUI for this DataStore
|
String |
getIconName()
Returns the name of the icon to be used when this datastore is displayed
in the GUI
|
LanguageResource |
getLr(String lrClassName,
Object lrPersistenceId)
Get a resource from the persistent store.
|
List<String> |
getLrIds(String lrType)
Get a list of the IDs of LRs of a particular type that are present.
|
String |
getLrName(Object lrId)
Get the name of an LR from its ID.
|
List<String> |
getLrNames(String lrType)
Get a list of the names of LRs of a particular type that are present.
|
List<String> |
getLrTypes()
Get a list of the types of LR that are present in the data store.
|
String |
getName()
Returns the name of this resource
|
File |
getStorageDir()
Get method for storage URL
|
String |
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 static boolean |
isValidProtocolVersion(String versionNumber)
Check a version number for validity.
|
boolean |
lockLr(LanguageResource lr)
Try to acquire exlusive lock on a resource from the persistent store.
|
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 |
setName(String name)
Sets the name of this resource
|
void |
setStorageDir(File storageDir)
Set method for storage URL
|
void |
setStorageUrl(String urlString)
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
|
void |
unlockLr(LanguageResource lr)
Releases the exlusive lock on a resource from the persistent store.
|
getFeatures, setFeaturesclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetFeatures, setFeaturesprotected String name
protected File storageDir
protected String currentProtocolVersion
protected static final String versionNumber
protected static final String[] protocolVersionNumbers
protected boolean autoSaving
public SerialDataStore(String storageDirUrl) throws PersistenceException
PersistenceExceptionpublic SerialDataStore()
public void setStorageDir(File storageDir)
public File getStorageDir()
public void setStorageUrl(String urlString) throws PersistenceException
setStorageUrl in interface DataStorePersistenceExceptionpublic String getStorageUrl()
getStorageUrl in interface DataStorepublic void create()
throws PersistenceException
create in interface DataStorePersistenceExceptionprotected File getVersionFile() throws IOException
IOExceptionprotected static boolean isValidProtocolVersion(String versionNumber)
public void delete()
throws PersistenceException
delete in interface DataStorePersistenceExceptionpublic void delete(String lrClassName, Object lrPersistenceId) throws PersistenceException
delete in interface DataStorelrClassName - class name of the type of resourcelrPersistenceId - a data-store specific unique identifier for the resourcePersistenceExceptionpublic LanguageResource adopt(LanguageResource lr) throws PersistenceException
adopt in interface DataStorePersistenceExceptionpublic void open()
throws PersistenceException
open in interface DataStorePersistenceExceptionpublic void close()
throws PersistenceException
close in interface DataStorePersistenceExceptionpublic void sync(LanguageResource lr) throws PersistenceException
sync in interface DataStorePersistenceExceptionprotected String constructPersistenceId(String lrName)
public LanguageResource getLr(String lrClassName, Object lrPersistenceId) throws PersistenceException, SecurityException
DataStoreFeatureMap params = Factory.newFeatureMap(); params.put(DataStore.DATASTORE_FEATURE_NAME, datastore); params.put(DataStore.LR_ID_FEATURE_NAME, lrID); LanguageResource lr = (LanguageResource)Factory.createResource(lrClassName, params);
getLr in interface DataStorePersistenceExceptionSecurityExceptionpublic List<String> getLrTypes() throws PersistenceException
getLrTypes in interface DataStorePersistenceExceptionpublic List<String> getLrIds(String lrType) throws PersistenceException
getLrIds in interface DataStorePersistenceExceptionpublic List<String> getLrNames(String lrType) throws PersistenceException
getLrNames in interface DataStorePersistenceExceptionpublic void setAutoSaving(boolean autoSaving)
throws UnsupportedOperationException
setAutoSaving in interface DataStoreUnsupportedOperationExceptionpublic boolean isAutoSaving()
isAutoSaving in interface DataStoreprotected static int random()
public int hashCode()
public boolean equals(Object other)
public void removeDatastoreListener(DatastoreListener l)
DataStoreDatastoreListener
from the list listeners for this datastoreremoveDatastoreListener in interface DataStorepublic void addDatastoreListener(DatastoreListener l)
DataStoreDatastoreListener with this datastoreaddDatastoreListener in interface DataStoreprotected void fireResourceAdopted(DatastoreEvent e)
protected void fireResourceDeleted(DatastoreEvent e)
protected void fireResourceWritten(DatastoreEvent e)
public String getIconName()
getIconName in interface DataStorepublic String getComment()
getComment in interface DataStorepublic boolean canReadLR(Object lrID) throws PersistenceException
canReadLR in interface DataStorePersistenceExceptionpublic boolean canWriteLR(Object lrID) throws PersistenceException
canWriteLR in interface DataStorePersistenceExceptionpublic void setName(String name)
setName in interface NameBearerpublic String getName()
getName in interface NameBearerpublic boolean lockLr(LanguageResource lr) throws PersistenceException, SecurityException
lockLr in interface DataStorePersistenceExceptionSecurityExceptionpublic void unlockLr(LanguageResource lr) throws PersistenceException, SecurityException
unlockLr in interface DataStorePersistenceExceptionSecurityExceptionpublic List findLrIds(List constraints) throws PersistenceException
findLrIds in interface DataStorePersistenceExceptionpublic List findLrIds(List constraints, String lrType) throws PersistenceException
findLrIds in interface DataStorePersistenceExceptionprotected String[] filterIgnoredFileNames(String[] fileNames)
fileNames - Copyright © 2024 GATE. All rights reserved.