commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kukosa, Tomas" <tomas.kuk...@siemens-enterprise.com>
Subject [jexl] mathod within namespace not found if parameter is int[]
Date Fri, 10 Aug 2012 11:00:47 GMT
Hi,

the method log(Object fmt, Object... arr) acessible via namespace is not found if it is called
with (String, int[]) parameters.
All other types of parameters work well.
See the example below.

Best regards,
  Tomas


---------
public class Test03 {

	private final static String NS_UTIL = "util";
	private final static ScriptUtil mNsUtil = new ScriptUtil();

	private static class JCtx extends MapContext implements NamespaceResolver {
		@Override
		public Object resolveNamespace(String name) {
            if (name == null) {
                return this;
            }
            if (NS_UTIL.equals(name)) {
                return mNsUtil;
            }
            return null;
		}
	}
	
	private final static String[] SCRIPTS = {
		"var x = null; util:log('x = %s', x);",
		"var x = 'abc'; util:log('x = %s', x);",
		"var x = 333; util:log('x = %s', x);",
		"var x = [1, 2]; util:log('x = %s', x);", // === ERROR ===
		"var x = ['a', 'b']; util:log('x = %s', x);",
		"var x = {1:'A', 2:'B'}; util:log('x = %s', x);",
	};

	public static void main(String[] args) {
		JexlEngine jexl = new JexlEngine();
		JexlContext jc = new JCtx();
		Script script;

		for (String stext : SCRIPTS) {
			System.out.println(stext);
			script = jexl.createScript(stext);
			script.execute(jc);
		}
		
	}

	public static class ScriptUtil {
		public void log(Object fmt, Object... arr) {
			System.out.println(String.format(fmt.toString(), arr));
		}
	}

}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message