gate.corpora
Class DatabaseDocumentImpl

java.lang.Object
  |
  +--gate.util.AbstractFeatureBearer
        |
        +--gate.creole.AbstractResource
              |
              +--gate.creole.AbstractLanguageResource
                    |
                    +--gate.corpora.DocumentImpl
                          |
                          +--gate.corpora.DatabaseDocumentImpl
All Implemented Interfaces:
Comparable, CreoleListener, DatastoreListener, Document, EventAwareDocument, EventAwareLanguageResource, EventListener, FeatureBearer, LanguageResource, NameBearer, Resource, Serializable, TextualDocument

public class DatabaseDocumentImpl
extends DocumentImpl
implements EventAwareDocument

See Also:
Serialized Form

Inner Class Summary
(package private)  class DatabaseDocumentImpl.EventsHandler
          All the events from the features are handled by this inner class.
 
Inner classes inherited from class gate.corpora.DocumentImpl
DocumentImpl.AnnotationComparator
 
Field Summary
private  Collection addedAnotationSets
           
private  boolean contentChanged
           
private  Object contentLock
           
protected  int dbType
           
private static boolean DEBUG
           
private  boolean documentChanged
           
protected  DatabaseDocumentImpl.EventsHandler eventHandler
          The listener for the events coming from the features.
private  boolean featuresChanged
           
private  boolean isContentRead
           
private  Connection jdbcConn
           
private  String jdbcSchema
           
private  int maxAnnotationId
           
private  boolean nameChanged
           
private  Document parentDocument
           
private  Collection removedAnotationSets
           
 
Fields inherited from class gate.corpora.DocumentImpl
ASC, collectRepositioningInfo, content, crossedOverAnnotation, defaultAnnots, DESC, DOC_SIZE_MULTIPLICATION_FACTOR, documentListeners, encoding, entitiesMap, gateListeners, markupAware, namedAnnotSets, nextAnnotationId, nextNodeId, ORDER_ON_ANNOT_ID, ORDER_ON_END_OFFSET, ORDER_ON_START_OFFSET, preserveOriginalContent, rootEnd, serialVersionUID, smallestAnnotationID, sourceUrl, sourceUrlEndOffset, sourceUrlStartOffset, stringContent
 
Fields inherited from class gate.creole.AbstractLanguageResource
dataStore, lrPersistentId
 
Fields inherited from class gate.creole.AbstractResource
name
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Fields inherited from interface gate.corpora.EventAwareLanguageResource
DOC_CONTENT, DOC_MAIN, RES_FEATURES, RES_NAME
 
Fields inherited from interface gate.Document
DOCUMENT_ENCODING_PARAMETER_NAME, DOCUMENT_END_OFFSET_PARAMETER_NAME, DOCUMENT_MARKUP_AWARE_PARAMETER_NAME, DOCUMENT_PRESERVE_CONTENT_PARAMETER_NAME, DOCUMENT_REPOSITIONING_PARAMETER_NAME, DOCUMENT_START_OFFSET_PARAMETER_NAME, DOCUMENT_STRING_CONTENT_PARAMETER_NAME, DOCUMENT_URL_PARAMETER_NAME
 
Constructor Summary
DatabaseDocumentImpl()
           
DatabaseDocumentImpl(Connection conn)
           
 
Method Summary
private  void _getAnnotations(String name)
           
private  void _readContent()
           
private  HashMap _readFeatures(Long asetID)
           
private  void _setAnnotations(String setName, Collection annotations)
           
 void cleanup()
          Overriden to remove the features listener, when the document is closed.
 Collection getAddedAnnotationSets()
           
 AnnotationSet getAnnotations()
          Get the default set of annotations.
 AnnotationSet getAnnotations(String name)
          Get a named set of annotations.
private  List getAnnotationsForOffset(AnnotationSet aDumpAnnotSet, Long offset)
           
 DocumentContent getContent()
          The content of the document: a String for text; MPEG for video; etc.
 String getEncoding()
          Get the encoding of the document content source
 Object getInitData__$$__(Object initData)
           
 Collection getLoadedAnnotationSets()
           
 Map getNamedAnnotationSets()
          Returns a map with the named annotation sets.
 LanguageResource getParent()
          Returns the parent LR of this LR.
 Collection getRemovedAnnotationSets()
           
 Resource init()
          Initialise this resource, and return it.
 boolean isModified()
          Returns true of an LR has been modified since the last sync.
 boolean isResourceChanged(int changeType)
           
 void removeAnnotationSet(String name)
          Removes one of the named annotation sets.
 void resourceAdopted(DatastoreEvent evt)
          Called by a datastore when a new resource has been adopted
 void resourceDeleted(DatastoreEvent evt)
          Called by a datastore when a resource has been deleted
 void resourceWritten(DatastoreEvent evt)
          Called by a datastore when a resource has been wrote into the datastore
 void setContent(DocumentContent content)
          Set method for the document content
private  void setDatabaseInfo(Connection conn)
           
 void setFeatures(FeatureMap features)
          Set the feature set
 void setInitData__$$__(Object data)
           
 void setMarkupAware(Boolean newMarkupAware)
          Make the document markup-aware.
 void setName(String name)
          Sets the name of this resource
 void setNextNodeId(int nextID)
           
 void setParent(LanguageResource parentLR)
          Sets the parent LR of this LR.
 void setSourceUrl(URL sourceUrl)
          Set method for the document's URL
 void setSourceUrlEndOffset(Long sourceUrlEndOffset)
          Documents may be packed within files; in this case an optional pair of offsets refer to the location of the document.
 void setSourceUrlStartOffset(Long sourceUrlStartOffset)
          Documents may be packed within files; in this case an optional pair of offsets refer to the location of the document.
 
Methods inherited from class gate.corpora.DocumentImpl
, addDocumentListener, analyseAmpCodding, annotationSetToXml, buildEntityMapFromString, collectInformationForAmpCodding, collectInformationForWS, compareTo, correctRepositioningForCRLFInXML, datastoreClosed, datastoreCreated, datastoreOpened, edit, featuresToXml, filterNonXmlChars, fireAnnotationSetAdded, fireAnnotationSetRemoved, getAnnotationsForOffset, getCollectRepositioningInfo, getMarkupAware, getNextAnnotationId, getNextNodeId, getOrderingString, getPreserveOriginalContent, getSourceUrl, getSourceUrlEndOffset, getSourceUrlOffsets, getSourceUrlStartOffset, getStringContent, hasOriginalContentFeatures, insertsSafety, isNumber, isValidOffset, isValidOffsetRange, isXmlChar, removeDocumentListener, replaceCharsWithEntities, resourceLoaded, resourceRenamed, resourceUnloaded, saveAnnotationSetAsXml, saveAnnotationSetAsXmlInOrig, setCollectRepositioningInfo, setDataStore, setEncoding, setLRPersistenceId, setNextAnnotationId, setPreserveOriginalContent, setStringContent, textWithNodes, toString, toXml, toXml, toXml, writeEmptyTag, writeEmptyTag, writeEndTag, writeFeatures, writeStartTag, writeStartTag
 
Methods inherited from class gate.creole.AbstractLanguageResource
getDataStore, getLRPersistenceId, sync
 
Methods inherited from class gate.creole.AbstractResource
checkParameterValues, getName, getParameterValue, getParameterValue, removeResourceListeners, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface gate.LanguageResource
getDataStore, getLRPersistenceId, sync
 
Methods inherited from interface gate.Resource
getParameterValue, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures
 
Methods inherited from interface gate.util.NameBearer
getName
 

Field Detail

DEBUG

private static final boolean DEBUG

isContentRead

private boolean isContentRead

contentLock

private Object contentLock

jdbcConn

private Connection jdbcConn

jdbcSchema

private String jdbcSchema

dbType

protected int dbType

contentChanged

private boolean contentChanged

featuresChanged

private boolean featuresChanged

nameChanged

private boolean nameChanged

documentChanged

private boolean documentChanged

removedAnotationSets

private Collection removedAnotationSets

addedAnotationSets

private Collection addedAnotationSets

parentDocument

private Document parentDocument

maxAnnotationId

private int maxAnnotationId

eventHandler

protected DatabaseDocumentImpl.EventsHandler eventHandler
The listener for the events coming from the features.
Constructor Detail

DatabaseDocumentImpl

public DatabaseDocumentImpl()

DatabaseDocumentImpl

public DatabaseDocumentImpl(Connection conn)
                     throws PersistenceException
Method Detail

setDatabaseInfo

private void setDatabaseInfo(Connection conn)
                      throws PersistenceException

getContent

public DocumentContent getContent()
The content of the document: a String for text; MPEG for video; etc.
Overrides:
getContent in class DocumentImpl

_readContent

private void _readContent()

getEncoding

public String getEncoding()
Get the encoding of the document content source
Overrides:
getEncoding in class DocumentImpl
Following copied from interface: gate.TextualDocument
Returns:
a String value.

getNamedAnnotationSets

public Map getNamedAnnotationSets()
Returns a map with the named annotation sets. It returns null if no named annotaton set exists.
Overrides:
getNamedAnnotationSets in class DocumentImpl

getAnnotations

public AnnotationSet getAnnotations()
Get the default set of annotations. The set is created if it doesn't exist yet.
Overrides:
getAnnotations in class DocumentImpl

getAnnotations

public AnnotationSet getAnnotations(String name)
Get a named set of annotations. Creates a new set if one with this name doesn't exist yet. If the provided name is null then it returns the default annotation set.
Overrides:
getAnnotations in class DocumentImpl

_getAnnotations

private void _getAnnotations(String name)

_readFeatures

private HashMap _readFeatures(Long asetID)

setContent

public void setContent(DocumentContent content)
Set method for the document content
Overrides:
setContent in class DocumentImpl

setFeatures

public void setFeatures(FeatureMap features)
Set the feature set
Overrides:
setFeatures in class AbstractFeatureBearer

setName

public void setName(String name)
Sets the name of this resource
Overrides:
setName in class AbstractResource

getAnnotationsForOffset

private List getAnnotationsForOffset(AnnotationSet aDumpAnnotSet,
                                     Long offset)

setNextNodeId

public void setNextNodeId(int nextID)

isResourceChanged

public boolean isResourceChanged(int changeType)
Specified by:
isResourceChanged in interface EventAwareLanguageResource

_setAnnotations

private void _setAnnotations(String setName,
                             Collection annotations)
                      throws InvalidOffsetException

setSourceUrl

public void setSourceUrl(URL sourceUrl)
Set method for the document's URL
Overrides:
setSourceUrl in class DocumentImpl

setSourceUrlEndOffset

public void setSourceUrlEndOffset(Long sourceUrlEndOffset)
Documents may be packed within files; in this case an optional pair of offsets refer to the location of the document. This method sets the end offset.
Overrides:
setSourceUrlEndOffset in class DocumentImpl

setSourceUrlStartOffset

public void setSourceUrlStartOffset(Long sourceUrlStartOffset)
Documents may be packed within files; in this case an optional pair of offsets refer to the location of the document. This method sets the start offset.
Overrides:
setSourceUrlStartOffset in class DocumentImpl

setMarkupAware

public void setMarkupAware(Boolean newMarkupAware)
Make the document markup-aware. This will trigger the creation of a DocumentFormat object at Document initialisation time; the DocumentFormat object will unpack the markup in the Document and add it as annotations. Documents are not markup-aware by default.
Overrides:
setMarkupAware in class DocumentImpl
Parameters:
b - markup awareness status.

cleanup

public void cleanup()
Overriden to remove the features listener, when the document is closed.
Overrides:
cleanup in class DocumentImpl

resourceAdopted

public void resourceAdopted(DatastoreEvent evt)
Called by a datastore when a new resource has been adopted
Overrides:
resourceAdopted in class DocumentImpl

resourceDeleted

public void resourceDeleted(DatastoreEvent evt)
Called by a datastore when a resource has been deleted
Overrides:
resourceDeleted in class DocumentImpl

resourceWritten

public void resourceWritten(DatastoreEvent evt)
Called by a datastore when a resource has been wrote into the datastore
Overrides:
resourceWritten in class DocumentImpl

getLoadedAnnotationSets

public Collection getLoadedAnnotationSets()
Specified by:
getLoadedAnnotationSets in interface EventAwareDocument

getRemovedAnnotationSets

public Collection getRemovedAnnotationSets()
Specified by:
getRemovedAnnotationSets in interface EventAwareDocument

getAddedAnnotationSets

public Collection getAddedAnnotationSets()
Specified by:
getAddedAnnotationSets in interface EventAwareDocument

removeAnnotationSet

public void removeAnnotationSet(String name)
Description copied from class: DocumentImpl
Removes one of the named annotation sets. Note that the default annotation set cannot be removed.
Overrides:
removeAnnotationSet in class DocumentImpl
Following copied from class: gate.corpora.DocumentImpl
Parameters:
name - the name of the annotation set to be removed

isModified

public boolean isModified()
Returns true of an LR has been modified since the last sync. Always returns false for transient LRs.
Overrides:
isModified in class AbstractLanguageResource

getParent

public LanguageResource getParent()
                           throws PersistenceException,
                                  SecurityException
Returns the parent LR of this LR. Only relevant for LRs that support shadowing. Most do not by default.
Overrides:
getParent in class AbstractLanguageResource

setParent

public void setParent(LanguageResource parentLR)
               throws PersistenceException,
                      SecurityException
Sets the parent LR of this LR. Only relevant for LRs that support shadowing. Most do not by default.
Overrides:
setParent in class AbstractLanguageResource

setInitData__$$__

public void setInitData__$$__(Object data)
                       throws PersistenceException,
                              InvalidOffsetException

getInitData__$$__

public Object getInitData__$$__(Object initData)

init

public Resource init()
              throws ResourceInstantiationException
Initialise this resource, and return it.
Overrides:
init in class DocumentImpl