|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgate.jape.Constraint
public class Constraint
A set of predicates/expressions that apply to a single
Annotation type. It doesn't extend PatternElement, even
though it has to "match", because a set of Constraint must be applied
together in order to avoid doing separate selectAnnotations calls for
each one.
Matching Logic:The matching function of a non-negated constraint can be defined as, "There exists an annotation for which all of the predicates are true." Thus, given a collection of annotations, only a single annotation must meet all of the predicates of the constraint in order for the match to be successful.
Negation: A negated constraint means strictly the opposite - "There does not exist an annotation for which any of these predicates are true." Negation does not mean "There exists an annotation for which all of these predicates are false." Thus, negation makes more intuitive sense when thought of as applying to a set of annotations rather than to an individual annotation.
| Field Summary | |
|---|---|
protected FeatureMap |
ontFeatureMap
FeatureMap that may contain ontology-related features and values pulled from any predicates that operate on those features |
protected ConstraintPredicate |
ontLookupClassPred
Predicate that acts on class feature, if one is set. |
| Fields inherited from interface gate.jape.JapeConstants |
|---|
ALL_STYLE, APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, ONCE_STYLE, SINGLE_SPAN_BINDING |
| Constructor Summary | |
|---|---|
Constraint(String annotType)
Construction from annot type string |
|
Constraint(String annotType,
FeatureMap attrs)
Construction from annot type and FeatureMap. |
|
Constraint(String annotType,
List<JdmAttribute> attrsArray)
Deprecated. JdmAttributes are no longer used. Use ConstraintPredicates instead. |
|
| Method Summary | |
|---|---|
void |
addAttribute(ConstraintPredicate attr)
Add an attribute. |
void |
addAttribute(JdmAttribute attr)
Deprecated. |
void |
addAttribute(String name,
Object value)
Create and add an attribute. |
void |
addAttributes(Collection<ConstraintPredicate> attrs)
Add all predicates from the given collection to this object. |
void |
changeSign()
Change the sign of the negation flag. |
Object |
clone()
Need cloning for processing of macro references. |
boolean |
equals(Object other)
Returns a boolean value indicating whether this Constraint is equivalent to the given Constraint. |
void |
finish()
Finish: replace dynamic data structures with Java arrays; called after parsing. |
String |
getAnnotType()
Get the type of annotation we're looking for. |
List<ConstraintPredicate> |
getAttributeSeq()
Get the attributes that must be present on the matched annotation. |
String |
getAttributesString()
Returns string representation of all the attributes that is appropriate for display. |
String |
getDisplayString(String prefix)
Create a string representation of the object. |
protected FeatureMap |
getOntFeatureMap()
Generate a FeatureMap to perform ontology-related compare. |
int |
hashCode()
Returns an integer hash code for this object. |
boolean |
isNegated()
Access to negation flag. |
boolean |
matches(Annotation annot,
AnnotationSet context)
Test if an annotation is of the proper type for this constraint and if it complies with the ConstraintPredicates of this
constraint. |
boolean |
matches(Annotation annot,
Ontology ontologyLR,
AnnotationSet context)
Test if an annotation is of the proper type for this constraint and if it complies with the ConstraintPredicates of this
constraint. |
List<Annotation> |
matches(Collection<Annotation> annots,
Ontology ontology,
AnnotationSet context)
Invoke #matches(Annotation, Ontology, Object) on all provided
annotations. |
void |
negate()
Set negation. |
String |
shortDesc()
|
String |
toString()
Create a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ConstraintPredicate ontLookupClassPred
protected FeatureMap ontFeatureMap
| Constructor Detail |
|---|
public Constraint(String annotType)
public Constraint(String annotType,
FeatureMap attrs)
EqualPredicates for each feature in the map
@Deprecated
public Constraint(String annotType,
List<JdmAttribute> attrsArray)
ConstraintPredicates instead.
| Method Detail |
|---|
public void negate()
public void changeSign()
public boolean isNegated()
public String getAnnotType()
public List<ConstraintPredicate> getAttributeSeq()
public void addAttribute(ConstraintPredicate attr)
protected FeatureMap getOntFeatureMap()
public void addAttribute(JdmAttribute attr)
attr -
public void addAttribute(String name,
Object value)
public void addAttributes(Collection<ConstraintPredicate> attrs)
attrs - public Object clone()
PatternElement.clone()
clone in class Objectpublic boolean equals(Object other)
Object.equals().
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic void finish()
public String toString()
toString in class Objectpublic String getDisplayString(String prefix)
public String getAttributesString()
public String shortDesc()
public List<Annotation> matches(Collection<Annotation> annots,
Ontology ontology,
AnnotationSet context)
#matches(Annotation, Ontology, Object) on all provided
annotations.
annots - collection of Annotations to testontology - optional Ontology to compare ont-specific features
public final boolean matches(Annotation annot,
Ontology ontologyLR,
AnnotationSet context)
ConstraintPredicates of this
constraint.
annot - an AnnotationontologyLR - optional ontology to use when comparing
ont-related features
true if the annotation is of the proper type
and matches all predicates. If the constraint is negated,
an annotation need only match a single predicate to return
true.
public boolean matches(Annotation annot,
AnnotationSet context)
ConstraintPredicates of this
constraint.
annot - a Annotation
true if the annotation is of the proper type
and matches all predicates. If the constraint is negated,
an annotation need only match a single predicate to return
true.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||