net.sourceforge.nrl.parser.ast.constraints.impl
Class ValidationFragmentDependencyProcessor

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

public class ValidationFragmentDependencyProcessor
extends Object

A dependency processor that can be fed with a number of fragment declarations, and returns them in dependency order. Properties with no dependencies will be returned first.

This class enables the type checker to determine a processing order, because fragment types cannot determined until types of properties referenced within them are clear.

The class also detects circular fragment references. Here is how to use it:

Author:
Christian Nentwich

Constructor Summary
ValidationFragmentDependencyProcessor()
           
 
Method Summary
 void addDeclaration(IDeclaration decl)
           
 void addDeclaration(IValidationFragmentDeclaration decl)
           
 void addDeclarations(IRuleFile file)
           
protected  Collection<net.sourceforge.nrl.parser.ast.constraints.impl.ValidationFragmentDependencyProcessor.DependencyNode> buildDependencyGraph()
          Build the graph of DependencyNode objects.
protected  void depthFirst(net.sourceforge.nrl.parser.ast.constraints.impl.ValidationFragmentDependencyProcessor.DependencyNode root, Collection<net.sourceforge.nrl.parser.ast.constraints.impl.ValidationFragmentDependencyProcessor.DependencyNode> removalList)
          Traverse from a node, and add all encountered nodes to the orderedDeclarations list.
 List<IDeclaration> getOrderedDeclarations()
           
protected  List<IDeclaration> getReferencedDeclarations(IDeclaration decl)
          Given a declaration, return a list of declarations it references.
 List<NRLError> resolve()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationFragmentDependencyProcessor

public ValidationFragmentDependencyProcessor()
Method Detail

addDeclaration

public void addDeclaration(IValidationFragmentDeclaration decl)

addDeclaration

public void addDeclaration(IDeclaration decl)

addDeclarations

public void addDeclarations(IRuleFile file)

resolve

public List<NRLError> resolve()

depthFirst

protected void depthFirst(net.sourceforge.nrl.parser.ast.constraints.impl.ValidationFragmentDependencyProcessor.DependencyNode root,
                          Collection<net.sourceforge.nrl.parser.ast.constraints.impl.ValidationFragmentDependencyProcessor.DependencyNode> removalList)
Traverse from a node, and add all encountered nodes to the orderedDeclarations list. Also remove from the second list being provided as parameter, to indicate processing.

Parameters:
root - the root node
removalList - the list to remove from

buildDependencyGraph

protected Collection<net.sourceforge.nrl.parser.ast.constraints.impl.ValidationFragmentDependencyProcessor.DependencyNode> buildDependencyGraph()
Build the graph of DependencyNode objects. See below for the class definition.

Returns:
the graph

getReferencedDeclarations

protected List<IDeclaration> getReferencedDeclarations(IDeclaration decl)
Given a declaration, return a list of declarations it references.

Parameters:
decl - the declarations
Returns:
the referenced declarations

getOrderedDeclarations

public List<IDeclaration> getOrderedDeclarations()


Copyright © 2006-2013. All Rights Reserved.