org.springmodules.validation.valang.parser
Class DefaultVisitor

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

public class DefaultVisitor
extends Object
implements ValangVisitor, BeanFactoryAware, ApplicationContextAware, ResourceLoaderAware, MessageSourceAware, ApplicationEventPublisherAware

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

Default functions are:

Since:
Apr 23, 2005
Author:
Steven Devijver

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 propertyName)
          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 setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
          Implementation of ApplicationEventPublisherAware.
 void setBeanFactory(BeanFactory beanFactory)
          Implementation of BeanFactoryAware.
 void setMessageSource(MessageSource messageSource)
          Implementation of MessageSourceAware.
 void setResourceLoader(ResourceLoader resourceLoader)
          Implementation of ResourceLoaderAware.
 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
 

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 propertyName)
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.


setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException
Implementation of BeanFactoryAware.

Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException

setApplicationContext

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

Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Implementation of ResourceLoaderAware.

Specified by:
setResourceLoader in interface ResourceLoaderAware

setMessageSource

public void setMessageSource(MessageSource messageSource)
Implementation of MessageSourceAware.

Specified by:
setMessageSource in interface MessageSourceAware

setApplicationEventPublisher

public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
Implementation of ApplicationEventPublisherAware.

Specified by:
setApplicationEventPublisher in interface ApplicationEventPublisherAware


Copyright © 2009. All Rights Reserved.