001 /*
002 * Annotation.java
003 *
004 * Copyright (c) 1995-2010, The University of Sheffield. See the file
005 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
006 *
007 * This file is part of GATE (see http://gate.ac.uk/), and is free
008 * software, licenced under the GNU Library General Public License,
009 * Version 2, June 1991 (in the distribution as file licence.html,
010 * and also available at http://gate.ac.uk/gate/licence.html).
011 *
012 * Hamish Cunningham, 19/Jan/00
013 *
014 * $Id: Annotation.java 13230 2010-11-16 20:01:40Z johann_p $
015 */
016
017 package gate;
018
019 import java.io.Serializable;
020 import java.util.Set;
021
022 import gate.event.AnnotationListener;
023 import gate.util.FeatureBearer;
024 import gate.util.IdBearer;
025
026 /** An Annotation is an arc in an AnnotationSet. It is immutable, to avoid
027 * the situation where each annotation has to point to its parent graph in
028 * order to tell it to update its indices when it changes.
029 * <P> Changes from TIPSTER: no ID; single span only.
030 *
031 * It inherits from SimpleAnnotation in order to allow users to add events
032 * and more methods for comparing annotations
033 *
034 * The event code is needed so a persistent annotation set can listen to
035 * its annotations and update correctly the database
036 */
037 public interface Annotation
038 extends SimpleAnnotation, Serializable {
039
040 /** This verifies if <b>this</b> annotation is compatible with another one.
041 * Compatible means that they hit the same possition and the FeatureMap of
042 * <b>this</b> is incuded into aAnnot FeatureMap.
043 * @param anAnnot a gate Annotation.
044 * @return <code>true</code> if aAnnot is compatible with <b>this</b> and
045 * <code>false</code> otherwise.
046 */
047 public boolean isCompatible(Annotation anAnnot);
048
049 /** This verifies if <b>this</b> annotation is compatible with another one,
050 * given a set with certain keys.
051 * In this case, compatible means that they hit the same possition
052 * and those keys from <b>this</b>'s FeatureMap intersected with
053 * aFeatureNamesSet are incuded together with their values into the aAnnot's
054 * FeatureMap.
055 * @param anAnnot a gate Annotation.
056 * @param aFeatureNamesSet is a set containing certian key that will be
057 * intersected with <b>this</b>'s FeatureMap's keys.
058 * @return <code>true</code> if aAnnot is compatible with <b>this</b> and
059 * <code>false</code> otherwise.
060 */
061 public boolean isCompatible(Annotation anAnnot, Set aFeatureNamesSet);
062
063 /** This method verifies if two annotation and are partially compatible.
064 * Partially compatible means that they overlap and the FeatureMap of
065 * <b>this</b> is incuded into FeatureMap of aAnnot.
066 * @param anAnnot a gate Annotation.
067 * @return <code>true</code> if <b>this</b> is partially compatible with
068 * aAnnot and <code>false</code> otherwise.
069 */
070 public boolean isPartiallyCompatible(Annotation anAnnot);
071
072 /** This method verifies if two annotation and are partially compatible,
073 * given a set with certain keys.
074 * In this case, partially compatible means that they overlap
075 * and those keys from <b>this</b>'s FeatureMap intersected with
076 * aFeatureNamesSet are incuded together with their values into the aAnnot's
077 * FeatureMap.
078 * @param anAnnot a gate Annotation.
079 * @param aFeatureNamesSet is a set containing certian key that will be
080 * intersected with <b>this</b>'s FeatureMap's keys.
081 * @return <code>true</code> if <b>this</b> is partially compatible with
082 * aAnnot and <code>false</code> otherwise.
083 */
084 public boolean isPartiallyCompatible(Annotation anAnnot,Set aFeatureNamesSet);
085
086 /** Two Annotation are coestensive if their offsets are the same.
087 * @param anAnnot A Gate annotation.
088 * @return <code>true</code> if two annotation hit the same possition and
089 * <code>false</code> otherwise
090 */
091 public boolean coextensive(Annotation anAnnot);
092
093 /**
094 * This method determines if <b>this</b> overlaps aAnnot, i.e. if either
095 * the beginning or the end (or both) of anAnnot is
096 * contained in the span of <b>this</b>.
097 *
098 * @param aAnnot a gate Annotation.
099 * @return <code>true</code> if they overlap and <code>false</code> false if
100 * they don't or if aAnnot is null.
101 */
102 public boolean overlaps(Annotation aAnnot);
103
104 /** This method tells if <b>this</b> annotation's text range is
105 * fully contained within the text annotated by <code>aAnnot</code>'s
106 * annotation.
107 * @param aAnnot a gate Annotation.
108 * @return <code>true</code> if this annotation is fully contained in the
109 * other one.
110 */
111 public boolean withinSpanOf(Annotation aAnnot);
112
113 /**
114 *
115 * Removes an annotation listener
116 */
117 public void removeAnnotationListener(AnnotationListener l);
118 /**
119 *
120 * Adds an annotation listener
121 */
122 public void addAnnotationListener(AnnotationListener l) ;
123
124 } // interface Annotation,
|