Annotation.java |
1 /* 2 * Annotation.java 3 * 4 * Copyright (c) 1998-2005, 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.23 2005/11/22 16:39:07 ian_roberts Exp $ 14 */ 15 16 package gate; 17 18 import java.io.Serializable; 19 import java.util.Set; 20 21 import gate.event.AnnotationListener; 22 import gate.util.FeatureBearer; 23 import gate.util.IdBearer; 24 25 /** An Annotation is an arc in an AnnotationSet. It is immutable, to avoid 26 * the situation where each annotation has to point to its parent graph in 27 * order to tell it to update its indices when it changes. 28 * <P> Changes from TIPSTER: no ID; single span only. 29 * 30 * It inherits from SimpleAnnotation in order to allow users to add events 31 * and more methods for comparing annotations 32 * 33 * The event code is needed so a persistent annotation set can listen to 34 * its annotations and update correctly the database 35 */ 36 public interface Annotation 37 extends SimpleAnnotation, Serializable { 38 39 /** This verifies if <b>this</b> annotation is compatible with another one. 40 * Compatible means that they hit the same possition and the FeatureMap of 41 * <b>this</b> is incuded into aAnnot FeatureMap. 42 * @param anAnnot a gate Annotation. 43 * @return <code>true</code> if aAnnot is compatible with <b>this</b> and 44 * <code>false</code> otherwise. 45 */ 46 public boolean isCompatible(Annotation anAnnot); 47 48 /** This verifies if <b>this</b> annotation is compatible with another one, 49 * given a set with certain keys. 50 * In this case, compatible means that they hit the same possition 51 * and those keys from <b>this</b>'s FeatureMap intersected with 52 * aFeatureNamesSet are incuded together with their values into the aAnnot's 53 * FeatureMap. 54 * @param anAnnot a gate Annotation. 55 * @param aFeatureNamesSet is a set containing certian key that will be 56 * intersected with <b>this</b>'s FeatureMap's keys. 57 * @return <code>true</code> if aAnnot is compatible with <b>this</> and 58 * <code>false</code> otherwise. 59 */ 60 public boolean isCompatible(Annotation anAnnot, Set aFeatureNamesSet); 61 62 /** This method verifies if two annotation and are partially compatible. 63 * Partially compatible means that they overlap and the FeatureMap of 64 * <b>this</b> is incuded into FeatureMap of aAnnot. 65 * @param anAnnot a gate Annotation. 66 * @return <code>true</code> if <b>this</b> is partially compatible with 67 * aAnnot and <code>false</code> otherwise. 68 */ 69 public boolean isPartiallyCompatible(Annotation anAnnot); 70 71 /** This method verifies if two annotation and are partially compatible, 72 * given a set with certain keys. 73 * In this case, partially compatible means that they overlap 74 * and those keys from <b>this</b>'s FeatureMap intersected with 75 * aFeatureNamesSet are incuded together with their values into the aAnnot's 76 * FeatureMap. 77 * @param anAnnot a gate Annotation. 78 * @param aFeatureNamesSet is a set containing certian key that will be 79 * intersected with <b>this</b>'s FeatureMap's keys. 80 * @return <code>true</code> if <b>this</b> is partially compatible with 81 * aAnnot and <code>false</code> otherwise. 82 */ 83 public boolean isPartiallyCompatible(Annotation anAnnot,Set aFeatureNamesSet); 84 85 /** Two Annotation are coestensive if their offsets are the same. 86 * @param anAnnot A Gate annotation. 87 * @return <code>true</code> if two annotation hit the same possition and 88 * <code>false</code> otherwise 89 */ 90 public boolean coextensive(Annotation anAnnot); 91 92 /** This method tells if <b>this</b> overlaps aAnnot. 93 * @param aAnnot a gate Annotation. 94 * @return <code>true</code> if they overlap and <code>false</code> false if 95 * they don't. 96 */ 97 public boolean overlaps(Annotation aAnnot); 98 99 /** 100 * 101 * Removes an annotation listener 102 */ 103 public void removeAnnotationListener(AnnotationListener l); 104 /** 105 * 106 * Adds an annotation listener 107 */ 108 public void addAnnotationListener(AnnotationListener l) ; 109 110 } // interface Annotation, 111