assertArgCount(2); String key = InfoSetUtil.stringValue(getArg1().computeValue(context)); Object value = getArg2().compute(context); EvalContext ec = null; if (value instanceof EvalContext) {
/** * concat() implementation. * @param context evaluation context * @return String */ protected Object functionConcat(EvalContext context) { if (getArgumentCount() < 2) { assertArgCount(2); } StringBuffer buffer = new StringBuffer(); Expression[] args = getArguments(); for (int i = 0; i < args.length; i++) { buffer.append(InfoSetUtil.stringValue(args[i].compute(context))); } return buffer.toString(); }
/** * Iterate over the values from the specified context. * @param context evaluation context * @return value Iterator */ public Iterator iterate(EvalContext context) { Object result = compute(context); if (result instanceof EvalContext) { return new ValueIterator((EvalContext) result); } if (result instanceof NodeSet) { return new ValueIterator(((NodeSet) result).getPointers().iterator()); } return ValueUtils.iterate(result); }
public Object computeValue(EvalContext context) { EvalContext[] argCtxs = new EvalContext[args.length]; for (int i = 0; i < args.length; i++) { Object value = args[i].compute(context); if (value instanceof EvalContext) { argCtxs[i] = (EvalContext) value; } else { argCtxs[i] = context.getRootContext().getConstantContext(value); } } return new UnionContext(context.getRootContext(), argCtxs); }
/** * sum() implementation. * @param context evaluation context * @return Number */ protected Object functionSum(EvalContext context) { assertArgCount(1); Object v = getArg1().compute(context); if (v == null) { return ZERO; } if (v instanceof EvalContext) { double sum = 0.0; EvalContext ctx = (EvalContext) v; while (ctx.hasNext()) { NodePointer ptr = (NodePointer) ctx.next(); sum += InfoSetUtil.doubleValue(ptr); } return new Double(sum); } throw new JXPathException( "Invalid argument type for 'sum': " + v.getClass().getName()); }
Expression arg1 = getArg1(); int count = 0; Object value = arg1.compute(context); if (value instanceof NodePointer) { value = ((NodePointer) value).getValue();
public Object computeValue(EvalContext context) { Object[] parameters = null; if (args != null) { parameters = new Object[args.length]; for (int i = 0; i < args.length; i++) { parameters[i] = convert(args[i].compute(context)); } } Function function = context.getRootContext().getFunction(functionName, parameters); if (function == null) { throw new JXPathFunctionNotFoundException("No such function: " + functionName + Arrays.asList(parameters)); } Object result = function.invoke(context, parameters); return result instanceof NodeSet ? new NodeSetContext(context, (NodeSet) result) : result; }
/** * Iterate over the pointers from the specified context. * @param context evaluation context * @return pointer Iterator */ public Iterator iteratePointers(EvalContext context) { Object result = compute(context); if (result == null) { return Collections.EMPTY_LIST.iterator(); } if (result instanceof EvalContext) { return (EvalContext) result; } if (result instanceof NodeSet) { return new PointerIterator(((NodeSet) result).getPointers().iterator(), new QName(null, "value"), context.getRootContext().getCurrentNodePointer().getLocale()); } return new PointerIterator(ValueUtils.iterate(result), new QName(null, "value"), context.getRootContext().getCurrentNodePointer().getLocale()); }
/** * namespace-uri() implementation. * @param context evaluation context * @return String */ protected Object functionNamespaceURI(EvalContext context) { if (getArgumentCount() == 0) { NodePointer ptr = context.getCurrentNodePointer(); String str = ptr.getNamespaceURI(); return str == null ? "" : str; } assertArgCount(1); Object set = getArg1().compute(context); if (set instanceof EvalContext) { EvalContext ctx = (EvalContext) set; if (ctx.hasNext()) { NodePointer ptr = (NodePointer) ctx.next(); String str = ptr.getNamespaceURI(); return str == null ? "" : str; } } return ""; }
/** * name() implementation. * @param context evaluation context * @return String */ protected Object functionName(EvalContext context) { if (getArgumentCount() == 0) { NodePointer ptr = context.getCurrentNodePointer(); return ptr.getName().toString(); } assertArgCount(1); Object set = getArg1().compute(context); if (set instanceof EvalContext) { EvalContext ctx = (EvalContext) set; if (ctx.hasNext()) { NodePointer ptr = (NodePointer) ctx.next(); return ptr.getName().toString(); } } return ""; }
/** * local-name() implementation. * @param context evaluation context * @return String */ protected Object functionLocalName(EvalContext context) { if (getArgumentCount() == 0) { NodePointer ptr = context.getCurrentNodePointer(); return ptr.getName().getName(); } assertArgCount(1); Object set = getArg1().compute(context); if (set instanceof EvalContext) { EvalContext ctx = (EvalContext) set; if (ctx.hasNext()) { NodePointer ptr = (NodePointer) ctx.next(); return ptr.getName().getName(); } } return ""; }
Object value = expression.compute(evalContext); EvalContext context; if (value instanceof InitialContext) {