org.jboss.dna.graph.connector.federation
Class ProjectionParser

java.lang.Object
  extended by org.jboss.dna.graph.connector.federation.ProjectionParser

@ThreadSafe
public class ProjectionParser
extends Object

A parser library for projections and projection rules.


Constructor Summary
ProjectionParser()
           
 
Method Summary
 void addRuleParser(Class<?> clazz, String methodName)
          Add a static method that can be used to parse rule definition strings.
 void addRuleParser(ClassLoader classLoader, String className, String methodName)
          Add a static method that can be used to parse rule definition strings.
 void addRuleParser(Method method)
          Add a static method that can be used to parse rule definition strings.
static ProjectionParser getInstance()
          Get the shared projection parser, which is by default populated with the standard parser rules.
 boolean removeRuleParser(Method method)
          Remove the rule parser method.
 boolean removeRuleParser(String declaringClassName, String methodName)
          Remove the rule parser method.
 Projection.Rule ruleFromString(String definition, ExecutionContext context)
          Parse the string form of a rule definition and return the rule
 Projection.Rule[] rulesFromString(ExecutionContext context, String definitions)
          Parse a single string containing one or more string forms of rule definitions, and return the rules.
 Projection.Rule[] rulesFromStrings(ExecutionContext context, String... definitions)
          Parse string forms of an arry of rule definitions and return the rules
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectionParser

public ProjectionParser()
Method Detail

getInstance

public static ProjectionParser getInstance()
Get the shared projection parser, which is by default populated with the standard parser rules.

Returns:
the parser; never null

addRuleParser

public void addRuleParser(Method method)
Add a static method that can be used to parse rule definition strings. These methods must be static, must accept a String definition as the first parameter and an ExecutionContext environment reference as the second parameter, and should return the resulting Projection.Rule (or null if the definition format could not be understood by the method. Any exceptions during invocation will be logged at the trace level.

Parameters:
method - the method to be added
See Also:
addRuleParser(ClassLoader, String, String)

addRuleParser

public void addRuleParser(Class<?> clazz,
                          String methodName)
                   throws SecurityException,
                          NoSuchMethodException
Add a static method that can be used to parse rule definition strings. These methods must be static, must accept a String definition as the first parameter and an ExecutionContext environment reference as the second parameter, and should return the resulting Projection.Rule (or null if the definition format could not be understood by the method. Any exceptions during invocation will be logged at the trace level.

Parameters:
clazz - the class on which the static method is defined; may not be null
methodName - the name of the method
Throws:
SecurityException - if there is a security exception while loading the class or getting the method
NoSuchMethodException - if the method does not exist on the class
IllegalArgumentException - if the class loader reference is null, or if the class name or method name are null or empty
See Also:
addRuleParser(Method)

addRuleParser

public void addRuleParser(ClassLoader classLoader,
                          String className,
                          String methodName)
                   throws SecurityException,
                          NoSuchMethodException,
                          ClassNotFoundException
Add a static method that can be used to parse rule definition strings. These methods must be static, must accept a String definition as the first parameter and an ExecutionContext environment reference as the second parameter, and should return the resulting Projection.Rule (or null if the definition format could not be understood by the method. Any exceptions during invocation will be logged at the trace level.

Parameters:
classLoader - the class loader that should be used to load the class on which the method is defined; may not be null
className - the name of the class on which the static method is defined; may not be null
methodName - the name of the method
Throws:
SecurityException - if there is a security exception while loading the class or getting the method
NoSuchMethodException - if the method does not exist on the class
ClassNotFoundException - if the class could not be found given the supplied class loader
IllegalArgumentException - if the class loader reference is null, or if the class name or method name are null or empty
See Also:
addRuleParser(Method)

removeRuleParser

public boolean removeRuleParser(Method method)
Remove the rule parser method.

Parameters:
method - the method to remove
Returns:
true if the method was removed, or false if the method was not a registered rule parser method

removeRuleParser

public boolean removeRuleParser(String declaringClassName,
                                String methodName)
Remove the rule parser method.

Parameters:
declaringClassName - the name of the class on which the static method is defined; may not be null
methodName - the name of the method
Returns:
true if the method was removed, or false if the method was not a registered rule parser method
Throws:
IllegalArgumentException - if the class loader reference is null, or if the class name or method name are null or empty

ruleFromString

public Projection.Rule ruleFromString(String definition,
                                      ExecutionContext context)
Parse the string form of a rule definition and return the rule

Parameters:
definition - the definition of the rule that is to be parsed
context - the environment in which this method is being executed; may not be null
Returns:
the rule, or null if the definition could not be parsed

rulesFromStrings

public Projection.Rule[] rulesFromStrings(ExecutionContext context,
                                          String... definitions)
Parse string forms of an arry of rule definitions and return the rules

Parameters:
context - the environment in which this method is being executed; may not be null
definitions - the definition of the rules that are to be parsed
Returns:
the rule, or null if the definition could not be parsed

rulesFromString

public Projection.Rule[] rulesFromString(ExecutionContext context,
                                         String definitions)
Parse a single string containing one or more string forms of rule definitions, and return the rules. The string contains each rule on a separate line.

Parameters:
context - the environment in which this method is being executed; may not be null
definitions - the definitions of the rules that are to be parsed, each definition separated by a newline character.
Returns:
the rule, or null if the definition could not be parsed


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.