Package VASSAL.script.expression
Class Expression
java.lang.Object
VASSAL.script.expression.Expression
- Direct Known Subclasses:
BeanShellExpression
,FormattedStringExpression
,IntExpression
,NullExpression
,PropertyMatchExpression
,SinglePropertyExpression
,StringExpression
public abstract class Expression extends Object
An abstract class representing an expression that can be evaluated.
Subclasses implement specific types of expression and the way they are
evaluated.
-
Constructor Summary
Constructors Constructor Description Expression()
-
Method Summary
Modifier and Type Method Description static Expression
createExpression(String s)
Factory method to create an appropriate expression based on the supplied String.static Expression
createPropertyExpression(String s)
Factory method to create a new Property Match Expression.static Expression
createSimplePropertyExpression(String s)
Factory method to create a Beanshell expression of a value that is known to be a property name.boolean
equals(Object obj)
String
evaluate()
String
evaluate(boolean localized)
String
evaluate(PropertySource ps)
String
evaluate(PropertySource ps, boolean localized)
abstract String
evaluate(PropertySource ps, Map<String,String> properties, boolean localized)
Each subclass must implement evaluate() to evaluate itselfString
getExpression()
PieceFilter
getFilter()
PieceFilter
getFilter(PropertySource ps)
Return a PieceFilter using the expression.int
hashCode()
void
setExpression(String s)
abstract String
toBeanShellString()
Output a BeanShell equivalent of this expression.
-
Constructor Details
-
Expression
public Expression()
-
-
Method Details
-
setExpression
-
getExpression
-
evaluate
public abstract 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
-
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. -
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 proprty field in Embellishment -
hashCode
public int hashCode() -
equals
-