本文整理汇总了Java中org.mvel2.integration.VariableResolverFactory类的典型用法代码示例。如果您正苦于以下问题:Java VariableResolverFactory类的具体用法?Java VariableResolverFactory怎么用?Java VariableResolverFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariableResolverFactory类属于org.mvel2.integration包,在下文中一共展示了VariableResolverFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public static void main(String[] args) {
Foo foo = new Foo();
foo.setName("test");
Map context = new HashMap();
String expression = "foo.name == 'test'";
VariableResolverFactory functionFactory = new MapVariableResolverFactory(context);
context.put("foo",foo);
Boolean result = (Boolean) MVEL.eval(expression,functionFactory);
System.out.println(result);
Serializable compileExpression = MVEL.compileExpression(expression);
result = (Boolean) MVEL.executeExpression(compileExpression, context, functionFactory);
System.out.print(result);
}
示例2: runMvel
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public static void runMvel(int xmax, int ymax, int zmax) {
Map context = new HashMap();
String expression = "x + y*2 - z";
Serializable compileExpression = MVEL.compileExpression(expression);
Integer result = 0;
Date start = new Date();
for (int xval = 0; xval < xmax; xval++) {
for (int yval = 0; yval < ymax; yval++) {
for (int zval = 0; zval <= zmax; zval++) {
context.put("x", xval);
context.put("y", yval);
context.put("z", zval);
VariableResolverFactory functionFactory = new MapVariableResolverFactory(context);
Integer cal = (Integer) MVEL.executeExpression(compileExpression, context, functionFactory);
result += cal;
}
}
}
Date end = new Date();
System.out.println("MVEL:time is : " + (end.getTime() - start.getTime()) + ",result is " + result);
}
示例3: optimizeAccessor
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public Accessor optimizeAccessor(ParserContext pCtx, char[] property, Object ctx, Object thisRef,
VariableResolverFactory factory, boolean root, Class ingressType) {
this.rootNode = this.currNode = null;
this.start = this.cursor = 0;
this.first = true;
this.length = (this.expr = property).length;
this.ctx = ctx;
this.thisRef = thisRef;
this.variableFactory = factory;
this.ingressType = ingressType;
this.pCtx = pCtx;
return compileGetChain();
}
示例4: findClassImportResolverFactory
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public static ClassImportResolverFactory findClassImportResolverFactory(VariableResolverFactory factory) {
VariableResolverFactory v = factory;
while (v != null) {
if (v instanceof ClassImportResolverFactory) {
return (ClassImportResolverFactory) v;
}
v = v.getNextFactory();
}
if (factory == null) {
throw new OptimizationFailure("unable to import classes. no variable resolver factory available.");
}
else {
return insertFactory(factory, new ClassImportResolverFactory());
}
}
示例5: optimize
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
private Object optimize(Object ctx, Object elCtx, VariableResolverFactory variableResolverFactory) {
if (DynamicOptimizer.isOverloaded()) {
DynamicOptimizer.enforceTenureLimit();
}
AccessorOptimizer ao = OptimizerFactory.getAccessorCompiler("ASM");
switch (type) {
case DynamicOptimizer.REGULAR_ACCESSOR:
_accessor = ao.optimizeAccessor(context, property, ctx, elCtx, variableResolverFactory, false, null);
return ao.getResultOptPass();
case DynamicOptimizer.OBJ_CREATION:
_accessor = ao.optimizeObjectCreation(context, property, ctx, elCtx, variableResolverFactory);
return _accessor.getValue(ctx, elCtx, variableResolverFactory);
case DynamicOptimizer.COLLECTION:
_accessor = ao.optimizeCollection(AbstractParser.getCurrentThreadParserContext(), ctx, null, property, ctx, elCtx, variableResolverFactory);
return _accessor.getValue(ctx, elCtx, variableResolverFactory);
}
return null;
}
示例6: setValue
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value) {
if (!opt) {
if (++runcount > DynamicOptimizer.tenuringThreshold) {
if ((currentTimeMillis() - stamp) < DynamicOptimizer.timeSpan) {
opt = true;
return optimize(ctx, elCtx, variableFactory, value);
}
else {
runcount = 0;
stamp = currentTimeMillis();
}
}
}
_accessor.setValue(ctx, elCtx, variableFactory, value);
return value;
}
示例7: getValue
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) {
if (!opt) {
if (++runcount > DynamicOptimizer.tenuringThreshold) {
if ((currentTimeMillis() - stamp) < DynamicOptimizer.timeSpan) {
opt = true;
return optimize(AbstractParser.getCurrentThreadParserContext(), ctx, elCtx, variableFactory);
}
else {
runcount = 0;
stamp = currentTimeMillis();
}
}
}
return _accessor.getValue(ctx, elCtx, variableFactory);
}
示例8: execute
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public Integer execute(String columnValue, Map<String, Object> extension) {
Map<String, Object> vrs = new HashMap<String, Object>();
//, Map<String, ElFunction<?,?>> functionMap
//vrs.putAll(functionMap);// 拓展函数
Map<String, Object> params = new HashMap<String, Object>();
params.put("value", columnValue);
vrs.put("$ROOT", params);
VariableResolverFactory vrfactory = new MapVariableResolverFactory(vrs);
return MVEL.eval(expression, params, vrfactory, Integer.class);
}
示例9: setValue
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value) {
if (nextNode != null) {
return nextNode.setValue(propertyHandler.getProperty(propertyName, ctx, variableFactory), ctx, variableFactory, value);
}
else {
return propertyHandler.setProperty(propertyName, ctx, variableFactory, value);
}
}
示例10: testThisReferenceMapVirtualObjects
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public void testThisReferenceMapVirtualObjects() {
Map<String, String> map = new HashMap<String, String>();
map.put("foo",
"bar");
VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
factory.createVariable("this", map);
assertEquals(true,
eval("this.foo == 'bar'", map, factory));
}
示例11: executeExpression
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public static <T> T executeExpression(final Object compiledExpression, final Object ctx, final VariableResolverFactory vars, Class<T> toType) {
try {
return convert(executeExpression(compiledExpression, ctx, vars), toType);
}
catch (EndWithValue end) {
return convert(end.getValue(), toType);
}
}
示例12: checkBreak
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public int checkBreak(LineLabel label, VariableResolverFactory factory, CompiledExpression expression) {
if (debuggerState == Debugger.STEP || hasBreakpoint(label)) {
if (debugger == null) throw new RuntimeException("no debugger registered to handle breakpoint");
return debuggerState = debugger.onBreak(new Frame(label, factory, expression.getParserContext()));
}
return 0;
}
示例13: getInjectedImports
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public static Map<String, Object> getInjectedImports(VariableResolverFactory factory) {
if (factory == null) return null;
do {
if (factory instanceof ClassImportResolverFactory) {
return ((ClassImportResolverFactory) factory).getImportedClasses();
}
}
while ((factory = factory.getNextFactory()) != null);
return null;
}
示例14: setValue
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory vrf, Object value) {
if (accessor == null) {
if (ingressType == Object.class && value != null) ingressType = value.getClass();
accessor = getThreadAccessorOptimizer()
.optimizeSetAccessor(context, expression, ctx, ctx, vrf, false, value, ingressType);
}
else {
accessor.setValue(ctx, elCtx, vrf, value);
}
return value;
}
示例15: insertFactory
import org.mvel2.integration.VariableResolverFactory; //导入依赖的package包/类
public void insertFactory(VariableResolverFactory resolverFactory) {
if (nextFactory == null) {
nextFactory = resolverFactory;
}
else {
resolverFactory.setNextFactory(nextFactory = resolverFactory);
}
}