org.springmodules.validation.valang.parser
Class DefaultVisitor

java.lang.Object
  extended by org.springmodules.validation.valang.parser.DefaultVisitor
All Implemented Interfaces:
ApplicationContextAware, ValangVisitor

public class DefaultVisitor
extends Object
implements ApplicationContextAware, ValangVisitor

Allows registration of custom functions. Custom functions can overwrite default functions.

Default functions are:

Since:
Apr 23, 2005
Author:
Steven Devijver

Field Summary
static char INDEXED_DELIM_BEGIN
          The delimiter that preceeds the zero-relative subscript for an indexed reference.
static char INDEXED_DELIM_END
           
 
Constructor Summary
DefaultVisitor()
          Constructor
 
Method Summary
 DefaultDateParser getDateParser()
          Gets date parser.
 Function getFunction(String name, Function[] arguments, int line, int column)
          Get a function based on the function name and arguments.
 Function getFunction(String className, String propName)
          Get bytecode generation function.
 org.apache.commons.collections.Predicate getPredicate(Function leftFunction, Operator operator, Function rightFunction, int line, int column)
          Gets predicate.
 ValangVisitor getVisitor()
          Gets visitor.
 void setApplicationContext(ApplicationContext applicationContext)
          Implementation of ApplicationContextAware.
 void setVisitor(ValangVisitor visitor)
          Register a custom visitor to look up custom functions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEXED_DELIM_BEGIN

public static final char INDEXED_DELIM_BEGIN
The delimiter that preceeds the zero-relative subscript for an indexed reference.

See Also:
Constant Field Values

INDEXED_DELIM_END

public static final char INDEXED_DELIM_END
See Also:
Constant Field Values
Constructor Detail

DefaultVisitor

public DefaultVisitor()
Constructor

Method Detail

getFunction

public Function getFunction(String name,
                            Function[] arguments,
                            int line,
                            int column)
Get a function based on the function name and arguments.

Specified by:
getFunction in interface ValangVisitor

getFunction

public Function getFunction(String className,
                            String propName)
Get bytecode generation function.

Parameters:
className - Name of the Class to generated a Function to retrieve a property.
propertyName - The name of the property to retrieve a value from in the function. For example, expects 'message' and will call getMessage().
Returns:
Function Bytecode generated Function based on the class and property name.

getVisitor

public ValangVisitor getVisitor()
Gets visitor.


setVisitor

public void setVisitor(ValangVisitor visitor)

Register a custom visitor to look up custom functions. Lookup of functions will first be delegated to this visitor. If no function has been returned (null) lookup will be handled by DefaultVisitor.

Parameters:
visitor - The custom visitor.

getPredicate

public org.apache.commons.collections.Predicate getPredicate(Function leftFunction,
                                                             Operator operator,
                                                             Function rightFunction,
                                                             int line,
                                                             int column)
Gets predicate.

Parameters:
leftFunction - Left comparison Function.
operator - Operation for comparison.
rightFunction - Right comparison Function.
line - Line number of parsed expression.
column - Column number of parsed expression.
Returns:
Predicate Comparison predicate based on input.

getDateParser

public DefaultDateParser getDateParser()
Gets date parser.


setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Implementation of ApplicationContextAware.

Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException


Copyright © 2009. All Rights Reserved.