01 /*
02 * AnnotationAccessor - transducer class
03 *
04 * Copyright (c) 1995-2010, The University of Sheffield. See the file
05 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06 *
07 * This file is part of GATE (see http://gate.ac.uk/), and is free
08 * software, licenced under the GNU Library General Public License,
09 * Version 2, June 1991 (in the distribution as file licence.html,
10 * and also available at http://gate.ac.uk/gate/licence.html).
11 *
12 * Eric Sword, 03/09/08
13 *
14 * $Id$
15 */
16 package gate.jape.constraint;
17
18 import gate.*;
19
20 import java.io.Serializable;
21
22 /**
23 * Provides way to access some property of an {@link Annotation} or
24 * otherwise get a value associated with an annotation (such as the
25 * length of text it spans or the text itself if the associated document
26 * is available).
27 *
28 * @version $Revision$
29 * @author esword
30 */
31 public interface AnnotationAccessor extends Serializable {
32
33 /**
34 * Store a key or name for the accessor to reference when it attempts
35 * to obtain the value of an object. Different implementors will have
36 * different uses for the key. For example, it could be the name of
37 * the feature that should be returned. It could also be the name of a
38 * property to invoke on the Annotation object.
39 *
40 * @param key
41 */
42 public void setKey(Object key);
43
44 /**
45 * Return the key for this accessor.
46 * @return
47 */
48 public Object getKey();
49
50 /**
51 * Obtain the value of some part of the given annotation
52 *
53 * @param annot
54 * @param context optional parameter with information about the
55 * context in which the annotation has meaning. Normally this
56 * would be a {@link Document}. Not all accessors will
57 * require the context information so it may be null. Some
58 * accessor implementations may throw an exception without
59 * it.
60 *
61 * @return
62 */
63 public Object getValue(Annotation annot, AnnotationSet context);
64 }
|