org.eclipse.actf.validation.doc.rulebase
Class ReflectionDocumentRuleFactory

java.lang.Object
  extended by org.eclipse.actf.validation.doc.rulebase.ReflectionDocumentRuleFactory
All Implemented Interfaces:
IRuleFactory

public class ReflectionDocumentRuleFactory
extends Object
implements IRuleFactory

The IRuleFactory for ACTF rules.

Author:
John Buslawski

Field Summary
protected static Map ruleMap
           
 
Constructor Summary
ReflectionDocumentRuleFactory()
           
 
Method Summary
protected  List createComponentCriteria(Element comp)
           
protected  IRule createCriteria(Attr criteriaAttr)
           
protected  IRule createRule(Element ruleElem)
           
protected  IRule createRule(Element ruleElement, IRule parent)
           
protected  List createRulesForComponent(Element comp)
           
protected  String getAliasValue(String name)
           
 ICodeProcessor getCodeProcessor()
           
 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.
 IRuleMapping getRuleMapping(Object rulesetToken)
          retreaves a rule 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.
 IRuleSet getRuleSet()
           
 boolean isRuleAttribute(String name)
           
 IRule makeRuleInstance(Object obj)
          Makes an instance of the rule using the object.
 IRule makeRuleInstance(Object obj, IRule parent)
          Makes an instance of the rule using the object having the specified parent.
protected  void processRuleElement(Element ruleElem, Map componentCriteriaMap)
           
 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

ReflectionDocumentRuleFactory

public ReflectionDocumentRuleFactory()
Method Detail

getCodeProcessor

public ICodeProcessor getCodeProcessor()

setCodeProcessor

public void setCodeProcessor(ICodeProcessor codeProc)

getRuleBase

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

setRuleBase

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

Specified by:
setRuleBase in interface IRuleFactory

getRuleSet

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

setRuleSet

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

Specified by:
setRuleSet in interface IRuleFactory

getRuleMapping

public IRuleMapping getRuleMapping(Object rulesetToken)
retreaves a rule 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:
getRuleMapping in interface IRuleFactory
Parameters:
rulesetToken - - ruleset (or token of ruleset) associated with this factory
Returns:
rule mapping

processRuleElement

protected void processRuleElement(Element ruleElem,
                                  Map componentCriteriaMap)

createRulesForComponent

protected List createRulesForComponent(Element comp)

createRule

protected IRule createRule(Element ruleElement,
                           IRule parent)

createRule

protected IRule createRule(Element ruleElem)

getAliasValue

protected String getAliasValue(String name)

createComponentCriteria

protected List createComponentCriteria(Element comp)

createCriteria

protected IRule createCriteria(Attr criteriaAttr)

registerRuleClassName

public void registerRuleClassName(String name,
                                  String ruleClassName)
registers a validation rule class for the given type

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

getRuleInstance

public IRule getRuleInstance(String name)
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 IRuleFactory
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:
IRuleFactory.registerRuleClassName(String, String)

getRuleInstance

public IRule getRuleInstance(String name,
                             IRule parent)
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 IRuleFactory
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:
IRuleFactory.registerRuleClassName(String, String)

makeRuleInstance

public IRule makeRuleInstance(Object obj,
                              IRule parent)
Makes an instance of the rule using the object having the specified parent.

Specified by:
makeRuleInstance in interface IRuleFactory
Parameters:
obj - - Object from which the rule is derived
parent - - parent rule instance
Returns:
the rule based on the input object

makeRuleInstance

public IRule makeRuleInstance(Object obj)
Makes an instance of the rule using the object.

Specified by:
makeRuleInstance in interface IRuleFactory
Parameters:
obj - - Object from which the rule is derived
Returns:
the rule based on the input object

isRuleAttribute

public boolean isRuleAttribute(String name)