User Guide

Jexpel is very simple to use.


You will just need one line to do it. See bellow.

  Expression exp = Compiler.getCompiler().compile(AnyClass.class, "a expression");
  • AnyClass is the class of the object where you will execute the expression * a expression is the expression you wanna compile. In the next section I'll explain which expresions can be compiled.

Writing Expressions

The expression are almost all you can imagine, there are some rules to write them.

  1. You can refer to fields in the object by their names. Automaticaly the compiler will use a get method if it exists. If it doesn't exist it will try to access the field directly if its visibility is public;
  2. The same is did for fields of fields;
  3. You can call methods at the same way you do in java;
  4. You can access arrays by passing a index that is an expression with an integer result;
  5. Types of terms are converted automaticaly to a result type with the priority as seen bellow
    Date 2
    double 3
    float 4
    long 5
    int 6
    short 7
    byte, char, boolean 8
  6. Operators >, <, ==, <=, >= are automaticaly converted to the compareTo method, this way you can use them to any class which implements the Comparable interface.
  7. Operators +, - are implemented just for numbers, String(just +) and Date
  8. Operators *, / are implemented for all number types
  9. Operators %, &, ^, ~, | just to integer types
  10. Operators &&, ||, ! only to booleans
  11. You can use conditional expressions cond ? exp1 : exp2