Package com.groiss.ds
Class StringExpression
java.lang.Object
com.groiss.ds.StringExpression
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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 valuesCall this method to evaluate the expression.abstract Object
Abstract method for var substitution, should be implemented by subclasses.
-
Constructor Details
-
StringExpression
public StringExpression()
-
-
Method Details
-
appendIfNotEmpty
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
Call this method to evaluate the expression.- Parameters:
s
- the expression- Returns:
- the evaluated expression.
-
varSubstitute
Abstract method for var substitution, should be implemented by subclasses.- Parameters:
s
- the variable name- Returns:
- the value
-