Skip to content

jackyxinli/commons-jexl-3.1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

commons-jexl-3.1

The original version does not support bit move operation. So I add bit move operators like "<<" and ">>" for bit move operation, and bit move assignment operators like "<<=" and ">>=" are supported. Then parser can parse expression like "3 << 26" or "l<<=r", the result is 0x0C000000 in Hex format.

These listed files are modified.

  1. org/apache/commons/jexl3/internal/Debugger.java
  2. org/apache/commons/jexl3/internal/Interpreter.java
  3. org/apache/commons/jexl3/internal/Operators.java
  4. org/apache/commons/jexl3/parser/ParserVisitor.java
  5. org/apache/commons/jexl3/parser/Parser.jjt
  6. org/apache/commons/jexl3/JexlArithmetic.java
  7. org/apache/commons/jexl3/JexlOperator.java

Compile

  1. Install JDK 1.8 or upper.
  2. Install the latest version of Maven.
  3. Set environment in local operation system.
  4. Run commands in command line(Windows) or terminal(Unix/Linux).
    4.1 mvn package
    4.2 Copy jar file 'commons-jexl3-3.1.jar' generated by maven into project directory and add it to build path.

Examples

Example 1

import org.apache.commons.jexl3.JexlBuilder;
import org.apache.commons.jexl3.JexlContext;
import org.apache.commons.jexl3.JexlEngine;
import org.apache.commons.jexl3.JexlExpression;
import org.apache.commons.jexl3.MapContext;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		JexlBuilder builder = new JexlBuilder();
		JexlEngine engine = builder.create();
		JexlExpression expression = null;
		JexlContext context = null;

		context = new MapContext();
		context.set("l", 3);
		context.set("r", 26);

		expression = engine.createExpression("l<<(r+1)");
		Object ret = expression.evaluate(context);

		if (ret instanceof Long) {
			Long val = (Long) ret;
			System.out.println(String.format("0x%08X", val.longValue()));
		}
	}
}

Example 2

import org.apache.commons.jexl3.JexlBuilder;
import org.apache.commons.jexl3.JexlContext;
import org.apache.commons.jexl3.JexlEngine;
import org.apache.commons.jexl3.JexlExpression;
import org.apache.commons.jexl3.MapContext;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		JexlBuilder builder = new JexlBuilder();
		JexlEngine engine = builder.create();
		JexlExpression expression = null;
		JexlContext context = null;

		context = new MapContext();
		context.set("l", 3);
		context.set("r", 26);

		expression = engine.createExpression("l<<=r");
		Object ret = expression.evaluate(context);

		if (ret instanceof Long) {
			Long val = (Long) ret;
			System.out.println(String.format("0x%08X", val.longValue()));
		}
		
		Object var = context.get("l");
		if (var instanceof Long) {
			Long val = (Long) var;
			System.out.println(String.format("0x%08X", val.longValue()));
		}
	}
}

About

commons-jexl-3.1

Resources

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE
Apache-2.0
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published