Search in sources :

Example 1 with DocumentEvent

use of gate.event.DocumentEvent in project gate-core by GateNLP.

the class DocumentImpl method getAnnotations.

// getAnnotations()
/**
 * 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 or the empty string then
 * it returns the default annotation set.
 */
@Override
public AnnotationSet getAnnotations(String name) {
    if (name == null || "".equals(name))
        return getAnnotations();
    if (namedAnnotSets == null) {
        namedAnnotSets = new HashMap<String, AnnotationSet>();
    }
    AnnotationSet namedSet = namedAnnotSets.get(name);
    if (namedSet == null) {
        namedSet = new AnnotationSetImpl(this, name);
        namedAnnotSets.put(name, namedSet);
        DocumentEvent evt = new DocumentEvent(this, DocumentEvent.ANNOTATION_SET_ADDED, name);
        fireAnnotationSetAdded(evt);
    }
    return namedSet;
}
Also used : AnnotationSetImpl(gate.annotation.AnnotationSetImpl) AnnotationSet(gate.AnnotationSet) DocumentEvent(gate.event.DocumentEvent)

Example 2 with DocumentEvent

use of gate.event.DocumentEvent in project gate-core by GateNLP.

the class DocumentImpl method getAnnotations.

/**
 * Get the default set of annotations. The set is created if it doesn't exist
 * yet.
 */
@Override
public AnnotationSet getAnnotations() {
    if (defaultAnnots == null) {
        defaultAnnots = new AnnotationSetImpl(this, "");
        fireAnnotationSetAdded(new DocumentEvent(this, DocumentEvent.ANNOTATION_SET_ADDED, ""));
    }
    // if
    return defaultAnnots;
}
Also used : AnnotationSetImpl(gate.annotation.AnnotationSetImpl) DocumentEvent(gate.event.DocumentEvent)

Aggregations

AnnotationSetImpl (gate.annotation.AnnotationSetImpl)2 DocumentEvent (gate.event.DocumentEvent)2 AnnotationSet (gate.AnnotationSet)1