Package com.groiss.ds

Class StringExpression

java.lang.Object
com.groiss.ds.StringExpression

public abstract class StringExpression extends Object
An expression is parsed, the containing variables are substituted with values. The caller calls the parse method with a string, the variables are handed over to an abstract varSubstitute method. The expression has the following form: { any-char* "{" placeholder ["," ("date" | "datetime" | decimal-format-mask ) ] "}" any_char* }*
  • Constructor Details

    • StringExpression

      public StringExpression()
  • Method Details

    • appendIfNotEmpty

      protected final void appendIfNotEmpty(StringBuilder result, Object val)
      appends the given value. if the value is null/empty and the current result ends with a blank, this blank is removed to avoid accumulating blanks for optional values
      Parameters:
      result -
      val -
    • parse

      public String parse(String s)
      Call this method to evaluate the expression.
      Parameters:
      s - the expression
      Returns:
      the evaluated expression.
    • varSubstitute

      public abstract Object varSubstitute(String s)
      Abstract method for var substitution, should be implemented by subclasses.
      Parameters:
      s - the variable name
      Returns:
      the value