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 Details

    • Expression

      public Expression()
  • Method Details

    • setExpression

      public void setExpression​(String s)
    • getExpression

      public String getExpression()
    • evaluate

      public abstract 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
    • 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 abstract 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.
    • 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 proprty field in Embellishment
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object