Class Compiler
java.lang.Object
cl.obcom.desktopfx.expr.Compiler
Expression compiler. The compiler recognizes the following grammar:
| expression | → | conditional-or | |
| | | conditional-or ? expression : expression | if-then-else (lazy) | |
| conditional-or | → | conditional-and | |
| | | conditional-or || conditional-and | conditional or (lazy) | |
| conditional-and | → | equality | |
| | | conditional-and && equality | conditional and (lazy) | |
| equality | → | relational | |
| | | relational == relational | equal to | |
| | | relational != relational | not equal to | |
| relational | → | additive | |
| | | additive < additive | less than | |
| | | additive <= additive | less than or equal to | |
| | | additive > additive | greater than | |
| | | additive >= additive | greater than or equal to | |
| additive | → | multiplicative | |
| | | additive + multiplicative | concatenation or addition | |
| | | additive - multiplicative | substraction | |
| multiplicative | → | unary | |
| | | multiplicative * unary | multiplication | |
| | | multiplicative / unary | division | |
| | | multiplicative % unary | remainder | |
| unary | → | primary | |
| | | ! unary | logical not | |
| | | - unary | negative | |
| | | + unary | positive | |
| primary | → | ( expression ) | |
| | | function | ||
| | | string | ||
| | | number | ||
| function | → | identifier ( arguments ) | |
| | | identifier ( ) | ||
| | | identifier | ||
| arguments | → | expression [ , expression ]* |
|
| identifier | → | name [ . name ]* |
package notation |
| name | → | [A-Za-z$_][A-Za-z0-9$_]* |
case sensitive |
| string | → | " [ any-character-with \" for " ]* " |
double quotes |
| | | ' [ any-character-with \' for ' ]* ' |
single quote | |
| number | → | digits [ . digits ]? |
BigDecimal |
The following built-in functions are available:
- capacity(expr): the value of the user
capacityexpr. - evaluate(expr): evaluates the string
expressionexpr. - hasCapacity(expr): true if the user has
capacityexpr. - hasPrivilege(expr): true if the user has
privilegeexpr. - matches(expr, regex): true if expr matches the
patternregex. - systemProp(expr): the value of the
system propertyexpr.
The following built-in properties are available:
- anonUser: true if login type is
ANONYMOUS. - envName: the
nameof the server environment. - kioskUser: true if login type is
KIOSK. - menuName: the
nameof the menu of the user. - normalUser: true if login type is
NORMAL. - officeType: the
typeof the office the user. - stationName: the
nameof the workstation. - userName: the
nameof the user. - userType: the
typeof the profile of the user.
The following built-in constants are available:
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFunction(Function function) Adds a function to the list of functions of the compiler.static intCompares two object values and returns -1, 0, or 1 if the left value is less than, equal to, or greater than the right value.Compiles the supplied expression string.Returns an object with the default user-supplied logic.intReturns the scale of quotients.removeFunction(Function function) Removes a function from the list of functions of the compiler.voidsetQuotientScale(int scale) Changes the scale of quotients.static BooleanConverts an object value to a Boolean value.static BigDecimalConverts an object value to a BigDecimal number.static StringConverts an object value to a String value.
-
Constructor Details
-
Compiler
Constructs a newCompilerinstance.- Parameters:
desktop- the Desktop Application.defaultLogic- an object with default user logic.- Throws:
NullPointerException- if an argument isnull.
-
-
Method Details
-
getDefaultLogic
Returns an object with the default user-supplied logic.- Returns:
- an object with the default user-supplied logic.
-
getQuotientScale
public int getQuotientScale()Returns the scale of quotients. By default the scale is 20.- Returns:
- the scale of quotients.
-
setQuotientScale
public void setQuotientScale(int scale) Changes the scale of quotients. By default the scale is 20.- Parameters:
scale- the new scale of quotients.
-
addFunction
Adds a function to the list of functions of the compiler.- Parameters:
function- the function to added to the list.- Returns:
- the function previously indexed by the same name.
- Throws:
NullPointerException- iffunctionisnull.
-
removeFunction
Removes a function from the list of functions of the compiler.- Parameters:
function- the function to be remove from the list.- Returns:
- the function associatted with the function name.
- Throws:
NullPointerException- iffunctionisnull.
-
compile
Compiles the supplied expression string.- Parameters:
expr- the string expression to compiled.- Returns:
- the resulting compiled Expression.
- Throws:
NullPointerException- ifexprisnull.ExpressionException- if the expression is invalid.
-
toString
-
toBoolean
-
toNumber
Converts an object value to a BigDecimal number.- Parameters:
value- the value to convert to a BigDecimal (can be null).- Returns:
- a BigDecimal or
nullifvalueisnull. - Throws:
NumberFormatException- ifvalueis invalid.
-
compare
Compares two object values and returns -1, 0, or 1 if the left value is less than, equal to, or greater than the right value.- Parameters:
lvalue- the left value of the comparison.rvalue- the right value of the comparison.- Returns:
- -1, 0, or 1 if
lvalueis less than, equal to, or greater thanrvalue. - Throws:
NullPointerException- if an argument isnull.
-