當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。