protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object v1 = children[0].getValue(context, source); object v2 = children[1].getValue(context, source); return(OgnlOps.operin(v1, v2)? false : true); }
protected override void setValueBody(OgnlContext context, object target, object value) // throws OgnlException { object test = children[0].getValue(context, target); int branch = OgnlOps.booleanValue(test)? 1 : 2; children[branch].setValue(context, target, value); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object test = children[0].getValue(context, source); int branch = OgnlOps.booleanValue(test)? 1 : 2; return(children[branch].getValue(context, source)); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object v1 = children[0].getValue(context, source); object v2 = children[1].getValue(context, source); return(OgnlOps.remainder(v1, v2)); }
/** * Returns OgnlRuntime.NotFound if the property does not exist. */ public object getPossibleProperty(IDictionary context, object target, string name) // throws OgnlException { object result; OgnlContext ognlContext = (OgnlContext)context; if (context [("_compile")] != null) { Getter getter = getGetter(ognlContext, target, name); if (getter != NotFoundGetter) { result = getter.get(ognlContext, target, name); } else { try { result = OgnlRuntime.getFieldValue(ognlContext, target, name, true); } catch (Exception ex) { throw new OgnlException(name, ex); } } } else { result = base.getPossibleProperty(context, target, name); } return(result); }
protected override object getValueBody(OgnlContext context, object source) { object result = children[1].getValue(context, source); children[0].setValue(context, source, result); return(result); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object result = children[0].getValue(context, source); for (int i = 1; i < children.Length; ++i) { result = OgnlOps.multiply(result, children[i].getValue(context, source)); } return(result); }
protected override void setValueBody(OgnlContext context, object target, object value) // throws OgnlException { int last = children.Length - 1; for (int i = 0; i < last; ++i) { object v = children[i].getValue(context, target); if (OgnlOps.booleanValue(v)) { return; } } children[last].setValue(context, target, value); }
protected override void setValueBody(OgnlContext context, object target, object value) // throws OgnlException { object expr = children[0].getValue(context, target), previousRoot = context.getRoot(); Node node; target = children[1].getValue(context, target); node = (expr is Node) ? (Node)expr : (Node)Ognl.parseExpression(expr.ToString()); try { context.setRoot(target); node.setValue(context, target, value); } finally { context.setRoot(previousRoot); } }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object result = null; int last = children.Length - 1; for (int i = 0; i <= last; ++i) { result = children[i].getValue(context, source); if (i != last && OgnlOps.booleanValue(result)) { break; } } return(result); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren()); object root = context.getRoot(); try { for (int i = 0, icount = args.Length; i < icount; ++i) { args[i] = children[i].getValue(context, root); } return(OgnlRuntime.callStaticMethod(context, className, methodName, args)); } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object result, expr = children[0].getValue(context, source), previousRoot = context.getRoot(); Node node; source = children[1].getValue(context, source); node = (expr is Node) ? (Node)expr : (Node)Ognl.parseExpression(expr.ToString()); try { context.setRoot(source); result = node.getValue(context, source); } finally { context.setRoot(previousRoot); } return(result); }
public static Getter generateGetter(OgnlContext context, string code) // throws OgnlException { string className = NAME_FACTORY.getNewClassName(); try { ClassPool pool = (ClassPool)pools [(context.getClassResolver())]; EnhancedClassLoader loader = (EnhancedClassLoader)loaders [(context.getClassResolver())]; CtClass newClass; CtClass ognlContextClass; CtClass objectClass; CtClass stringClass; CtMethod method; byte[] byteCode; Type compiledClass; if ((pool == null) || (loader == null)) { ClassLoader classLoader = new ContextClassLoader(typeof(OgnlContext).getClassLoader(), context); pool = ClassPool.getDefault(); pool.insertClassPath(new LoaderClassPath(classLoader)); pools.Add(context.getClassResolver(), pool); loader = new EnhancedClassLoader(classLoader); loaders.Add(context.getClassResolver(), loader); } newClass = pool.makeClass(className); ognlContextClass = pool.get(typeof(OgnlContext).Name); objectClass = pool.get(typeof(object).Name); stringClass = pool.get(typeof(string).Name); newClass.addInterface(pool.get(typeof(Getter).Name)); method = new CtMethod(objectClass, "get", new CtClass[] { ognlContextClass, objectClass, stringClass }, newClass); method.setBody("{" + code + "}"); newClass.addMethod(method); byteCode = newClass.toBytecode(); compiledClass = loader.defineClass(className, byteCode); return((Getter)compiledClass.newInstance()); } catch (Exception ex) { throw new OgnlException("Cannot create class", ex); } }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren()); try { object result, root = context.getRoot(); for (int i = 0, icount = args.Length; i < icount; ++i) { args[i] = children[i].getValue(context, root); } result = OgnlRuntime.callMethod(context, source, methodName, null, args); if (result == null) { NullHandler nh = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source)); result = nh.nullMethodResult(context, source, methodName, args); } return(result); } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { return(OgnlOps.negate(children[0].getValue(context, source))); }
/*=================================================================== * Constructors * ===================================================================*/ public ContextClassLoader(ClassLoader parentClassLoader, OgnlContext context) { base(parentClassLoader); this.context = context; }
public OgnlEvaluator(object fixture) { this.Fixture = fixture; this.OgnlContext = new OgnlContext(); }
public OgnlEvaluator(object fixture) { this.Fixture = fixture; this.OgnlContext = new OgnlContext(); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object value = children[0].getValue(context, source); return(OgnlRuntime.isInstance(context, value, targetType)); // ? Boolean.TRUE : Boolean.FALSE; }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { return(context.getRoot()); }
public virtual void setUp() { context = (OgnlContext)Ognl.createDefaultContext(null); }
protected override void setValueBody(OgnlContext context, object target, object value) // throws OgnlException { context [name] = value; }
public void setUp() { context = (OgnlContext)Ognl.createDefaultContext(null); context.setMemberAccess(new DefaultMemberAccess(true)); }
protected void setUp() { context = (OgnlContext)Ognl.createDefaultContext(null); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { return(OgnlOps.booleanValue(children[0].getValue(context, source))? false : true); }
protected override void setValueBody(OgnlContext context, object target, object value) // throws OgnlException { context.setRoot(value); }
private Getter getGetter(OgnlContext context, object target, string propertyName) // throws OgnlException { Getter result; Type targetClass = target.GetType(); IDictionary propertyMap; if ((propertyMap = (IDictionary)seenGetMethods.get(targetClass)) == null) { propertyMap = new HashMap(101); seenGetMethods.put(targetClass, propertyMap); } if ((result = (Getter)propertyMap.get(propertyName)) == null) { try { MethodInfo method = OgnlRuntime.getGetMethod(context, targetClass, propertyName); if (method != null) { if (method.IsPublic) { if (method.ReturnType.IsPrimitive) { propertyMap.Add(propertyName, result = generateGetter(context, "java.lang.object\t\tresult;\n" + targetClass.Name + "\t" + "t0 = (" + targetClass.Name + ")$2;\n" + "\n" + "try {\n" + " result = new " + getPrimitiveWrapperClass(method.ReturnType).Name + "(t0." + method.Name + "());\n" + "} catch (java.lang.Exception ex) {\n" + " throw new java.lang.RuntimeException(ex);\n" + "}\n" + "return result;" )); } else { propertyMap.Add(propertyName, result = generateGetter(context, "java.lang.object\t\tresult;\n" + targetClass.Name + "\t" + "t0 = (" + targetClass.Name + ")$2;\n" + "\n" + "try {\n" + " result = t0." + method.Name + "();\n" + "} catch (java.lang.Exception ex) {\n" + " throw new java.lang.RuntimeException(ex);\n" + "}\n" + "return result;" )); } } else { propertyMap.Add(propertyName, result = DefaultGetter); } } else { propertyMap.Add(propertyName, result = NotFoundGetter); } } catch (Exception ex) { throw new OgnlException("getting getter", ex); } } return(result); }