gate.jape.constraint
Class AbstractRegExpPredicate

java.lang.Object
  extended by gate.jape.constraint.AbstractConstraintPredicate
      extended by gate.jape.constraint.AbstractRegExpPredicate
All Implemented Interfaces:
ConstraintPredicate, Serializable
Direct Known Subclasses:
NotRegExpFindPredicate, NotRegExpMatchPredicate, RegExpFindPredicate, RegExpMatchPredicate

public abstract class AbstractRegExpPredicate
extends AbstractConstraintPredicate

Abstract regular expression based predicate implementation. This class handles parsing of the regexp into a Pattern object, and at match time it creates a Matcher for the annotation value. Concrete subclasses define the different criteria for what counts as a "match" in terms of Matcher.find() and Matcher.matches().

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gate.jape.constraint.AbstractConstraintPredicate
accessor, value
 
Fields inherited from interface gate.jape.constraint.ConstraintPredicate
EQUAL, GREATER, GREATER_OR_EQUAL, LESSER, LESSER_OR_EQUAL, NOT_EQUAL, NOT_REGEXP_FIND, NOT_REGEXP_MATCH, REGEXP_FIND, REGEXP_MATCH
 
Constructor Summary
AbstractRegExpPredicate()
           
 
Method Summary
 boolean doMatch(Object annotValue, AnnotationSet context)
          Returns true if the given value matches the set pattern.
protected abstract  boolean matcherResult(Matcher m)
          Must be implemented by subclasses to define the matching logic, typically one of Matcher.find() and Matcher.matches(), possibly negated.
 void setValue(Object value)
          Set the value used in comparisons against passed in data in ConstraintPredicate.matches(Annotation, AnnotationSet).
 String toString()
           
 
Methods inherited from class gate.jape.constraint.AbstractConstraintPredicate
equals, getAccessor, getValue, hashCode, matches, setAccessor
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gate.jape.constraint.ConstraintPredicate
getOperator
 

Constructor Detail

AbstractRegExpPredicate

public AbstractRegExpPredicate()
Method Detail

toString

public String toString()
Overrides:
toString in class AbstractConstraintPredicate

setValue

public void setValue(Object value)
Description copied from interface: ConstraintPredicate
Set the value used in comparisons against passed in data in ConstraintPredicate.matches(Annotation, AnnotationSet).

Specified by:
setValue in interface ConstraintPredicate
Overrides:
setValue in class AbstractConstraintPredicate

doMatch

public boolean doMatch(Object annotValue,
                       AnnotationSet context)
                throws JapeException
Returns true if the given value matches the set pattern. If the value is null it is treated as an empty string. The actual matching logic is defined by matcherResult(java.util.regex.Matcher).

Specified by:
doMatch in class AbstractConstraintPredicate
Throws:
JapeException

matcherResult

protected abstract boolean matcherResult(Matcher m)
Must be implemented by subclasses to define the matching logic, typically one of Matcher.find() and Matcher.matches(), possibly negated.

Parameters:
m - a Matcher for the annotation value string, obtained from the constraint pattern.
Returns:
true if this constraint should be considered to match, false otherwise.