de.dfki.lt.hog.database
Class AnnotationDatabase

java.lang.Object
  extended by de.dfki.lt.hog.database.AnnotationDatabase
Direct Known Subclasses:
XMLDBAnnotationDatabase

public abstract class AnnotationDatabase
extends java.lang.Object

This is an abstract class for a Deepthought annotation database independent of a specific underlying database system. This class uses concepts like Session and Document (identified via Strings) that are used to structure the Deepthought annotation database. In this Database, a session comprises a collection of a documents. A document itself is a collection (!) of XML annotations that are produced from different modules and can be accessed via annotation layer names.


Constructor Summary
AnnotationDatabase()
          Default Constructor: Creates an Annotation database object.
AnnotationDatabase(java.lang.String databaseLocation)
          Constructor with database location prefix as parameter.
 
Method Summary
abstract  boolean addAnnotation(java.lang.String sessionID, java.lang.String docName, java.lang.String layerName, org.w3c.dom.Node domTree)
          Adds XML annotation (as DOM tree) for specified document.
abstract  boolean addAnnotation(java.lang.String sessionID, java.lang.String docName, java.lang.String layerName, java.lang.String annotation)
          Adds XML annotation (as String) for the specified document.
abstract  boolean addDocument(java.lang.String sessionID, java.lang.String docName)
          Adds a new, empty annotation collection for a document to the annotation database.
protected abstract  boolean addIndex(java.lang.String sessionID, java.lang.String indexID, java.lang.String indexPattern)
          Adds an index to the annotation database.
abstract  boolean addSession(java.lang.String sessionID)
          Adds a new session to the annotation database.
abstract  boolean addSession(java.lang.String sessionID, org.w3c.dom.Node metaInfo)
          Adds a new session to the annotation database.
abstract  boolean addSession(java.lang.String sessionID, java.lang.String metaInfo)
          Adds a new session to the annotation database.
abstract  void closeDatabase()
          Closes the annotation database .
abstract  boolean deleteDocument(java.lang.String sessionID, java.lang.String docName)
          Deletes an annotation collection for a document from the annotation database.
abstract  boolean deleteSession(java.lang.String sessionID)
          Deletes a session from the annotation database.
abstract  org.w3c.dom.Node getAnnotationAsDOM(java.lang.String sessionID, java.lang.String docName, java.lang.String Layer)
          Returns the annotation for the specified document and layer as DOM tree.
abstract  java.lang.String getAnnotationAsString(java.lang.String sessionID, java.lang.String docName, java.lang.String Layer)
          Returns the annotation for the specified document and layer as String.
protected  java.lang.String getDatabaseLocation()
          Returns the database location prefix.
abstract  boolean openDatabase(java.lang.String connectString)
          Opens the annotation database.
 void setDatabaseLocation(java.lang.String databaseLocation)
          Sets the database location prefix.
abstract  long XUpdateQuery(java.lang.String sessionID, java.lang.String query)
          Executes an XUpdate `query'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationDatabase

public AnnotationDatabase()
Default Constructor: Creates an Annotation database object. Normally, the database is initialized using the setDatabaseLocation() method or the alternative constructor with the same signature.


AnnotationDatabase

public AnnotationDatabase(java.lang.String databaseLocation)
Constructor with database location prefix as parameter.

Parameters:
databaseLocation - a String identifying the location of the database, e.g. URI
Method Detail

setDatabaseLocation

public void setDatabaseLocation(java.lang.String databaseLocation)
Sets the database location prefix.

Parameters:
databaseLocation - a String identifying the location of the database, e.g. URI.

getDatabaseLocation

protected java.lang.String getDatabaseLocation()
Returns the database location prefix.

Returns:
a String identifying the location of the database, e.g. URI, as set by setDatabaseLocation().

openDatabase

public abstract boolean openDatabase(java.lang.String connectString)
                              throws java.lang.Exception
Opens the annotation database.

Parameters:
connectString - optional connection String for the underlying database
Returns:
true iff successful
Throws:
java.lang.Exception

closeDatabase

public abstract void closeDatabase()
                            throws java.lang.Exception
Closes the annotation database .

Throws:
java.lang.Exception

addSession

public abstract boolean addSession(java.lang.String sessionID)
                            throws java.lang.Exception
Adds a new session to the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
Returns:
true iff successful
Throws:
java.lang.Exception

addSession

public abstract boolean addSession(java.lang.String sessionID,
                                   java.lang.String metaInfo)
                            throws java.lang.Exception
Adds a new session to the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
metaInfo - metainformation associated with the session (XML String)
Returns:
true iff successful
Throws:
java.lang.Exception

addSession

public abstract boolean addSession(java.lang.String sessionID,
                                   org.w3c.dom.Node metaInfo)
Adds a new session to the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
metaInfo - metainformation associated with the session (DOM object)
Returns:
true iff successful

deleteSession

public abstract boolean deleteSession(java.lang.String sessionID)
Deletes a session from the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
Returns:
true iff successful

addDocument

public abstract boolean addDocument(java.lang.String sessionID,
                                    java.lang.String docName)
Adds a new, empty annotation collection for a document to the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
docName - identifier of the added document (must be unique within the same session collection)
Returns:
true iff successful

deleteDocument

public abstract boolean deleteDocument(java.lang.String sessionID,
                                       java.lang.String docName)
Deletes an annotation collection for a document from the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
docName - identifier of the document to be deleted
Returns:
true iff successful

addAnnotation

public abstract boolean addAnnotation(java.lang.String sessionID,
                                      java.lang.String docName,
                                      java.lang.String layerName,
                                      java.lang.String annotation)
Adds XML annotation (as String) for the specified document.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
docName - identifier of the document for which annotation is to be added
layerName - name of the layer type (such as Tokens, NamedEntities etc.) of the annotation
annotation - the XML annotation as String
Returns:
true iff successful

addAnnotation

public abstract boolean addAnnotation(java.lang.String sessionID,
                                      java.lang.String docName,
                                      java.lang.String layerName,
                                      org.w3c.dom.Node domTree)
Adds XML annotation (as DOM tree) for specified document.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
docName - identifier of the document for which annotation is to be added
layerName - name of the layer type (such as Tokens, NamedEntities etc.) of the annotation
domTree - the XML annotation as DOM object
Returns:
true iff successful

getAnnotationAsString

public abstract java.lang.String getAnnotationAsString(java.lang.String sessionID,
                                                       java.lang.String docName,
                                                       java.lang.String Layer)
Returns the annotation for the specified document and layer as String.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
docName - identifier of the document for which annotation is to be added
Layer - name of the layer type (such as Tokens, NamedEntities etc.) of the annotation
Returns:
annotation as string

getAnnotationAsDOM

public abstract org.w3c.dom.Node getAnnotationAsDOM(java.lang.String sessionID,
                                                    java.lang.String docName,
                                                    java.lang.String Layer)
Returns the annotation for the specified document and layer as DOM tree.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
docName - identifier of the document for which annotation is to be retrieved
Layer - name of the layer type (such as Tokens, NamedEntities etc.) of the annotation
Returns:
annotation as DOM object

XUpdateQuery

public abstract long XUpdateQuery(java.lang.String sessionID,
                                  java.lang.String query)
Executes an XUpdate `query'. For details and syntax of XUpdate see http://xmldb.org/xupdate and http://xml.apache.org/xindice.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
query - the XUpdate query (XML syntax) as String
Returns:
number of updated entries

addIndex

protected abstract boolean addIndex(java.lang.String sessionID,
                                    java.lang.String indexID,
                                    java.lang.String indexPattern)
Adds an index to the annotation database.

Parameters:
sessionID - the session Identifier (single token starting with a non-numerical character)
indexID - name of the index (must be unique within a collection)
indexPattern - pattern for the indexer to be generated
Returns:
true iff successful