Package VASSAL.script.expression
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 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()
evaluate(boolean localized)
evaluate(PropertySource ps)
evaluate(PropertySource ps, boolean localized)
evaluate(PropertySource ps, Map<String,String> properties, boolean localized)
Each subclass must implement evaluate() to evaluate itselfgetFilter(PropertySource ps)
Return a PieceFilter using the expression.protected void
int
hashCode()
protected void
reset()
static void
void
setExpression(String s)
Output a BeanShell equivalent of this expression.Evaluate an expression with data warning support built intryEvaluate(boolean localized)
Evaluate an expression with data warning support built inEvaluate an expression with data warning support built intryEvaluate(PropertySource ps, boolean localized)
Evaluate an expression with data warning support built intryEvaluate(PropertySource ps, Map<String,String> properties, boolean localized)
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>>,Expression> CACHE
-
-
Constructor Details
-
Expression
-
-
Method Details
-
getExpression
-
setExpression
-
reset
protected void reset() -
evaluate
public String evaluate(PropertySource ps, Map<String,String> properties, boolean localized) throws ExpressionExceptionEach subclass must implement evaluate() to evaluate itself- Parameters:
ps
- Property Source providing property valuesproperties
- default property valueslocalized
- localize property calls?- Returns:
- evaluated String.
- Throws:
ExpressionException
-
evaluate
- Throws:
ExpressionException
-
evaluate
- Throws:
ExpressionException
-
evaluate
- Throws:
ExpressionException
-
evaluate
- Throws:
ExpressionException
-
handleError
-
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
ps
- Property Source providing property values- Returns:
- evaluated String
-
tryEvaluate
Evaluate an expression with data warning support built in- Returns:
- evaluated String
-
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
ps
- Property Source providing property valueslocalized
- Localize property calls?- Returns:
- evaluated String
-
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
localized
- Localize property calls?- Returns:
- evaluated String
-
tryEvaluate
Evaluate an expression with data warning support built in- Parameters:
ps
- Property Source providing property valuesproperties
- Default property valueslocalized
- Localize property calls?- Returns:
- evaluated String
-
getFilter
Return a PieceFilter using the expression.- Parameters:
ps
- PropertySource to use as source of filter- Returns:
- Created PieceFilter
-
getFilter
-
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
public int 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()
-