Class BeanShellExpression

java.lang.Object
VASSAL.script.expression.Expression
VASSAL.script.expression.BeanShellExpression

public class BeanShellExpression extends Expression
A basic beanShell expression
  • Field Details

  • Constructor Details

    • BeanShellExpression

      public BeanShellExpression(String s)
  • Method Details

    • reset

      protected void reset()
      Overrides:
      reset in class Expression
    • evaluate

      public String evaluate(PropertySource ps, Map<String,String> properties, boolean localized, Auditable owner, AuditTrail audit) throws ExpressionException
      Evaluate this expression using a BeanShell Interpreter
      Overrides:
      evaluate in class Expression
      Parameters:
      ps - A property source to use to evaluate properties referenced in the expression
      properties - A map of additional properties to use
      localized - Use localized version of property values
      audit - Audit Trail to record significant information for error reporting
      Returns:
      Evaluated expression value
      Throws:
      ExpressionException - If a catastrophic failure occurs in evaluation
    • evaluate

      @Deprecated(since="2021-06-11") public String evaluate(PropertySource ps, Map<String,String> properties, boolean localized) throws ExpressionException
      Overrides:
      evaluate in class Expression
      Throws:
      ExpressionException
    • toBeanShellString

      public String toBeanShellString()
      Description copied from class: Expression
      Output a BeanShell equivalent of this expression.
      Overrides:
      toBeanShellString in class Expression
      Returns:
      BeanShell equivalent
    • strip

      protected static String strip(String expr)
    • isDynamic

      protected boolean isDynamic()
    • getFilter

      @Deprecated(since="2021-06-11") public PieceFilter getFilter(PropertySource ps)
      Return a PieceFilter that selects GamePieces that cause this expression to evaluate to true
      Overrides:
      getFilter in class Expression
    • getFilter

      public PieceFilter getFilter(PropertySource ps, Auditable owner, AuditTrail audit)
      Description copied from class: Expression
      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.
      Overrides:
      getFilter in class Expression
      Parameters:
      ps - PropertySource to use as source of filter
      audit - Audit trail to record expression evaluation info in
      Returns:
      Created PieceFilter
    • convertProperty

      public static String convertProperty(String prop)
      Convert a Property name to its BeanShell equivalent.
      Parameters:
      prop - Property name
      Returns:
      beanshell equivalent
    • isBeanShellExpression

      public static boolean isBeanShellExpression(String expr)
    • isJavaIdentifier

      public static boolean isJavaIdentifier(String s)
    • createExpression

      public static Expression createExpression(String s)
      Create a BeanShellExpression. The expression may or may not be surrounded by {}. Create null, integer and simple Expressions as their basic type to ensure efficient evaluation.
    • createExpression

      public static Expression createExpression(String s, boolean dontCreateStringExpressions)
      Parameters:
      s - String to convert to a Beanshell expressions
      dontCreateStringExpressions - If True, then convert quoted string to Beanshell Expressions, not String Expressions
      Returns:
      Expression
    • instance

      public static Expression instance(String s)