JEXL(Java Expression Language)

Unfold Hierarchy number Tags Values

      JEXL(Java Expression Language)
        1  Examples
            1.1  Object
                1.1.1  double
JEXL scriptvar d = new('java.lang.Double', 0d); return 'minmum of positive=' + d.MIN_VALUE + ' maximum=' + d.MAX_VALUE;
                1.1.2  string
JEXL scriptvar s = new('java.lang.String', 'Hello'); return 'include e:'+ s.contains('e') + ' length:' + s.length();
                1.1.3  time
JEXL scriptvar date = new('java.util.Date'); return 'current time:' + date.toString() + ' value:' + date.getTime();
            1.2  Math
                1.2.1  e
JEXL scriptMath.E
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.2  pi
JEXL scriptMath.PI
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.3  absoluate
JEXL scriptMath.abs(-5.611)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.4  square root
JEXL scriptMath.sqrt(9)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.5  cubic root
JEXL scriptMath.cbrt(27)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.6  power
JEXL scriptMath.pow(2,5)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.7  power of e
JEXL scriptMath.exp(2)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.8  natural logarithm(base e)
JEXL scriptMath.log(6)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.9  common logarithm(base 10)
JEXL scriptMath.log10(6)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.10  cosine
JEXL scriptMath.cos(0)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.11  sine
JEXL scriptMath.sin(9)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.12  tangent
JEXL scriptMath.tan(5)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.13  arc tangent
JEXL scriptMath.atan(-7.3)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.14  arc cosine
JEXL scriptMath.acos(0.5)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.15  arc sine
JEXL scriptMath.asin(0.3)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.16  round up
JEXL scriptMath.ceil(4.13)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.17  round down
JEXL scriptMath.floor(4.67)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.18  round
JEXL scriptMath.round(4.83)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.19  random()
JEXL scriptMath.random( )
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.20  maximum
JEXL scriptMath.max(1,-3)
JEXL ContextjexlContext.set("Math", Math.class);
                1.2.21  minimum
JEXL scriptMath.min(1,-3)
JEXL ContextjexlContext.set("Math", Math.class);
            1.3  Boolean expression
                1.3.1  in array
JEXL scriptvar value = 3; var array = [1,'2',3, 'hello']; value =~ array;
                1.3.2  not in set
JEXL scriptvar value = 2; var set = {1,'2',3, 'hello'}; value !~ set;
                1.3.3  match string
JEXL scriptvar s = 'abc1233hello'; var regex = '\\S*3{2,}\\S*'; var caseInsensitive = true; StringTools.match(s,regex,caseInsensitive);
JEXL ContextjexlContext.set("StringTools", mara.mybox.tools.StringTools.class);
                1.3.4  include string
JEXL scriptvar s = 'abc1233hello'; var regex = '3{2}'; var caseInsensitive = true; StringTools.include(s,regex,caseInsensitive);
JEXL ContextjexlContext.set("StringTools", mara.mybox.tools.StringTools.class);
                1.3.5  and/or/not
JEXL scriptvar a = 5; var b = 2; 'hello'.startsWith('hell') and ( a < 9 or b >= 6 ) and not ( a == b );
            1.4  Numeric operations
                1.4.1  decimal scale
JEXL scriptvar d = 52362.18903; var scale = 2; DoubleTools.scale(d, scale);
JEXL ContextjexlContext.set("DoubleTools", mara.mybox.tools.DoubleTools.class);
                1.4.2  format
JEXL scriptvar d = 52362.18903; var scale = 2; DoubleTools.format(d, scale);
JEXL ContextjexlContext.set("DoubleTools", mara.mybox.tools.DoubleTools.class);
                1.4.3  percentage
JEXL scriptvar number = 37; var total = 518; var scale = 2; DoubleTools.percentage(number, total, scale);
JEXL ContextjexlContext.set("DoubleTools", mara.mybox.tools.DoubleTools.class);
            1.5  Date
                1.5.1  now
JEXL scriptDateTools.nowString();
JEXL ContextjexlContext.set("DateTools", mara.mybox.tools.DateTools.class);
                1.5.2  format
JEXL scriptvar date = new('java.util.Date'); var format = 'yyyy-MM-dd HH:mm:ss.SSS'; DateTools.datetimeToString(date, format);
JEXL ContextjexlContext.set("DateTools", mara.mybox.tools.DateTools.class);
            1.6  Statement
                1.6.1  loop
JEXL scriptvar array = [ 'A', 'B', 'C', 'D' ]; var arrayString = ''; for (var i : 1 .. size (array)) { if (empty (arrayString)) { arrayString = array[i-1]; } else { arrayString += ' , ' + array[i-1]; } } return arrayString;
                1.6.2  function
JEXL scriptvar circleArea = function(r) { Math.PI * r * r } var r = 9.42; return circleArea(r);
JEXL ContextjexlContext.set("Math", Math.class);