org.springmodules.validation.valang.parser
Class SimpleValangBased

java.lang.Object
  extended by org.springmodules.validation.valang.parser.SimpleValangBased
All Implemented Interfaces:
ApplicationContextAware, ValangBased
Direct Known Subclasses:
ValangConditionExpressionParser, ValangFunctionExpressionParser, ValangValidator

public class SimpleValangBased
extends Object
implements ApplicationContextAware, ValangBased

A simple implementation of ValangBased.

Author:
Uri Boness

Constructor Summary
SimpleValangBased()
           
 
Method Summary
 void addCustomFunction(String functionName, String functionClassName)
          Adds the a new custom function to be used in the valang el.
 ValangParser createValangParser(String expression)
          Creates a new ValangParser that is already configured with the proper custom functions and date parsers.
 ValangParser createValangParser(String expression, String className)
          Creates a new ValangParser that is already configured with the proper custom functions and date parsers and uses the class name to perform bytecode generation to avoid reflection.
protected  Map<String,Object> findAllCustomFunctionsInApplicationContext()
          Finds all FunctionDefinition and FunctionWrapper beans in the Spring context.
 Map<String,Object> getAllCustomFunctions()
          Returns all the custom functions that can be found.
 Map<String,Object> getCustomFunctions()
           
 Map getDateParsers()
           
 void initValang(Object object)
           
 void setApplicationContext(ApplicationContext applicationContext)
          Implementation of ApplicationContextAware.
 void setCustomFunctions(Map<String,Object> hCustomFunctions)
          Sets custom functions that should be registered with the used ValangParser.
 void setDateParsers(Map parserByRegexp)
          Sets the date parser that should be registered with the used ValangParser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleValangBased

public SimpleValangBased()
Method Detail

setApplicationContext

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

Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

setCustomFunctions

public void setCustomFunctions(Map<String,Object> hCustomFunctions)
Description copied from interface: ValangBased
Sets custom functions that should be registered with the used ValangParser.

Specified by:
setCustomFunctions in interface ValangBased
Parameters:
hCustomFunctions - the custom functions where the key is the function name and the value is the function class FQN.
See Also:
ValangBased.setCustomFunctions(java.util.Map)

addCustomFunction

public void addCustomFunction(String functionName,
                              String functionClassName)
Description copied from interface: ValangBased
Adds the a new custom function to be used in the valang el.

Specified by:
addCustomFunction in interface ValangBased
Parameters:
functionName - The name of the function.
functionClassName - The fully qualified class name of the function.
See Also:
ValangBased.addCustomFunction(String, String)

setDateParsers

public void setDateParsers(Map parserByRegexp)
Description copied from interface: ValangBased
Sets the date parser that should be registered with the used ValangParser.

Specified by:
setDateParsers in interface ValangBased
Parameters:
parserByRegexp - the date parsers where the key is the regexp associated with the parser and the value is the parser class FQN.
See Also:
ValangBased.setDateParsers(java.util.Map)

getCustomFunctions

public Map<String,Object> getCustomFunctions()

getDateParsers

public Map getDateParsers()

createValangParser

public ValangParser createValangParser(String expression)
Creates a new ValangParser that is already configured with the proper custom functions and date parsers.

Parameters:
expression - Valang language validation expression.
Returns:
A new ValangParser.

createValangParser

public ValangParser createValangParser(String expression,
                                       String className)
Creates a new ValangParser that is already configured with the proper custom functions and date parsers and uses the class name to perform bytecode generation to avoid reflection.

Parameters:
expression - Valang language validation expression.
className - Name of the Class to generated a Function to retrieve a property.
Returns:
A new ValangParser.

initValang

public void initValang(Object object)

getAllCustomFunctions

public Map<String,Object> getAllCustomFunctions()
Returns all the custom functions that can be found. This method returns all the custom functions that were explicitly registered with this instance and all custom functions that can be found in the application context (if one is set) by looking for FunctionDefinition beans.

Returns:
All the custom function that can be found.

findAllCustomFunctionsInApplicationContext

protected Map<String,Object> findAllCustomFunctionsInApplicationContext()
Finds all FunctionDefinition and FunctionWrapper beans in the Spring context.



Copyright © 2009. All Rights Reserved.