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
- public class DatabaseDocumentImpl
- extends DocumentImpl
- implements DatastoreListener, Document, EventAwareDocument
- See Also:
- Serialized Form
Fields inherited from class gate.corpora.DocumentImpl |
addGatePreserveFormatTag, ASC, content, defaultAnnots, DESC, DOC_SIZE_MULTIPLICATION_FACTOR, documentListeners, encoding, entitiesMap, gateListeners, isRootTag, markupAware, namedAnnotSets, nextAnnotationId, nextNodeId, ORDER_ON_ANNOT_ID, ORDER_ON_END_OFFSET, ORDER_ON_START_OFFSET, serialVersionUID, sourceUrl, sourceUrlEndOffset, sourceUrlStartOffset, stringContent |
Constructor Summary |
DatabaseDocumentImpl(Connection conn)
|
DatabaseDocumentImpl(Connection _conn,
String _name,
DatabaseDataStore _ds,
Long _persistenceID,
DocumentContent _content,
FeatureMap _features,
Boolean _isMarkupAware,
URL _sourceURL,
Long _urlStartOffset,
Long _urlEndOffset,
AnnotationSet _default,
Map _named)
|
Methods inherited from class gate.corpora.DocumentImpl |
, addDocumentListener, annotationSetToXml, buildEntityMapFromString, check, compareTo, datastoreClosed, datastoreCreated, datastoreOpened, edit, equals, featuresToXml, filterNonXmlChars, fireAnnotationSetAdded, fireAnnotationSetRemoved, getMarkupAware, getNextAnnotationId, getNextNodeId, getOrderingString, getSourceUrl, getSourceUrlEndOffset, getSourceUrlOffsets, getSourceUrlStartOffset, getStringContent, hashCode, init, insertsSafety, isValidOffset, isValidOffsetRange, isXmlChar, removeDocumentListener, replaceCharsWithEntities, resourceLoaded, resourceUnloaded, saveAnnotationSetAsXml, setEncoding, setLRPersistenceId, setNextAnnotationId, setStringContent, textWithNodes, toString, toXml, toXml, writeEmptyTag, writeEndTag, writeFeatures, writeStartTag |
DEBUG
private static final boolean DEBUG
isContentRead
private boolean isContentRead
contentLock
private Object contentLock
jdbcConn
private Connection jdbcConn
contentChanged
private boolean contentChanged
featuresChanged
private boolean featuresChanged
nameChanged
private boolean nameChanged
documentChanged
private boolean documentChanged
removedAnotationSets
private Collection removedAnotationSets
addedAnotationSets
private Collection addedAnotationSets
SEQUENCE_POOL_SIZE
private static final int SEQUENCE_POOL_SIZE
sequencePool
private Integer[] sequencePool
poolMarker
private int poolMarker
eventHandler
protected DatabaseDocumentImpl.EventsHandler eventHandler
- The listener for the events coming from the features.
DatabaseDocumentImpl
public DatabaseDocumentImpl(Connection conn)
DatabaseDocumentImpl
public DatabaseDocumentImpl(Connection _conn,
String _name,
DatabaseDataStore _ds,
Long _persistenceID,
DocumentContent _content,
FeatureMap _features,
Boolean _isMarkupAware,
URL _sourceURL,
Long _urlStartOffset,
Long _urlEndOffset,
AnnotationSet _default,
Map _named)
getContent
public DocumentContent getContent()
- The content of the document: a String for text; MPEG for video; etc.
- Specified by:
getContent
in interface Document
- 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
getNamedAnnotationSets
public Map getNamedAnnotationSets()
- Returns a map with the named annotation sets. It returns
null
if no named annotaton set exists.
- Specified by:
getNamedAnnotationSets
in interface Document
- 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.
- Specified by:
getAnnotations
in interface Document
- 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.
- Specified by:
getAnnotations
in interface Document
- 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
- Specified by:
setContent
in interface Document
- Overrides:
setContent
in class DocumentImpl
setFeatures
public void setFeatures(FeatureMap features)
- Set the feature set
- Specified by:
setFeatures
in interface FeatureBearer
- Overrides:
setFeatures
in class AbstractFeatureBearer
setName
public void setName(String name)
- Sets the name of this resource
- Specified by:
setName
in interface NameBearer
- Overrides:
setName
in class AbstractResource
getAnnotationsForOffset
private List getAnnotationsForOffset(AnnotationSet aDumpAnnotSet,
Long offset)
- Description copied from class:
DocumentImpl
- This method returns a list with annotations ordered that way that
they can be serialized from left to right, at the offset. If one of the
params is null then an empty list will be returned.
- Overrides:
getAnnotationsForOffset
in class DocumentImpl
- Following copied from class:
gate.corpora.DocumentImpl
- Parameters:
aDumpAnnotSet
- is a set containing all annotations that will be
dumped.offset
- represent the offset at witch the annotation must start
AND/OR end.- Returns:
- a list with those annotations that need to be serialized.
isResourceChanged
public boolean isResourceChanged(int changeType)
- Generate and return the next annotation ID
- Specified by:
isResourceChanged
in interface EventAwareLanguageResource
_setAnnotations
private void _setAnnotations(String setName,
Collection annotations)
setSourceUrl
public void setSourceUrl(URL sourceUrl)
- Set method for the document's URL
- Specified by:
setSourceUrl
in interface Document
- 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.
- Specified by:
setSourceUrlEndOffset
in interface Document
- 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.
- Specified by:
setSourceUrlStartOffset
in interface Document
- 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.
- Specified by:
setMarkupAware
in interface Document
- 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.
- Specified by:
cleanup
in interface Resource
- Overrides:
cleanup
in class DocumentImpl
resourceAdopted
public void resourceAdopted(DatastoreEvent evt)
- Called by a datastore when a new resource has been adopted
- Specified by:
resourceAdopted
in interface DatastoreListener
resourceDeleted
public void resourceDeleted(DatastoreEvent evt)
- Called by a datastore when a resource has been deleted
- Specified by:
resourceDeleted
in interface DatastoreListener
resourceWritten
public void resourceWritten(DatastoreEvent evt)
- Called by a datastore when a resource has been wrote into the datastore
- Specified by:
resourceWritten
in interface DatastoreListener
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 interface:
Document
- Removes one of the named annotation sets.
Note that the default annotation set cannot be removed.
- Specified by:
removeAnnotationSet
in interface Document
- Overrides:
removeAnnotationSet
in class DocumentImpl
- Following copied from interface:
gate.Document
- Parameters:
name
- the name of the annotation set to be removed