net.sourceforge.nrl.parser.ast.impl
Class AntlrModelResolver

java.lang.Object
  extended by net.sourceforge.nrl.parser.ast.impl.AntlrModelResolver

public class AntlrModelResolver
extends Object

This class resolves all model references on the AST and replaces the string values with with proper references to model elements. It may generate errors in this process, if model elements are not found.

Author:
Christian Nentwich

Field Summary
protected  IModelCollection models
           
 
Constructor Summary
AntlrModelResolver(IModelCollection models)
           
 
Method Summary
protected  void eliminateExistenceWithBackreference(IConstraint constraint, IModelElement context)
           
protected  void eliminateExistenceWithBackreference(IRuleFile ruleFile)
          Eliminate any "exists" nodes whose element reference refers to the context element.
protected  Map<String,IVariableDeclaration> getGlobalVariablesAsMap(IRuleFile ruleFile)
           
 List<NRLError> resolve(IRuleFile ruleFile)
          Main method - resolve all model references in the entire AST.
protected  void resolveAction(IAction action, IClassifier context, Map<String,IVariableDeclaration> globalVariables, List<Variable> variables, List<NRLError> errors)
           
protected  void resolveActionFragment(IActionFragmentDeclaration macro, Map<String,IVariableDeclaration> globalVariables, List<NRLError> errors)
           
protected  void resolveActions(IRuleFile ruleFile, List<NRLError> errors)
           
protected  void resolveConstraints(IRuleFile ruleFile, Map<String,IVariableDeclaration> globalVariables, List<NRLError> errors)
           
protected  void resolveDeclarationsWithoutContext(IRuleFile ruleFile)
          Resolve all action rule/macro declarations that do not have a context, i.e.
protected  void resolveGlobalVariables(IRuleFile ruleFile, List<NRLError> errors)
           
protected  void resolveMultiContextDeclarations(IRuleFile ruleFile, List<NRLError> errors)
           
protected  void resolveRuleSets(IRuleFile ruleFile, Map<String,IVariableDeclaration> globalVariables, List<NRLError> errors)
          Resolve the context and constraints of rule set declarations
protected  void resolveSingleContextDeclarations(IRuleFile ruleFile, List<NRLError> errors)
           
protected  void resolveValidationFragmentDeclaration(IValidationFragmentDeclaration decl, Map<String,IVariableDeclaration> globalVariables, List<NRLError> errors)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

models

protected IModelCollection models
Constructor Detail

AntlrModelResolver

public AntlrModelResolver(IModelCollection models)
Method Detail

eliminateExistenceWithBackreference

protected void eliminateExistenceWithBackreference(IConstraint constraint,
                                                   IModelElement context)

eliminateExistenceWithBackreference

protected void eliminateExistenceWithBackreference(IRuleFile ruleFile)
Eliminate any "exists" nodes whose element reference refers to the context element. For example, if the context is "Trade" and the constraint is "The Trade has date = '2005-12-30'" then this method will eliminate the implied existence constraint "one trade has", and replace the formula with the subconstraint. The result formula is then: "date = '2005-12-30'".

Parameters:
ruleFile - the file to process

getGlobalVariablesAsMap

protected Map<String,IVariableDeclaration> getGlobalVariablesAsMap(IRuleFile ruleFile)

resolve

public List<NRLError> resolve(IRuleFile ruleFile)
Main method - resolve all model references in the entire AST.

Parameters:
ruleFile - the rule file AST
Returns:
errors, empty if no errors

resolveAction

protected void resolveAction(IAction action,
                             IClassifier context,
                             Map<String,IVariableDeclaration> globalVariables,
                             List<Variable> variables,
                             List<NRLError> errors)

resolveActionFragment

protected void resolveActionFragment(IActionFragmentDeclaration macro,
                                     Map<String,IVariableDeclaration> globalVariables,
                                     List<NRLError> errors)

resolveActions

protected void resolveActions(IRuleFile ruleFile,
                              List<NRLError> errors)

resolveConstraints

protected void resolveConstraints(IRuleFile ruleFile,
                                  Map<String,IVariableDeclaration> globalVariables,
                                  List<NRLError> errors)

resolveDeclarationsWithoutContext

protected void resolveDeclarationsWithoutContext(IRuleFile ruleFile)
Resolve all action rule/macro declarations that do not have a context, i.e. a context of 'None'.

Parameters:
ruleFile - the rule file

resolveGlobalVariables

protected void resolveGlobalVariables(IRuleFile ruleFile,
                                      List<NRLError> errors)

resolveMultiContextDeclarations

protected void resolveMultiContextDeclarations(IRuleFile ruleFile,
                                               List<NRLError> errors)

resolveValidationFragmentDeclaration

protected void resolveValidationFragmentDeclaration(IValidationFragmentDeclaration decl,
                                                    Map<String,IVariableDeclaration> globalVariables,
                                                    List<NRLError> errors)

resolveRuleSets

protected void resolveRuleSets(IRuleFile ruleFile,
                               Map<String,IVariableDeclaration> globalVariables,
                               List<NRLError> errors)
Resolve the context and constraints of rule set declarations

Parameters:
ruleFile - the rule file
errors - the error list to add to

resolveSingleContextDeclarations

protected void resolveSingleContextDeclarations(IRuleFile ruleFile,
                                                List<NRLError> errors)


Copyright © 2006-2013. All Rights Reserved.