gate.jape.constraint
Class AbstractRegExpPredicate
java.lang.Object
gate.jape.constraint.AbstractConstraintPredicate
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
AbstractRegExpPredicate
public AbstractRegExpPredicate()
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.