本文整理匯總了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());
}
示例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());
}
示例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());
}
示例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));
}
示例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();
}