1   /*
2    *  Annotation.java
3    *
4    *  Copyright (c) 1998-2001, The University of Sheffield.
5    *
6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
7    *  software, licenced under the GNU Library General Public License,
8    *  Version 2, June 1991 (in the distribution as file licence.html,
9    *  and also available at http://gate.ac.uk/gate/licence.html).
10   *
11   *  Hamish Cunningham, 19/Jan/00
12   *
13   *  $Id: Annotation.java,v 1.17 2001/10/21 13:26:24 kalina Exp $
14   */
15  
16  package gate;
17  
18  import java.io.*;
19  import java.util.*;
20  import gate.util.*;
21  import gate.event.*;
22  
23  /** An Annotation is an arc in an AnnotationGraph. It is immutable, to avoid
24    * the situation where each annotation has to point to its parent graph in
25    * order to tell it to update its indices when it changes.
26    * <P> Changes from TIPSTER: no ID; single span only.
27    *
28    * The event code is needed so a persistent annotation set can listen to
29    * its annotations and update correctly the database
30    */
31  public interface Annotation
32  extends FeatureBearer, IdBearer, Comparable, Serializable {
33  
34    /** The type of the annotation (corresponds to TIPSTER "name"). */
35    public String getType();
36  
37    /** The start node. */
38    public Node getStartNode();
39  
40    /** The end node. */
41    public Node getEndNode();
42  
43    /** Ordering */
44    public int compareTo(Object o) throws ClassCastException;
45  
46    /** This verifies if <b>this</b> annotation is compatible with another one.
47      * Compatible means that they hit the same possition and the FeatureMap of
48      * <b>this</b> is incuded into aAnnot FeatureMap.
49      * @param anAnnot a gate Annotation.
50      * @return <code>true</code> if aAnnot is compatible with <b>this</> and
51      * <code>false</code> otherwise.
52      */
53    public boolean isCompatible(Annotation anAnnot);
54  
55    /** This verifies if <b>this</b> annotation is compatible with another one,
56     *  given a set with certain keys.
57      * In this case, compatible means that they hit the same possition
58      * and those keys from <b>this</b>'s FeatureMap intersected with
59      * aFeatureNamesSet are incuded together with their values into the aAnnot's
60      * FeatureMap.
61      * @param anAnnot a gate Annotation.
62      * @param aFeatureNamesSet is a set containing certian key that will be
63      * intersected with <b>this</b>'s FeatureMap's keys.
64      * @return <code>true</code> if aAnnot is compatible with <b>this</> and
65      * <code>false</code> otherwise.
66      */
67    public boolean isCompatible(Annotation anAnnot, Set aFeatureNamesSet);
68  
69    /** This method verifies if two annotation and are partially compatible.
70      * Partially compatible means that they overlap and the FeatureMap of
71      * <b>this</b> is incuded into FeatureMap of aAnnot.
72      * @param anAnnot a gate Annotation.
73      * @return <code>true</code> if <b>this</b> is partially compatible with
74      * aAnnot and <code>false</code> otherwise.
75      */
76    public boolean isPartiallyCompatible(Annotation anAnnot);
77  
78    /** This method verifies if two annotation and are partially compatible,
79      * given a set with certain keys.
80      * In this case, partially compatible means that they overlap
81      * and those keys from <b>this</b>'s FeatureMap intersected with
82      * aFeatureNamesSet are incuded together with their values into the aAnnot's
83      * FeatureMap.
84      * @param anAnnot a gate Annotation.
85      * @param aFeatureNamesSet is a set containing certian key that will be
86      * intersected with <b>this</b>'s FeatureMap's keys.
87      * @return <code>true</code> if <b>this</b> is partially compatible with
88      * aAnnot and <code>false</code> otherwise.
89      */
90    public boolean isPartiallyCompatible(Annotation anAnnot,Set aFeatureNamesSet);
91  
92    /**  Two Annotation are coestensive if their offsets are the same.
93      *  @param anAnnot A Gate annotation.
94      *  @return <code>true</code> if two annotation hit the same possition and
95      *  <code>false</code> otherwise
96      */
97    public boolean coextensive(Annotation anAnnot);
98  
99    /** This method tells if <b>this</b> overlaps aAnnot.
100     * @param aAnnot a gate Annotation.
101     * @return <code>true</code> if they overlap and <code>false</code> false if
102     * they don't.
103     */
104   public boolean overlaps(Annotation aAnnot);
105 
106   /**
107    *
108    * Removes an annotation listener
109    */
110   public void removeAnnotationListener(AnnotationListener l);
111   /**
112    *
113    * Adds an annotation listener
114    */
115   public void addAnnotationListener(AnnotationListener l) ;
116 
117 } // interface Annotation,
118