Class Expression

java.lang.Object
VASSAL.script.expression.Expression
Direct Known Subclasses:
BeanShellExpression, FormattedStringExpression, IntExpression, NullExpression, PropertyMatchExpression, SinglePropertyExpression, StringExpression

public 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.
  • Field Details

  • Constructor Details

    • Expression

      protected Expression(String s)
  • Method Details

    • getExpression

      public String getExpression()
    • setExpression

      public void setExpression(String s)
    • reset

      protected void reset()
    • evaluate

      public String evaluate(PropertySource ps, Map<String,​String> properties, boolean localized) throws ExpressionException
      Each subclass must implement evaluate() to evaluate itself
      Parameters:
      ps - Property Source providing property values
      properties - default property values
      localized - localize property calls?
      Returns:
      evaluated String.
      Throws:
      ExpressionException
    • evaluate

      public String evaluate() throws ExpressionException
      Throws:
      ExpressionException
    • evaluate

      public String evaluate(PropertySource ps) throws ExpressionException
      Throws:
      ExpressionException
    • evaluate

      public String evaluate(PropertySource ps, boolean localized) throws ExpressionException
      Throws:
      ExpressionException
    • evaluate

      public String evaluate(boolean localized) throws ExpressionException
      Throws:
      ExpressionException
    • handleError

      protected void handleError(ExpressionException e)
    • tryEvaluate

      public String tryEvaluate(PropertySource ps)
      Evaluate an expression with data warning support built in
      Parameters:
      ps - Property Source providing property values
      Returns:
      evaluated String
    • tryEvaluate

      public String tryEvaluate()
      Evaluate an expression with data warning support built in
      Returns:
      evaluated String
    • tryEvaluate

      public String tryEvaluate(PropertySource ps, boolean localized)
      Evaluate an expression with data warning support built in
      Parameters:
      ps - Property Source providing property values
      localized - Localize property calls?
      Returns:
      evaluated String
    • tryEvaluate

      public String tryEvaluate(boolean localized)
      Evaluate an expression with data warning support built in
      Parameters:
      localized - Localize property calls?
      Returns:
      evaluated String
    • tryEvaluate

      public String tryEvaluate(PropertySource ps, Map<String,​String> properties, boolean localized)
      Evaluate an expression with data warning support built in
      Parameters:
      ps - Property Source providing property values
      properties - Default property values
      localized - Localize property calls?
      Returns:
      evaluated String
    • getFilter

      public PieceFilter getFilter(PropertySource ps)
      Return a PieceFilter using the expression.
      Parameters:
      ps - PropertySource to use as source of filter
      Returns:
      Created PieceFilter
    • getFilter

      public PieceFilter getFilter()
    • toBeanShellString

      public String toBeanShellString()
      Output a BeanShell equivalent of this expression.
      Returns:
      BeanShell equivalent
    • createExpression

      public static Expression createExpression(String s)
      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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • createPropertyExpression

      public static Expression createPropertyExpression(String s)
      Factory method to create a new Property Match Expression.
      Parameters:
      s - Expression string
      Returns:
      Generated Expression
    • createSimplePropertyExpression

      public static Expression createSimplePropertyExpression(String s)
      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()