001 /*
002 * ConstraintPredicate - transducer class
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 * Eric Sword, 03/09/08
013 *
014 * $Id$
015 */
016 package gate.jape.constraint;
017
018 import gate.Annotation;
019 import gate.AnnotationSet;
020 import gate.jape.JapeException;
021
022 import java.io.Serializable;
023
024 /**
025 * A predicate defines a single boolean operation on an
026 * {@link gate.Annotation} or some property of an annotation. These are
027 * also referred to as attributes of a constraint.
028 * <p>
029 * Implementors will determine if a provided annotation matches the
030 * predicate based on the intent of the operator (equals, not equals,
031 * greater than, etc).
032 *
033 * @version $Revision$
034 * @author esword
035 */
036 public interface ConstraintPredicate extends Serializable {
037
038 // Standard operators. Note that this was purposefully not done as an
039 // enum so that additional operators could be added dynamically for other
040 // parsers
041 public String EQUAL = "==";
042
043 public String NOT_EQUAL = "!=";
044
045 public String GREATER = ">";
046
047 public String LESSER = "<";
048
049 public String GREATER_OR_EQUAL = ">=";
050
051 public String LESSER_OR_EQUAL = "<=";
052
053 public String REGEXP_FIND = "=~";
054
055 public String NOT_REGEXP_FIND = "!~";
056
057 public String REGEXP_MATCH = "==~";
058
059 public String NOT_REGEXP_MATCH = "!=~";
060
061 /**
062 * The accessor associated with this predicate.
063 *
064 * @return
065 */
066 public AnnotationAccessor getAccessor();
067
068 /**
069 * Set the accessor associated with this predicate.
070 */
071 public void setAccessor(AnnotationAccessor accessor);
072
073 /**
074 * The value used in comparisons against passed in data in
075 * {@link #matches(Annotation)}.
076 *
077 * @return
078 */
079 public Object getValue();
080
081 /**
082 * Set the value used in comparisons against passed in data in
083 * {@link #matches(Annotation)}.
084 *
085 * @param value
086 */
087 public void setValue(Object value);
088
089 /**
090 * String representation of the logic operator that the predicate
091 * implements.
092 */
093 public String getOperator();
094
095 /**
096 * Evaluates if the provided annotation meets the requirements of the
097 * predicate.
098 *
099 * @param annot
100 * @param context
101 * @return
102 * @throws JapeException
103 */
104 public boolean matches(Annotation annot, AnnotationSet context) throws JapeException;
105 }
|