Package cl.obcom.desktopfx.expr
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
capacity
expr. - evaluate(expr): evaluates the string
expression
expr. - hasCapacity(expr): true if the user has
capacity
expr. - hasPrivilege(expr): true if the user has
privilege
expr. - matches(expr, regex): true if expr matches the
pattern
regex. - systemProp(expr): the value of the
system property
expr.
The following built-in properties are available:
- anonUser: true if login type is
ANONYMOUS
. - envName: the
name
of the server environment. - kioskUser: true if login type is
KIOSK
. - menuName: the
name
of the menu of the user. - normalUser: true if login type is
NORMAL
. - officeType: the
type
of the office the user. - stationName: the
name
of the workstation. - userName: the
name
of the user. - userType: the
type
of the profile of the user.
The following built-in constants are available:
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddFunction
(Function function) Adds a function to the list of functions of the compiler.static int
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.Compiles the supplied expression string.Returns an object with the default user-supplied logic.int
Returns the scale of quotients.removeFunction
(Function function) Removes a function from the list of functions of the compiler.void
setQuotientScale
(int scale) Changes the scale of quotients.static Boolean
Converts an object value to a Boolean value.static BigDecimal
Converts an object value to a BigDecimal number.static String
Converts an object value to a String value.
-
Constructor Details
-
Compiler
Constructs a newCompiler
instance.- 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
- iffunction
isnull
.
-
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
- iffunction
isnull
.
-
compile
Compiles the supplied expression string.- Parameters:
expr
- the string expression to compiled.- Returns:
- the resulting compiled Expression.
- Throws:
NullPointerException
- ifexpr
isnull
.ExpressionException
- if the expression is invalid.
-
toString
Converts an object value to a String value.- Parameters:
value
- the value to convert to a String (can be null).- Returns:
- a String or
null
ifvalue
isnull
.
-
toBoolean
Converts an object value to a Boolean value.- Parameters:
value
- the value to convert to a Boolean (can be null).- Returns:
- a Boolean or
null
ifvalue
isnull
.
-
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
null
ifvalue
isnull
. - Throws:
NumberFormatException
- ifvalue
is 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
lvalue
is less than, equal to, or greater thanrvalue
. - Throws:
NullPointerException
- if an argument isnull
.
-