com.voytechs.jnetstream.codec.filter
Class FilterAliases

java.lang.Object
  extended by com.voytechs.jnetstream.npl.Visitor
      extended by com.voytechs.jnetstream.codec.filter.FilterAliases

public class FilterAliases
extends Visitor

Sets up aliases for the filter. This class implements the Visitor pattern and traverses the passed AST searching for for "filter" statements. There are several modifiers on the FilterStatement, we're interested here in "filter alias".


Nested Class Summary
 class FilterAliases.AliasEntry
          Inner class that makes up an Alias entry stored in our hash.
 
Constructor Summary
FilterAliases()
          Initializes an empty aliases object.
FilterAliases(NodeList root)
          Initializes the aliases object with AST.
 
Method Summary
static void main(java.lang.String[] args)
          Test function for FilterAliases
 void subAliases(NodeList expression)
          Substitutes aliases for within the given expression when matches are found.
 boolean traverse(FilterStatement stat, java.lang.Object opath, java.lang.Object user2)
          During Visitor traversal record values of the filter statement.
 boolean traverse(HeaderStatement stat, java.lang.Object opath, java.lang.Object user2)
          During Visitor traversal recods the header statement onto a stack.
 boolean traverse(MutableReferenceNode ref, java.lang.Object user1, java.lang.Object user2)
          During Visitor traversal checks for any possible matches with list of defined aliases.
 
Methods inherited from class com.voytechs.jnetstream.npl.Visitor
traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, traverse, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterAliases

public FilterAliases()
Initializes an empty aliases object.


FilterAliases

public FilterAliases(NodeList root)
              throws NodeException
Initializes the aliases object with AST. The tree is traversed and all filter expressions evaluated.

Parameters:
root - The root of the Abstract Syntax Tree. This is where the traversal starts.
Throws:
NodeException
Method Detail

subAliases

public void subAliases(NodeList expression)
                throws NodeException
Substitutes aliases for within the given expression when matches are found.

Throws:
NodeException

traverse

public boolean traverse(MutableReferenceNode ref,
                        java.lang.Object user1,
                        java.lang.Object user2)
                 throws NodeException
During Visitor traversal checks for any possible matches with list of defined aliases. If one is found substitutes the new name based on aliase.

Overrides:
traverse in class Visitor
Parameters:
ref - Reference node to be aliased. Aliases only work on reference nodes.
Throws:
NodeException

traverse

public boolean traverse(HeaderStatement stat,
                        java.lang.Object opath,
                        java.lang.Object user2)
                 throws NodeException
During Visitor traversal recods the header statement onto a stack. So that when you declare a header within a header their names are pushed onto a stack making up a header path.

Overrides:
traverse in class Visitor
Parameters:
stat - Header statement node which contains many details.
opath - A stack which contains the path as made up of Headers where the filter statement was declared.
Throws:
NodeException

traverse

public boolean traverse(FilterStatement stat,
                        java.lang.Object opath,
                        java.lang.Object user2)
                 throws NodeException
During Visitor traversal record values of the filter statement.

Overrides:
traverse in class Visitor
Parameters:
stat - The filter statement node, which contains all of the statements paramaters.
opath - A stack which contains the path as made up of Headers where the filter statement was declared.
user2 - Not used.
Throws:
NodeException

main

public static void main(java.lang.String[] args)
Test function for FilterAliases

Parameters:
args - command line arguments