public String getSourceAccessor(OgnlContext context, Object target, Object index) { String indexStr = index.toString(); // need to convert to primitive for list index access // System.out.println("index class " + index.getClass() + " current type " + context.getCurrentType() + " current object class " + context.getCurrentObject().getClass()); if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) { indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) { // means it needs to be cast first as well String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()"; indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")"; } context.setCurrentAccessor(target.getClass()); context.setCurrentType(target.getClass().getComponentType()); return "[" + indexStr + "]"; }
public String getSourceAccessor(OgnlContext context, Object target, Object index) { String indexStr = index.toString(); // need to convert to primitive for list index access // System.out.println("index class " + index.getClass() + " current type " + context.getCurrentType() + " current object class " + context.getCurrentObject().getClass()); if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) { indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) { // means it needs to be cast first as well String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()"; indexStr = "ognl.OgnlOps#getIntValue(" + indexStr + toString + ")"; } context.setCurrentAccessor(target.getClass()); context.setCurrentType(target.getClass().getComponentType()); return "[" + indexStr + "]"; }
/** * Compares the {@link OgnlContext#getCurrentType()} and {@link OgnlContext#getPreviousType()} class types * on the stack to determine if a numeric expression should force object conversion. * <p/> * <p/> * Normally used in conjunction with the <code>forceConversion</code> parameter of * {@link OgnlRuntime#getChildSource(OgnlContext,Object,Node,boolean)}. * </p> * * @param context The current context. * @return True, if the class types on the stack wouldn't be comparable in a pure numeric expression such as <code>o1 >= o2</code>. */ public static boolean shouldConvertNumericTypes(OgnlContext context) { if (context.getCurrentType() == null || context.getPreviousType() == null) return true; if (context.getCurrentType() == context.getPreviousType() && context.getCurrentType().isPrimitive() && context.getPreviousType().isPrimitive()) return false; return context.getCurrentType() != null && !context.getCurrentType().isArray() && context.getPreviousType() != null && !context.getPreviousType().isArray(); }
/** * Compares the {@link OgnlContext#getCurrentType()} and {@link OgnlContext#getPreviousType()} class types * on the stack to determine if a numeric expression should force object conversion. * <p/> * <p/> * Normally used in conjunction with the <code>forceConversion</code> parameter of * {@link OgnlRuntime#getChildSource(OgnlContext,Object,Node,boolean)}. * </p> * * @param context The current context. * @return True, if the class types on the stack wouldn't be comparable in a pure numeric expression such as <code>o1 >= o2</code>. */ public static boolean shouldConvertNumericTypes(OgnlContext context) { if (context.getCurrentType() == null || context.getPreviousType() == null) return true; if (context.getCurrentType() == context.getPreviousType() && context.getCurrentType().isPrimitive() && context.getPreviousType().isPrimitive()) return false; return context.getCurrentType() != null && !context.getCurrentType().isArray() && context.getPreviousType() != null && !context.getPreviousType().isArray(); }
if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()";
if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && Number.class.isAssignableFrom(context.getCurrentType())) indexStr += "." + OgnlRuntime.getNumericValueGetter(context.getCurrentType()); } else if (context.getCurrentObject() != null && Number.class.isAssignableFrom(context.getCurrentObject().getClass()) && !context.getCurrentType().isPrimitive()) String toString = String.class.isInstance(index) && context.getCurrentType() != Object.class ? "" : ".toString()";
if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && context.getCurrentObject() != null && Number.class.isInstance(context.getCurrentObject())) } else if (context.getCurrentType() != null && context.getCurrentType().isPrimitive() && (ASTConst.class.isInstance(child) || NumericExpression.class.isInstance(child))) ret += OgnlRuntime.getNumericLiteral(context.getCurrentType()); } else if (context.getCurrentType() != null && String.class.isAssignableFrom(context.getCurrentType()))
if (context.getCurrentType() != null && !context.getCurrentType().isPrimitive() && context.getCurrentObject() != null && Number.class.isInstance(context.getCurrentObject())) } else if (context.getCurrentType() != null && context.getCurrentType().isPrimitive() && (ASTConst.class.isInstance(child) || NumericExpression.class.isInstance(child))) ret += OgnlRuntime.getNumericLiteral(context.getCurrentType()); } else if (context.getCurrentType() != null && String.class.isAssignableFrom(context.getCurrentType()))
|| context.getPreviousType() == null || context.getCurrentAccessor().isAssignableFrom(context.getPreviousType()) || (context.getCurrentType() != null && context.getCurrentObject() != null && context.getCurrentType().isAssignableFrom(context.getCurrentObject().getClass()) && context.getCurrentAccessor().isAssignableFrom(context.getPreviousType())) || body == null || body.trim().length() < 1 || (context.getCurrentType() != null && context.getCurrentType().isArray() && (context.getPreviousType() == null || context.getPreviousType() != Object.class)) || ASTOr.class.isInstance(expression)
|| context.getPreviousType() == null || context.getCurrentAccessor().isAssignableFrom(context.getPreviousType()) || (context.getCurrentType() != null && context.getCurrentObject() != null && context.getCurrentType().isAssignableFrom(context.getCurrentObject().getClass()) && context.getCurrentAccessor().isAssignableFrom(context.getPreviousType())) || body == null || body.trim().length() < 1 || (context.getCurrentType() != null && context.getCurrentType().isArray() && (context.getPreviousType() == null || context.getPreviousType() != Object.class)) || ASTOr.class.isInstance(expression)
first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); Class firstType = context.getCurrentType(); second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType()); Class secondType = context.getCurrentType();
if (context.getCurrentType() != null) { pre = "((" + OgnlRuntime.getCompiler().getInterfaceClass(context.getCurrentType()).getName() + ")"; post = ")";
if (context.getCurrentType() != null) { pre = "((" + OgnlRuntime.getCompiler().getInterfaceClass(context.getCurrentType()).getName() + ")"; post = ")";
first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); Class firstType = context.getCurrentType(); second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType()); Class secondType = context.getCurrentType();
if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive()) first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive()) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive()) first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType()); if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive()) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
/** * Returns true if this property is described by an IndexedPropertyDescriptor and that if * followed by an index specifier it will call the index get/set methods rather than go through * property accessors. */ public int getIndexedPropertyType(OgnlContext context, Object source) throws OgnlException { Class type = context.getCurrentType(); Class prevType = context.getPreviousType(); try { if (!isIndexedAccess()) { Object property = getProperty(context, source); if (property instanceof String) { return OgnlRuntime.getIndexedPropertyType(context, (source == null) ? null : OgnlRuntime.getCompiler().getInterfaceClass(source.getClass()), (String) property); } } return OgnlRuntime.INDEXED_PROPERTY_NONE; } finally { context.setCurrentObject(source); context.setCurrentType(type); context.setPreviousType(prevType); } }
/** * Returns true if this property is described by an IndexedPropertyDescriptor and that if * followed by an index specifier it will call the index get/set methods rather than go through * property accessors. */ public int getIndexedPropertyType(OgnlContext context, Object source) throws OgnlException { Class type = context.getCurrentType(); Class prevType = context.getPreviousType(); try { if (!isIndexedAccess()) { Object property = getProperty(context, source); if (property instanceof String) { return OgnlRuntime.getIndexedPropertyType(context, (source == null) ? null : OgnlRuntime.getCompiler().getInterfaceClass(source.getClass()), (String) property); } } return OgnlRuntime.INDEXED_PROPERTY_NONE; } finally { context.setCurrentObject(source); context.setCurrentType(type); context.setPreviousType(prevType); } }
+ pre + _children[1].toSetSourceString(context, target); if (!OgnlRuntime.isBoolean(second)) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
+ pre + _children[1].toSetSourceString(context, target); if (!OgnlRuntime.isBoolean(second)) second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());