org.eclipse.actf.validation.valdoc.rulebase
Class ReflectionDocumentCriterionFactory

java.lang.Object
  extended by org.eclipse.actf.validation.valdoc.rulebase.ReflectionDocumentCriterionFactory
All Implemented Interfaces:
ICriterionFactory

public class ReflectionDocumentCriterionFactory
extends Object
implements ICriterionFactory

The IRuleFactory for ACTF rules.

Author:
John Buslawski

Field Summary
protected static Map ruleMap
           
 
Constructor Summary
ReflectionDocumentCriterionFactory()
           
 
Method Summary
protected  IRule createRule(Element ruleElem)
           
protected  IRule createRule(Element ruleElement, ICriterion parent)
           
protected  List<IRule> createRulesForCriterion(Element ruleElem)
           
protected  String getAliasValue(String name)
           
 ICodeProcessor getCodeProcessor()
           
 ICriterionMapping getCriterionMapping(Object rulesetToken)
          retrieves a criterion mapping that maps a type of object to a set of rules. For a ReflectionDocument,the mapping will consist of a Java type mapped to a set of rules to be applied to instances of that type.
 IRuleBase getRuleBase()
           
 IRule getRuleInstance(String name)
          gets an instance of the validation rule for the given name.
 IRule getRuleInstance(String name, IRule parent)
          creates and initializes a validation rule for the given name.
 IRuleSet getRuleSet()
           
 boolean isRuleAttribute(String name)
          Checks to see the parameter is a rule Attribute
 ICriterion makeCriterionInstance(Object obj)
          Makes an instance of the criterion using the object.
 ICriterion makeCriterionInstance(Object obj, ICriterion parent)
          Makes an instance of the criterion using the object having the specified parent.
protected  void processRuleElement(Element ruleElem, Map<ICriterion,List<IRule>> criteriaRuleMap)
           
 void registerRuleClassName(String name, String ruleClassName)
          registers a validation rule class for the given type
 void setCodeProcessor(ICodeProcessor codeProc)
           
 void setRuleBase(IRuleBase ruleBase)
          set the rulebase for this factory
 void setRuleSet(IRuleSet ruleSet)
          set the ruleset for this factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ruleMap

protected static final Map ruleMap
Constructor Detail

ReflectionDocumentCriterionFactory

public ReflectionDocumentCriterionFactory()
Method Detail

getCodeProcessor

public ICodeProcessor getCodeProcessor()

setCodeProcessor

public void setCodeProcessor(ICodeProcessor codeProc)

getRuleBase

public IRuleBase getRuleBase()
Specified by:
getRuleBase in interface ICriterionFactory
Returns:
rulebase

setRuleBase

public void setRuleBase(IRuleBase ruleBase)
Description copied from interface: ICriterionFactory
set the rulebase for this factory

Specified by:
setRuleBase in interface ICriterionFactory

getRuleSet

public IRuleSet getRuleSet()
Specified by:
getRuleSet in interface ICriterionFactory
Returns:
ruleset

setRuleSet

public void setRuleSet(IRuleSet ruleSet)
Description copied from interface: ICriterionFactory
set the ruleset for this factory

Specified by:
setRuleSet in interface ICriterionFactory

getCriterionMapping

public ICriterionMapping getCriterionMapping(Object rulesetToken)
retrieves a criterion mapping that maps a type of object to a set of rules. The mapping is created lazily based on the token representing the ruleset with which this factory is associated.

For a ReflectionDocument,the mapping will consist of a Java type mapped to a set of rules to be applied to instances of that type. The type is typically aliased and is the name of the element defining a particular set of rules within a ruleset.

Hence, the 'rulesetToken' should be an instance of org.w3c.dom.Element, having a name that specifies the type for which rules represented by its child elements are to be applied.

Specified by:
getCriterionMapping in interface ICriterionFactory
Parameters:
rulesetToken - - ruleset (or token of ruleset) associated with this factory
Returns:
rule mapping

processRuleElement

protected void processRuleElement(Element ruleElem,
                                  Map<ICriterion,List<IRule>> criteriaRuleMap)

createRulesForCriterion

protected List<IRule> createRulesForCriterion(Element ruleElem)

createRule

protected IRule createRule(Element ruleElement,
                           ICriterion parent)

createRule

protected IRule createRule(Element ruleElem)

getAliasValue

protected String getAliasValue(String name)

registerRuleClassName

public void registerRuleClassName(String name,
                                  String ruleClassName)
Description copied from interface: ICriterionFactory
registers a validation rule class for the given type

Specified by:
registerRuleClassName in interface ICriterionFactory
Parameters:
name - - name under which the rule is being registered
ruleClassName - - the class name of the rule implementation

getRuleInstance

public IRule getRuleInstance(String name)
Description copied from interface: ICriterionFactory
gets an instance of the validation rule for the given name. The rule must have been previously registered via the registerRuleClassName method or must be one of the standard ACTF validation rules.

Specified by:
getRuleInstance in interface ICriterionFactory
Parameters:
name - - name of the rule
Returns:
the registered rule for the given name or null if there was no rule registered under that name
See Also:
ICriterionFactory.registerRuleClassName(String, String)

getRuleInstance

public IRule getRuleInstance(String name,
                             IRule parent)
Description copied from interface: ICriterionFactory
creates and initializes a validation rule for the given name. The rule must have been previously registered via the registerRuleClassName method or must be one of the standard ACTF validation rules.

Specified by:
getRuleInstance in interface ICriterionFactory
Parameters:
name - - name of the rule
parent - - parent rule instance
Returns:
the registered rule for the given name or null if there was no rule registered under that name
See Also:
ICriterionFactory.registerRuleClassName(String, String)

makeCriterionInstance

public ICriterion makeCriterionInstance(Object obj,
                                        ICriterion parent)
Description copied from interface: ICriterionFactory
Makes an instance of the criterion using the object having the specified parent.

Specified by:
makeCriterionInstance in interface ICriterionFactory
Parameters:
obj - - Object from which the criterion is derived
parent - - parent criterion instance
Returns:
the criterion based on the input object

makeCriterionInstance

public ICriterion makeCriterionInstance(Object obj)
Description copied from interface: ICriterionFactory
Makes an instance of the criterion using the object.

Specified by:
makeCriterionInstance in interface ICriterionFactory
Parameters:
obj - - Object from which the criterion is derived
Returns:
the criterion based on the input object

isRuleAttribute

public boolean isRuleAttribute(String name)
Checks to see the parameter is a rule Attribute

Parameters:
name -
Returns:
boolean