org.eclipse.actf.validation.rules
Interface ICriterion

All Known Subinterfaces:
IRule
All Known Implementing Classes:
AbstractCriterion, AbstractRule, AndRule, CompoundCriterion, EqRule, FocusRule, InstanceofRule, MaxRule, MinRule, NeqRule, NodeNameCriterion, OrRule, PropertyCriterion, RangeRule, ReflexiveCriterion, ReflexiveRule, RegexpRule, ScriptRule, TypeCriterion

public interface ICriterion


Method Summary
 void addPart(ICriterion criterion)
          adds a criterion(or rule) to the list of criterion(rule parts or nested rules) that are executed when this Criterion(rule) is evaluated.
 boolean apply(IValidationContext context, Object target)
          apply this rule to the given target using the given context.
 String getAttribute(String name)
          retrieves the attribute with the given name for this rule
 ICriterion getParent()
          return the parent rule of this rule.
 ICriterion[] getParts()
          returns the criterion(rule) parts or nested criteria(rules) for the criterion/rule
 IRuleSet getRuleSet()
          return the IRuleSet containing this IRule.
 void initialize(Object content)
          initialize this rule with any content that might be necessary for its application to a target during the invocation of the apply method.
 void setAttribute(String name, String value)
          set an arbitrary attribute for this rule
 void setParent(ICriterion parent)
          set the parent rule of this rule.
 void setParts(ICriterion[] criterion)
          set the criterion(rule) parts or nested criterion(rules) for this criterion(rule).
 void setRuleSet(IRuleSet iRuleSet)
          Set the containing IRuleSet for this rule.
 

Method Detail

addPart

void addPart(ICriterion criterion)
adds a criterion(or rule) to the list of criterion(rule parts or nested rules) that are executed when this Criterion(rule) is evaluated.

Parameters:
criterion - - criterion which encapsulates rule

setParts

void setParts(ICriterion[] criterion)
set the criterion(rule) parts or nested criterion(rules) for this criterion(rule).

Parameters:
criterion - - list of encapsulated rules(Criterion)

getParts

ICriterion[] getParts()
returns the criterion(rule) parts or nested criteria(rules) for the criterion/rule

Returns:
list of criterion which may be an instanceof rules

setParent

void setParent(ICriterion parent)
set the parent rule of this rule. Rules can be nested. There are some fields that are set only on the parent rule for all nested rule parts.

Parameters:
parent - rule

getParent

ICriterion getParent()
return the parent rule of this rule.

Returns:
instance of the parent rule

getRuleSet

IRuleSet getRuleSet()
return the IRuleSet containing this IRule.

Returns:
instance of the containing IRuleSet

setRuleSet

void setRuleSet(IRuleSet iRuleSet)
Set the containing IRuleSet for this rule. A IRule is contained by only one IRuleSet.

Parameters:
iRuleSet - parent rule

getAttribute

String getAttribute(String name)
retrieves the attribute with the given name for this rule

Parameters:
name - name of attribute
Returns:
attribute with given name or null

setAttribute

void setAttribute(String name,
                  String value)
set an arbitrary attribute for this rule

Parameters:
name - name of attribute
value - value of attribute

apply

boolean apply(IValidationContext context,
              Object target)
              throws Exception
apply this rule to the given target using the given context. The returned value indicates whether or not a violation of some kind has taken place.

Note that the context object can be used to retrieve a great deal of information about the current validation process. In particular, it can be used to update the validation report being generated with the violations that result from an application of this rule to the given target.

Parameters:
context - context under which rule is being evaluated (supplied by engine)
target - object to which rule is to be applied
Returns:
whether or not the target violates the rule
Throws:
Exception
See Also:
initialize(Object), IValidationContext, ValidationContextConstants

initialize

void initialize(Object content)
                throws Exception
initialize this rule with any content that might be necessary for its application to a target during the invocation of the apply method.

The specified content may take any form. It may be an XML element, a .properties file, a string, etc. This method may be invoked any time prior to calling apply.

Parameters:
content - - initialization content for the rule
Throws:
Exception
See Also:
apply(IValidationContext, Object)