net.sf.jett.expression
Class ExpressionFactory

java.lang.Object
  extended by net.sf.jett.expression.ExpressionFactory

public class ExpressionFactory
extends java.lang.Object

An ExpressionFactory is a singleton factory class that creates and uses a JexlEngine to create JEXL Expressions.

It passes through several items to the JEXL Engine, including "silent" and "lenient" flags, the JEXL parse cache size, and JEXL namespace function objects (including jAgg functionality).

Author:
Randy Gettman

Method Summary
 org.apache.commons.jexl2.Expression createExpression(java.lang.String expression)
          Create a JEXL Expression from a string.
static ExpressionFactory getExpressionFactory()
          Returns the singleton ExpressionFactory.
 boolean isLenient()
          Returns the internal JexlEngine's "lenient" flag.
 boolean isSilent()
          Returns the internal JexlEngine's "silent" flag.
 void registerFuncs(java.lang.String namespace, java.lang.Object funcsObject)
          Registers an object under the given namespace in the JEXL Engine.
 void setCache(int size)
          Sets the size of the Expression cache to be used inside the JEXL Engine.
 void setLenient(boolean lenient)
          Passes the given "lenient" flag on to the internal JexlEngine.
 void setSilent(boolean silent)
          Passes the given "silent" flag on to the internal JexlEngine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setLenient

public void setLenient(boolean lenient)
Passes the given "lenient" flag on to the internal JexlEngine.

Parameters:
lenient - Whether the internal JexlEngine should be "lenient".

isLenient

public boolean isLenient()
Returns the internal JexlEngine's "lenient" flag.

Returns:
Whether the internal JexlEngine is currently "lenient".

setSilent

public void setSilent(boolean silent)
Passes the given "silent" flag on to the internal JexlEngine.

Parameters:
silent - Whether the internal JexlEngine should be "silent".

isSilent

public boolean isSilent()
Returns the internal JexlEngine's "silent" flag.

Returns:
Whether the internal JexlEngine is currently "silent".

setCache

public void setCache(int size)
Sets the size of the Expression cache to be used inside the JEXL Engine.

Parameters:
size - The size of the cache.
Since:
0.2.0

registerFuncs

public void registerFuncs(java.lang.String namespace,
                          java.lang.Object funcsObject)
Registers an object under the given namespace in the JEXL Engine. Each public method in the object's class is exposed as a "function" available in the JEXL Engine. To use instance methods, pass an instance of the object. To use class methods, pass a Class object.

Parameters:
namespace - The namespace.
funcsObject - An object (or a Class) containing the methods to expose as JEXL Engine functions.
Throws:
java.lang.IllegalArgumentException - If the namespace has already been registered.
Since:
0.2.0

getExpressionFactory

public static ExpressionFactory getExpressionFactory()
Returns the singleton ExpressionFactory.

Returns:
The singleton ExpressionFactory.

createExpression

public org.apache.commons.jexl2.Expression createExpression(java.lang.String expression)
Create a JEXL Expression from a string.

Parameters:
expression - The expression as a String.
Returns:
A JEXL Expression.


Copyright © 2012-2013 Jett Team. All Rights Reserved.