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
"}".
| Modifier and Type | Field | Description |
|---|---|---|
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.
|
static java.lang.String |
NEGATIVE_LOOKBEHIND_BACKSLASH |
This pattern makes sure that there is no backslash in front of an
expression that is due to be replaced with the result of its evaluation.
|
| Constructor | Description |
|---|---|
Expression(java.lang.String expression) |
Create an
Expression. |
| Modifier and Type | Method | Description |
|---|---|---|
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(ExpressionFactory factory,
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(java.lang.String value,
ExpressionFactory factory,
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(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
ExpressionFactory factory,
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,
WorkbookContext context) |
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,
WorkbookContext context) |
Determines whether this represents implicit Collections access, which
would result in an implicit collections processing loop.
|
public static final java.lang.String NEGATIVE_LOOKBEHIND_BACKSLASH
public static final java.lang.String BEGIN_EXPR
public static final java.lang.String END_EXPR
public Expression(java.lang.String expression)
Expression.expression - The expression in String form.public java.lang.Object evaluate(ExpressionFactory factory, java.util.Map<java.lang.String,java.lang.Object> beans)
Expression using the given Map of
beans as a context.factory - An ExpressionFactory.beans - A Map mapping strings to objects.public java.lang.String getValueIndicatingImplicitCollection(java.util.Map<java.lang.String,java.lang.Object> beans,
WorkbookContext context)
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.
beans - A Map mapping strings to objects.context - A WorkbookContext. Don't return a collection
expression whose collection property name is found in the List
of such names maintained by this WorkbookContext..Collection, or
null if it doesn't represent implicit Collections access.public static void clearExpressionToCollNamesMap()
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.public static java.util.List<java.lang.String> getImplicitCollectionExpr(java.lang.String value,
java.util.Map<java.lang.String,java.lang.Object> beans,
WorkbookContext context)
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.value - The string possibly representing an Expression.beans - A Map mapping strings to objects.context - A WorkbookContext, which supplies a
List of collection names to ignore and the
ExpressionFactory. Don't return a collection expression
whose collection property name is found in this List.List of strings representing the
Collections found, possibly empty if it doesn't represent
implicit Collections access.public static java.lang.Object evaluateString(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
ExpressionFactory factory,
java.util.Map<java.lang.String,java.lang.Object> beans)
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.richTextString - The rich text string, with possibly embedded
expressions.helper - A CreationHelper that can create the proper
RichTextString.factory - An ExpressionFactory.beans - A Map mapping strings to objects.public static java.lang.Object evaluateString(java.lang.String value,
ExpressionFactory factory,
java.util.Map<java.lang.String,java.lang.Object> beans)
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.value - The string, with possibly embedded expressions.factory - An ExpressionFactory.beans - A Map mapping strings to objects.Copyright © 2012–2018 Jett Team. All rights reserved.