Class Expression
java.lang.Object
VASSAL.script.expression.Expression
- Direct Known Subclasses:
BeanShellExpression
,FormattedStringExpression
,IntExpression
,NullExpression
,PropertyMatchExpression
,SinglePropertyExpression
,StringExpression
An abstract class representing an expression that can be evaluated.
Subclasses implement specific types of expression and the way they are
evaluated.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Map
<org.apache.commons.lang3.tuple.Pair<Object, Class<? extends Expression>>, Expression> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
Factory method to create an appropriate expression based on the supplied String.static Expression
Factory method to create a new Property Match Expression.static Expression
Factory method to create a Beanshell expression of a value that is known to be a property name.boolean
evaluate()
Deprecated.evaluate
(boolean localized) Deprecated.Deprecated.evaluate
(PropertySource ps, boolean localized) Deprecated.evaluate
(PropertySource ps, boolean localized, Auditable owner, AuditTrail audit) evaluate
(PropertySource ps, Map<String, String> properties, boolean localized) Deprecated.evaluate
(PropertySource ps, Map<String, String> properties, boolean localized, Auditable owner, AuditTrail audit) Each subclass must implement evaluate() to evaluate itself The default implementation just returns the expression itself, which works correctly for simple Expression types like NullExpression and IntExpression.evaluate
(PropertySource ps, Auditable owner, AuditTrail audit) evaluate
(Auditable owner, AuditTrail audit) Deprecated.Deprecated.getFilter
(PropertySource ps, Auditable owner, AuditTrail audit) Return a PieceFilter using the expression.getFilter
(Auditable owner, AuditTrail audit) protected void
int
hashCode()
quietEvaluate
(PropertySource ps, Map<String, String> properties, boolean localized, Auditable owner, AuditTrail audit) A version of tryEvaluate the supresses error messages.quietEvaluate
(PropertySource ps, Auditable owner, String fieldKey) protected void
reset()
static void
void
Output a BeanShell equivalent of this expression.Deprecated.tryEvaluate
(boolean localized) Deprecated.tryEvaluate
(boolean localized, Auditable owner, AuditTrail audit) Evaluate an expression with data warning support built inDeprecated.tryEvaluate
(PropertySource ps, boolean localized) Deprecated.tryEvaluate
(PropertySource ps, boolean localized, Auditable owner, AuditTrail audit) Evaluate an expression with data warning support built intryEvaluate
(PropertySource ps, Map<String, String> properties, boolean localized) Deprecated.tryEvaluate
(PropertySource ps, Map<String, String> properties, boolean localized, Auditable owner, AuditTrail audit) Core tryEvaluate implementation.tryEvaluate
(PropertySource ps, Auditable owner, String fieldKey) tryEvaluate
(PropertySource ps, Auditable owner, AuditTrail audit) Evaluate an expression with data warning support built intryEvaluate
(Auditable owner, AuditTrail audit) Evaluate an expression with data warning support built in
-
Field Details
-
CACHE
protected static final Map<org.apache.commons.lang3.tuple.Pair<Object,Class<? extends Expression>>, CACHEExpression>
-
-
Constructor Details
-
Expression
-
-
Method Details
-
getExpression
-
setExpression
-
reset
protected void reset() -
evaluate
public String evaluate(PropertySource ps, Map<String, String> properties, boolean localized, Auditable owner, AuditTrail audit) throws ExpressionExceptionEach subclass must implement evaluate() to evaluate itself The default implementation just returns the expression itself, which works correctly for simple Expression types like NullExpression and IntExpression.- Parameters:
ps
- Property Source providing property valuesproperties
- default property valueslocalized
- localize property calls?audit
- Audit trail to record expression evaluation info in- Returns:
- evaluated String.
- Throws:
ExpressionException
-
evaluate
public String evaluate(PropertySource ps, boolean localized, Auditable owner, AuditTrail audit) throws ExpressionException - Throws:
ExpressionException
-
evaluate
public String evaluate(PropertySource ps, Auditable owner, AuditTrail audit) throws ExpressionException - Throws:
ExpressionException
-
evaluate
- Throws:
ExpressionException
-
evaluate
@Deprecated(since="2021-06-11") public String evaluate(PropertySource ps, Map<String, String> properties, boolean localized) throws ExpressionExceptionDeprecated.- Throws:
ExpressionException
-
evaluate
@Deprecated(since="2021-06-11") public String evaluate(PropertySource ps, boolean localized) throws ExpressionException Deprecated.- Throws:
ExpressionException
-
evaluate
@Deprecated(since="2021-06-11") public String evaluate(PropertySource ps) throws ExpressionException Deprecated.- Throws:
ExpressionException
-
evaluate
@Deprecated(since="2021-06-11") public String evaluate(boolean localized) throws ExpressionException Deprecated.- Throws:
ExpressionException
-
evaluate
Deprecated.- Throws:
ExpressionException
-
handleError
-
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
ps
- Property Source providing property valuesaudit
- Audit trail to record expression evaluation info in- Returns:
- evaluated String
-
tryEvaluate
-
quietEvaluate
-
tryEvaluate
Deprecated. -
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
audit
- Audit trail to record expression evaluation info in- Returns:
- evaluated String
-
tryEvaluate
Deprecated. -
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
ps
- Property Source providing property valueslocalized
- Localize property calls?audit
- Audit trail to record expression evaluation info in- Returns:
- evaluated String
-
tryEvaluate
Deprecated. -
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
localized
- Localize property calls?audit
- Audit trail to record expression evaluation info in- Returns:
- evaluated String
-
tryEvaluate
Deprecated. -
tryEvaluate
public String tryEvaluate(PropertySource ps, Map<String, String> properties, boolean localized, Auditable owner, AuditTrail audit) Core tryEvaluate implementation. All other call signatures end here. Evaluate an expression with data warning support built in Use supplied owner and AuditTrail for Expression error reporting.- Parameters:
ps
- Property Source providing property valuesproperties
- Default property valueslocalized
- Localize property calls?audit
- Audit trail to record expression evaluation info in- Returns:
- evaluated String
-
quietEvaluate
public String quietEvaluate(PropertySource ps, Map<String, String> properties, boolean localized, Auditable owner, AuditTrail audit) A version of tryEvaluate the supresses error messages. Called by traits in the Game Piece Palette when an expression may fail due to properties not being accessible. -
tryEvaluate
@Deprecated(since="2021-06-11") public String tryEvaluate(PropertySource ps, Map<String, String> properties, boolean localized) Deprecated. -
getFilter
Return a PieceFilter using the expression. The default PieceFilter always returns true. Individual subclasses that are capable of selecting pieces MUST override these defaults. Auditing functionality is supplied since creating a filter usually involves evaluating an Expression.- Parameters:
ps
- PropertySource to use as source of filteraudit
- Audit trail to record expression evaluation info in- Returns:
- Created PieceFilter
-
getFilter
-
getFilter
Deprecated. -
getFilter
Deprecated. -
toBeanShellString
Output a BeanShell equivalent of this expression.- Returns:
- BeanShell equivalent
-
createExpression
Factory method to create an appropriate expression based on the supplied String. The majority of expressions in a module are going to be blank, integers or simple strings, so return optimised Expression subclasses for these types. -
hashCode
-
equals
-
createPropertyExpression
Factory method to create a new Property Match Expression.- Parameters:
s
- Expression string- Returns:
- Generated Expression
-
createSimplePropertyExpression
Factory method to create a Beanshell expression of a value that is known to be a property name. Used to convert values such as the Follow property field in Embellishment -
resetCachedExpressions
public static void resetCachedExpressions()
-
evaluate(Auditable, AuditTrail)