net.sf.jett.expression
Class Expression

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

public class Expression
extends java.lang.Object

An Expression object represents a JEXL Expression that can be evaluated given a Map of bean names to values. Many Expressions may be created in a cell. Here in JETT, Expressions are built from the text found in between "${" and "}".

Author:
Randy Gettman

Field Summary
static java.lang.String BEGIN_EXPR
          Determines the start of a JEXL expression.
static java.lang.String END_EXPR
          Determines the end of a JEXL expression.
 
Constructor Summary
Expression(java.lang.String expression)
          Create an Expression.
 
Method Summary
static void clearExpressionToCollNamesMap()
          Clear the Map that is used to cache the fact that a certain collection name may be present in expression text.
 java.lang.Object evaluate(java.util.Map<java.lang.String,java.lang.Object> beans)
          Evaluate this Expression using the given Map of beans as a context.
static java.lang.Object evaluateString(org.apache.poi.ss.usermodel.RichTextString richTextString, org.apache.poi.ss.usermodel.CreationHelper helper, java.util.Map<java.lang.String,java.lang.Object> beans)
          Find any Expressions embedded in the given string, evaluate them, and replace the expressions with the resulting values.
static java.lang.Object evaluateString(java.lang.String value, java.util.Map<java.lang.String,java.lang.Object> beans)
          Find any Expressions embedded in the given string, evaluate them, and replace the expressions with the resulting values.
static java.util.List<java.lang.String> getImplicitCollectionExpr(java.lang.String value, java.util.Map<java.lang.String,java.lang.Object> beans, java.util.List<java.lang.String> noImplProcCollNames)
          Determines whether a string representing an Expression represents implicit Collections access, which would result in an implicit collections processing loop.
 java.lang.String getValueIndicatingImplicitCollection(java.util.Map<java.lang.String,java.lang.Object> beans, java.util.List<java.lang.String> noImplProcCollNames)
          Determines whether this represents implicit Collections access, which would result in an implicit collections processing loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEGIN_EXPR

public static final java.lang.String BEGIN_EXPR
Determines the start of a JEXL expression.

See Also:
Constant Field Values

END_EXPR

public static final java.lang.String END_EXPR
Determines the end of a JEXL expression.

See Also:
Constant Field Values
Constructor Detail

Expression

public Expression(java.lang.String expression)
Create an Expression.

Parameters:
expression - The expression in String form.
Method Detail

evaluate

public java.lang.Object evaluate(java.util.Map<java.lang.String,java.lang.Object> beans)
Evaluate this Expression using the given Map of beans as a context.

Parameters:
beans - A Map mapping strings to objects.
Returns:
The result of the evaluation.

getValueIndicatingImplicitCollection

public java.lang.String getValueIndicatingImplicitCollection(java.util.Map<java.lang.String,java.lang.Object> beans,
                                                             java.util.List<java.lang.String> noImplProcCollNames)

Determines whether this represents implicit Collections access, which would result in an implicit collections processing loop. If so, then it returns the substring representing the Collection, else it returns null.

This method uses JEXL internal parser logic.

Parameters:
beans - A Map mapping strings to objects.
noImplProcCollNames - Don't return a collection expression whose collection property name is found in this List.
Returns:
The string representing the Collection, or null if it doesn't represent implicit Collections access.

clearExpressionToCollNamesMap

public static void clearExpressionToCollNamesMap()
Clear the Map that is used to cache the fact that a certain collection name may be present in expression text. Call this method when a new beans Map is being used, which would render the cache useless. Such a situation arises when supplying multiple bean maps to the transform method on ExcelTransformer, and we are moving to a new Sheet, or if either transform method on ExcelTransformer is called more than once.


getImplicitCollectionExpr

public static java.util.List<java.lang.String> getImplicitCollectionExpr(java.lang.String value,
                                                                         java.util.Map<java.lang.String,java.lang.Object> beans,
                                                                         java.util.List<java.lang.String> noImplProcCollNames)
Determines whether a string representing an Expression represents implicit Collections access, which would result in an implicit collections processing loop. If so, then it returns the substring representing the Collection, else it returns null.

Parameters:
value - The string possibly representing an Expression.
beans - A Map mapping strings to objects.
noImplProcCollNames - Don't return a collection expression whose collection property name is found in this List.
Returns:
A List of strings representing the Collections found, possibly empty if it doesn't represent implicit Collections access.

evaluateString

public static java.lang.Object evaluateString(org.apache.poi.ss.usermodel.RichTextString richTextString,
                                              org.apache.poi.ss.usermodel.CreationHelper helper,
                                              java.util.Map<java.lang.String,java.lang.Object> beans)
Find any Expressions embedded in the given string, evaluate them, and replace the expressions with the resulting values. If the entire string consists of one Expression, then the returned value may be any Object.

Parameters:
richTextString - The rich text string, with possibly embedded expressions.
helper - A CreationHelper that can create the proper RichTextString.
beans - A Map mapping strings to objects.
Returns:
A new string, with any embedded expressions replaced with the expression string values.

evaluateString

public static java.lang.Object evaluateString(java.lang.String value,
                                              java.util.Map<java.lang.String,java.lang.Object> beans)
Find any Expressions embedded in the given string, evaluate them, and replace the expressions with the resulting values. If the entire string consists of one Expression, then the returned value may be any Object.

Parameters:
value - The string, with possibly embedded expressions.
beans - A Map mapping strings to objects.
Returns:
A new string, with any embedded expressions replaced with the expression string values.


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