当前位置: 首页>>代码示例>>Java>>正文


Java MapExpression类代码示例

本文整理汇总了Java中org.javastack.mapexpression.MapExpression的典型用法代码示例。如果您正苦于以下问题:Java MapExpression类的具体用法?Java MapExpression怎么用?Java MapExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapExpression类属于org.javastack.mapexpression包,在下文中一共展示了MapExpression类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.javastack.mapexpression.MapExpression; //导入依赖的package包/类
public static void main(final String[] args) throws Throwable {
	final HashMap<String, String> map = new HashMap<String, String>();
	map.put("user", "john");
	final MapExpression m = new MapExpression();
	//
	m.setExpression("Hi ###user###") //
			.setDelimiters("###", "###") //
			.setPostMapper(new MapMapper(map));
	System.out.println(m.parse().eval().get());
	//
	m.setExpression("{{user}}? {{user}}?") //
			.setDelimiters("{{", "}}") //
			.setPostMapper(new MapMapper(map));
	System.out.println(m.parse().eval().get());
	//
	m.setExpression("Hi |user|, how are you?") //
			.setDelimiters("|", "|") //
			.setPostMapper(new MapMapper(map));
	System.out.println(m.parse().eval().get());
}
 
开发者ID:ggrandes,项目名称:mapexpression,代码行数:21,代码来源:Example3.java

示例2: main

import org.javastack.mapexpression.MapExpression; //导入依赖的package包/类
public static void main(final String[] args) throws Throwable {
	final String TEST_TEXT = "Hi ${user.name}, you are ${state}!!";
	final HashMap<String, String> map = new HashMap<String, String>();
	map.put("state", "lucky");
	final MapExpression m = new MapExpression(TEST_TEXT, map, true);
	System.out.println(m.get());
}
 
开发者ID:ggrandes,项目名称:mapexpression,代码行数:8,代码来源:Example1.java

示例3: main

import org.javastack.mapexpression.MapExpression; //导入依赖的package包/类
public static void main(final String[] args) throws Throwable {
	final String TEST_TEXT = "Hi ${user.name}, you are ${state}!!";
	final HashMap<String, String> map = new HashMap<String, String>();
	map.put("state", "lucky");
	final MapExpression m = new MapExpression();
	m.setExpression(TEST_TEXT) //
			.setPreMapper(SystemPropertyMapper.getInstance()) //
			.setPostMapper(new MapMapper(map)) //
			.parse() //
			.eval();
	System.out.println(m.get());
}
 
开发者ID:ggrandes,项目名称:mapexpression,代码行数:13,代码来源:Example2.java

示例4: main

import org.javastack.mapexpression.MapExpression; //导入依赖的package包/类
public static void main(final String[] args) throws Throwable {
	final int TOTAL = (int) 1e7;
	final String TEST_TEXT = "Hi ${user.name}, you are ${state}!!";
	final HashMap<String, String> map = new HashMap<String, String>();
	map.put("state", "lucky");
	final MapExpression m = new MapExpression() //
			.setExpression(TEST_TEXT) //
			.setPreMapper(SystemPropertyMapper.getInstance()) //
			.setPostMapper(new MapMapper(map)); //
	//
	long begin, diff;
	System.out.println("TestName | Iterations | Time | Iterations/Second");
	// Benchmark ParseOnly
	begin = System.currentTimeMillis();
	for (int i = 0; i < TOTAL; i++) {
		m.parse();
	}
	diff = Math.max(1, (System.currentTimeMillis() - begin));
	System.out.println(printTest("ParseOnly", TOTAL, diff));
	// Benchmark EvalOnly
	begin = System.currentTimeMillis();
	for (int i = 0; i < TOTAL; i++) {
		m.eval().get();
	}
	diff = Math.max(1, (System.currentTimeMillis() - begin));
	System.out.println(printTest("EvalOnly", TOTAL, diff));
	// Benchmark Parse+Eval
	begin = System.currentTimeMillis();
	for (int i = 0; i < TOTAL; i++) {
		m.parse().eval().get();
	}
	diff = Math.max(1, (System.currentTimeMillis() - begin));
	System.out.println(printTest("Parse+Eval", TOTAL, diff));
}
 
开发者ID:ggrandes,项目名称:mapexpression,代码行数:35,代码来源:Benchmark.java

示例5: eval

import org.javastack.mapexpression.MapExpression; //导入依赖的package包/类
private final String eval(final String str) throws InvalidExpression {
	if (str == null)
		return null;
	return new MapExpression(str, null, mapper, false).eval().get();
}
 
开发者ID:ggrandes,项目名称:stringproperties,代码行数:6,代码来源:StringProperties.java


注:本文中的org.javastack.mapexpression.MapExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。