本文整理汇总了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();
}