public NumberEnumerator(object target) { type = OgnlOps.getNumericType(target); finish = OgnlOps.longValue(target); }
protected override object getValueBody(OgnlContext context, object source) // throws OgnlException { object result, root = context.getRoot(); int count = jjtGetNumChildren(); object[] args = OgnlRuntime.getObjectArrayPool().create(count); try { for (int i = 0; i < count; ++i) { args[i] = children[i].getValue(context, root); } if (isArray) { if (args.Length == 1) { try { Type componentClass = OgnlRuntime.classForName(context, className); IList sourceList = null; int size; if (args[0] is IList) { sourceList = (IList)args[0]; size = sourceList.Count; } else { size = (int)OgnlOps.longValue(args[0]); } result = Array.CreateInstance(componentClass, size); if (sourceList != null) { TypeConverter converter = context.getTypeConverter(); for (int i = 0, icount = sourceList.Count; i < icount; i++) { object o = sourceList [i]; if ((o == null) || componentClass.IsInstanceOfType(o)) { ((Array)result).SetValue(o, i); } else { ((Array)result).SetValue(converter.convertValue(context, null, null, null, o, componentClass), i); } } } } catch (TypeLoadException ex) { throw new OgnlException("array component class '" + className + "' not found", ex); } } else { throw new OgnlException("only expect array size or fixed initializer list"); } } else { result = OgnlRuntime.callConstructor(context, className, args); } return(result); } finally { OgnlRuntime.getObjectArrayPool().recycle(args); } }