public final class Compiler extends Object
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.expression
expr.capacity
expr.privilege
expr.pattern
regex.system property
expr.The following built-in properties are available:
ANONYMOUS
.name
of the server environment.KIOSK
.name
of the menu of the user.NORMAL
.type
of the office the user.name
of the workstation.name
of the user.type
of the profile of the user.The following built-in constants are available:
Expression
,
Function
Constructor and Description |
---|
Compiler(Desktop desktop,
Object defaultLogic)
Constructs a new
Compiler instance. |
Modifier and Type | Method and Description |
---|---|
Function |
addFunction(Function function)
Adds a function to the list of functions of the compiler.
|
static int |
compare(Object lvalue,
Object rvalue)
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.
|
Expression |
compile(String expr)
Compiles the supplied expression string.
|
Object |
getDefaultLogic()
Returns an object with the default user-supplied logic.
|
int |
getQuotientScale()
Returns the scale of quotients.
|
Function |
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 |
toBoolean(Object value)
Converts an object value to a Boolean value.
|
static BigDecimal |
toNumber(Object value)
Converts an object value to a BigDecimal number.
|
static String |
toString(Object value)
Converts an object value to a String value.
|
public Compiler(Desktop desktop, Object defaultLogic)
Compiler
instance.desktop
- the Desktop Application.defaultLogic
- an object with default user logic.NullPointerException
- if an argument is null
.public Object getDefaultLogic()
public int getQuotientScale()
public void setQuotientScale(int scale)
scale
- the new scale of quotients.public Function addFunction(Function function)
function
- the function to added to the list.NullPointerException
- if function
is null
.public Function removeFunction(Function function)
function
- the function to be remove from the list.NullPointerException
- if function
is null
.public Expression compile(String expr)
expr
- the string expression to compiled.NullPointerException
- if expr
is null
.ExpressionException
- if the expression is invalid.public static String toString(Object value)
value
- the value to convert to a String (can be null).null
if value
is null
.public static Boolean toBoolean(Object value)
value
- the value to convert to a Boolean (can be null).null
if value
is null
.public static BigDecimal toNumber(Object value)
value
- the value to convert to a BigDecimal (can be null).null
if value
is null
.NumberFormatException
- if value
is invalid.public static int compare(Object lvalue, Object rvalue)
lvalue
- the left value of the comparison.rvalue
- the right value of the comparison.lvalue
is less than, equal to,
or greater than rvalue
.NullPointerException
- if an argument is null
.Copyright © OBCOM INGENIERIA S.A. (Chile). All Rights Reserved.