gate.db
Class CorpusWrapper
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractSet
|
+--java.util.TreeSet
|
+--gate.corpora.CorpusImpl
|
+--gate.db.CorpusWrapper
- All Implemented Interfaces:
- Cloneable, Collection, Corpus, FeatureBearer, LanguageResource, LRDBWrapper, Resource, Serializable, Set, SortedSet
- public class CorpusWrapper
- extends CorpusImpl
- implements LRDBWrapper
This class extends CorpusImpl adding database persistence via Jdbc.
- See Also:
- Serialized Form
Method Summary |
void |
beginTransaction()
Starts a transaction. |
void |
commit()
Commits the reads/writes |
void |
disconnect()
Disconnects from the Datastore object, that is returns the connection |
DataStore |
getDataStore()
Returns the datastore object used for the persistent store of this cropus |
long |
getId()
|
boolean |
isNew()
This method can be used to check whether the constructor read an old
corpus previously stored in in the database or it created a new corpus
starting from transient values. |
void |
rollback()
Rolls back all the actions performed since the last beginTransaction call |
static boolean |
setupDatabase(DataStore ds)
This method checks whether the provided datastore can be used for storing
persistent objects of this type(Corpus). |
Methods inherited from class java.util.TreeSet |
add, addAll, clear, clone, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet |
Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
CorpusWrapper
public CorpusWrapper(DataStore db,
String name)
throws IOException
- Constructs a CorpusWrapper object retrieving the information from the
DataStore provided as parameter. If there is a corpus by that name in the
database it will be retrieved and used for the creation of the new object;
if not, a new corpus will be created.
- Parameters:
db
- An object of type gate.db.DataStore which this object will use
to retrieve/store data from/to.name
- The name of the new corpus that will be retrieved from the
database or created and stored in the DataStoreImpl.
CorpusWrapper
public CorpusWrapper(DataStore db,
String name,
FeatureMap features)
throws IOException
- Creates a persistent corpus with the given name and features.
- Parameters:
db
- the datastore this corpus is to be read/saved from/to.name
- the name of the new corpus.features
- the features of the corpus.
CorpusWrapper
public CorpusWrapper(DataStore db,
CorpusImpl corpus)
throws IOException
- Creates a persistent corpus starting from a transient one.
Note that this method can be used to create a persistent copy
of another persistent corpus located in a different database.
- Parameters:
db
- the datstore used for saving the new persistent corpus.corpus
- the transient corpus.
rollback
public void rollback()
throws SQLException
- Rolls back all the actions performed since the last beginTransaction call
- Specified by:
rollback
in interface LRDBWrapper
beginTransaction
public void beginTransaction()
throws SQLException
- Starts a transaction. All database actions should be enclosed between a
beginTransaction() and a commit()/rollback() call.
- Specified by:
beginTransaction
in interface LRDBWrapper
commit
public void commit()
throws SQLException
- Commits the reads/writes
- Specified by:
commit
in interface LRDBWrapper
disconnect
public void disconnect()
throws GateException
- Disconnects from the Datastore object, that is returns the connection
- Specified by:
disconnect
in interface LRDBWrapper
getDataStore
public DataStore getDataStore()
- Returns the datastore object used for the persistent store of this cropus
- Specified by:
getDataStore
in interface LanguageResource
- Overrides:
getDataStore
in class CorpusImpl
isNew
public boolean isNew()
- This method can be used to check whether the constructor read an old
corpus previously stored in in the database or it created a new corpus
starting from transient values.
setupDatabase
public static boolean setupDatabase(DataStore ds)
- This method checks whether the provided datastore can be used for storing
persistent objects of this type(Corpus). If necessary, this method will
try to adapt the given datastore so it complies with the requirements
needed for storing corpora.
- Returns:
- true if the datastore is corpus-compliant or if the datastore has
been successfully adapted;
false otherwise.
getId
public long getId()
- Returns:
- the id used for this corpus in the database.