本文整理了Java中org.mvel2.MVEL.getProperty()
方法的一些代码示例,展示了MVEL.getProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MVEL.getProperty()
方法的具体详情如下:
包路径:org.mvel2.MVEL
类名称:MVEL
方法名:getProperty
暂无
代码示例来源:origin: dhanji/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
};
代码示例来源:origin: com.github.fosin/cdp-utils
/**
* getProperty
*
* @param bean a {@link java.lang.Object} object.
* @param nm a {@link java.lang.String} object.
* @return a {@link java.lang.Object} object.
* @throws java.lang.Exception if any.
*/
public static Object getProperty(Object bean, String nm) throws Exception {
Object val = null;
val = MVEL.getProperty(nm, bean);
return val;
}
代码示例来源:origin: dhanji/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
代码示例来源:origin: com.google.sitebricks/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
代码示例来源:origin: com.google.sitebricks/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
};
代码示例来源:origin: br.com.objectos/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
};
代码示例来源:origin: br.com.objectos/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
代码示例来源:origin: br.com.objectos/sitebricks
public Object read(String property, Object contextObject) {
return MVEL.getProperty(property, contextObject);
}
};
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory vars, Object value) {
try {
Object v = method.invoke(ctx, EMPTY);
if (v == null) v = nullHandler.getProperty(method.getName(), ctx, vars);
return nextNode.setValue(v, elCtx, vars, value);
}
catch (IllegalArgumentException e) {
/**
* HACK: Try to access this another way.
*/
Object v = getProperty(method.getName() + "()", ctx);
if (v == null) v = nullHandler.getProperty(method.getName(), ctx, vars);
return nextNode.setValue(v, elCtx, vars, value);
}
catch (CompileException e) {
throw e;
}
catch (Exception e) {
throw new RuntimeException("error " + method.getName() + ": " + e.getClass().getName() + ":" + e.getMessage(), e);
}
}
代码示例来源:origin: org.mvel/mvel2
public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) {
if (!conversionType.isAssignableFrom(ctx.getClass())) {
if (nextNode != null) {
return nextNode.getValue(MVEL.getProperty(propertyName, ctx), elCtx, variableFactory);
}
else {
return MVEL.getProperty(propertyName, ctx);
}
}
try {
if (nextNode != null) {
return nextNode.getValue(propertyHandler.getProperty(propertyName, ctx, variableFactory), elCtx, variableFactory);
}
else {
return propertyHandler.getProperty(propertyName, ctx, variableFactory);
}
}
catch (Exception e) {
throw new RuntimeException("unable to access field", e);
}
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) {
if (!conversionType.isAssignableFrom(ctx.getClass())) {
if (nextNode != null) {
return nextNode.getValue(MVEL.getProperty(propertyName, ctx), elCtx, variableFactory);
}
else {
return MVEL.getProperty(propertyName, ctx);
}
}
try {
if (nextNode != null) {
return nextNode.getValue(propertyHandler.getProperty(propertyName, ctx, variableFactory), elCtx, variableFactory);
}
else {
return propertyHandler.getProperty(propertyName, ctx, variableFactory);
}
}
catch (Exception e) {
throw new RuntimeException("unable to access field", e);
}
}
代码示例来源:origin: org.mvel/mvel2
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory vars, Object value) {
try {
Object v = method.invoke(ctx, EMPTY);
if (v == null) v = nullHandler.getProperty(method.getName(), ctx, vars);
return nextNode.setValue(v, elCtx, vars, value);
}
catch (IllegalArgumentException e) {
/**
* HACK: Try to access this another way.
*/
Object v = getProperty(method.getName() + "()", ctx);
if (v == null) v = nullHandler.getProperty(method.getName(), ctx, vars);
return nextNode.setValue(v, elCtx, vars, value);
}
catch (CompileException e) {
throw e;
}
catch (Exception e) {
throw new RuntimeException("error " + method.getName() + ": " + e.getClass().getName() + ":" + e.getMessage(), e);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mvel
public Object getValue(Object ctx, Object elCtx, VariableResolverFactory vars) {
try {
return nullHandle(method.getName(), method.invoke(ctx, EMPTY), ctx, elCtx, vars);
}
catch (IllegalArgumentException e) {
if (ctx != null && method.getDeclaringClass() != ctx.getClass()) {
Method o = getBestCandidate(EMPTY, method.getName(), ctx.getClass(), ctx.getClass().getMethods(), true);
if (o != null) {
return executeOverrideTarget(o, ctx, elCtx, vars);
}
}
/**
* HACK: Try to access this another way.
*/
return nullHandle(method.getName(), getProperty(method.getName() + "()", ctx), ctx, elCtx, vars);
}
catch (Exception e) {
throw new CompileException("cannot invoke getter: " + method.getName()
+ " [declr.class: " + method.getDeclaringClass().getName() + "; act.class: "
+ (ctx != null ? ctx.getClass().getName() : "null") + "]", e);
}
}
代码示例来源:origin: org.mvel/mvel2
public void testNullSafe() {
Map<String, Map<String, Float>> ctx = new HashMap<String, Map<String, Float>>();
Map<String, Float> tmp = new HashMap<String, Float>();
// tmp.put("latitude", 0.5f);
ctx.put("SessionSetupRequest", tmp);
System.out.println("Result = " + MVEL.getProperty("SessionSetupRequest.?latitude", ctx));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mvel
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory vars, Object value) {
try {
Object v = method.invoke(ctx, EMPTY);
if (v == null) v = nullHandler.getProperty(method.getName(), ctx, vars);
return nextNode.setValue(v, elCtx, vars, value);
}
catch (IllegalArgumentException e) {
/**
* HACK: Try to access this another way.
*/
Object v = getProperty(method.getName() + "()", ctx);
if (v == null) v = nullHandler.getProperty(method.getName(), ctx, vars);
return nextNode.setValue(v, elCtx, vars, value);
}
catch (CompileException e) {
throw e;
}
catch (Exception e) {
throw new CompileException("error " + method.getName() + ": " + e.getClass().getName() + ":" + e.getMessage(), e);
}
}
代码示例来源:origin: org.mvel/mvel2
/**
* Submitted by: cleverpig
*/
public void testBug4() {
ClassA A = new ClassA();
ClassB B = new ClassB();
System.out.println(MVEL.getProperty("date",
A));
System.out.println(MVEL.getProperty("date",
B));
}
代码示例来源:origin: org.mvel/mvel2
public void testInfiniteLoop() {
A226 a = new A226();
Map m = Collections.singletonMap("a", a);
String ex = "a.map['foo']";
try {
MVEL.getProperty(ex, m);
fail("access to a null field must fail");
} catch (Exception e) {
// ignore
}
}
代码示例来源:origin: org.mvel/mvel2
public void testSetListListener() {
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
class MyListener implements Listener {
public int counter;
public void onEvent(Object context, String contextName,
VariableResolverFactory variableFactory, Object value) {
counter++;
}
}
class MyBean {
private List someList;
public List getSomeList() {
return someList;
}
}
MyListener listener = new MyListener();
GlobalListenerFactory.registerGetListener(listener);
MVEL.getProperty("someList", new MyBean());
MVEL.getProperty("someList", new MyBean());
assertEquals(2, listener.counter);
}
代码示例来源:origin: org.mvel/mvel2
public void testSetSemantics() {
Bar bar = new Bar();
Foo foo = new Foo();
assertEquals("dog",
MVEL.getProperty("name",
bar));
assertEquals("dog",
MVEL.getProperty("name",
foo));
}
代码示例来源:origin: org.mvel/mvel2
public void testMVEL226() {
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
A226 a = new A226();
Map m = Collections.singletonMap("a", a);
Map<String, Object> nestMap = Collections.<String, Object>singletonMap("foo", "bar");
String ex = "a.?map['foo']";
Serializable s;
assertNull(MVEL.getProperty(ex, m));
OptimizerFactory.setDefaultOptimizer("ASM");
s = MVEL.compileExpression(ex);
assertNull(MVEL.executeExpression(s, m));
a.map = nestMap;
assertEquals("bar", MVEL.executeExpression(s, m));
a.map = null;
OptimizerFactory.setDefaultOptimizer(OptimizerFactory.DYNAMIC);
s = MVEL.compileExpression(ex);
assertNull(MVEL.executeExpression(s, m));
a.map = nestMap;
assertEquals("bar", MVEL.executeExpression(s, m));
}
内容来源于网络,如有侵权,请联系作者删除!