public ZeroOrMore(SequenceIterator<? extends T> iter) throws XPathException { content = new ArrayList<T>(); iter.forEachOrFail(content::add); }
/** * Create an AtomicArray supplying the contents as an iterator * * @param iter the iterator that supplies the atomic values (which must be position * at the start of the sequence, and which will be consumed by the method). * @throws XPathException if evaluation of the SequenceIterator fails * @throws ClassCastException if any of the items returned by the SequenceIterator is not atomic */ public AtomicArray(SequenceIterator<? extends AtomicValue> iter) throws XPathException { ArrayList<AtomicValue> list = new ArrayList<>(10); iter.forEachOrFail(list::add); content = list; }
/** * Create an AtomicArray supplying the contents as an iterator * * @param iter the iterator that supplies the atomic values (which must be position * at the start of the sequence, and which will be consumed by the method). * @throws XPathException if evaluation of the SequenceIterator fails * @throws ClassCastException if any of the items returned by the SequenceIterator is not atomic */ public AtomicArray(SequenceIterator<? extends AtomicValue> iter) throws XPathException { ArrayList<AtomicValue> list = new ArrayList<>(10); iter.forEachOrFail(list::add); content = list; }
public static <T extends Item<?>> OneOrMore<T> makeOneOrMore(Sequence<T> sequence) throws XPathException { List<T> content = new ArrayList<>(); sequence.iterate().forEachOrFail(content::add); if (content.isEmpty()) { throw new IllegalArgumentException(); } return new OneOrMore<>(content); }
public static <T extends Item<?>> OneOrMore<T> makeOneOrMore(Sequence<T> sequence) throws XPathException { List<T> content = new ArrayList<>(); sequence.iterate().forEachOrFail(content::add); if (content.isEmpty()) { throw new IllegalArgumentException(); } return new OneOrMore<>(content); }
/** * Get the nodes with a given composite key value * * @param soughtValue The required composite key value * @return a list of the selected nodes, always in document order with no duplicates, or null * to represent an empty list * @throws XPathException if a dynamic error is encountered */ public List<NodeInfo> getComposite(SequenceIterator<?> soughtValue) throws XPathException { List<AtomicMatchKey> amks = new ArrayList<>(4); soughtValue.forEachOrFail( keyVal -> amks.add(getCollationKey((AtomicValue)keyVal, collation, implicitTimezone))); return index.get(new CompositeAtomicMatchKey(amks)); }
/** * Execute the expression, returning the result as a List, whose members will be instances * of the class {@link net.sf.saxon.om.Item} * * @param context the XPath dynamic context * @return a list of items representing the result of the expression * @throws XPathException if a dynamic error occurs while evaluation the expression */ public List<Item<?>> evaluate(XPathDynamicContext context) throws XPathException { List<Item<?>> list = new ArrayList<>(20); expression.iterate(context.getXPathContextObject()).forEachOrFail(list::add); return list; }
/** * Execute the expression, returning the result as a List, whose members will be instances * of the class {@link net.sf.saxon.om.Item} * * @param context the XPath dynamic context * @return a list of items representing the result of the expression * @throws XPathException if a dynamic error occurs while evaluation the expression */ public List<Item<?>> evaluate(XPathDynamicContext context) throws XPathException { List<Item<?>> list = new ArrayList<>(20); expression.iterate(context.getXPathContextObject()).forEachOrFail(list::add); return list; }
private void flatten(Sequence<?> arg, List<Item<?>> out) throws XPathException { arg.iterate().forEachOrFail(item -> { if (item instanceof ArrayItem) { for (Sequence<?> member : ((ArrayItem) item).members()) { flatten(member, out); } } else { out.add(item); } }); }
private void flatten(Sequence<?> arg, List<Item<?>> out) throws XPathException { arg.iterate().forEachOrFail(item -> { if (item instanceof ArrayItem) { for (Sequence<?> member : ((ArrayItem) item).members()) { flatten(member, out); } } else { out.add(item); } }); }
/** * Helper method for subclasses to invoke if required: flatten an array */ protected void flatten(ArrayItem array, Location locationId, int copyNamespaces) throws XPathException { for (Sequence<?> member : array.members()) { member.iterate().forEachOrFail(it -> append(it, locationId, copyNamespaces)); } }
/** * Helper method for subclasses to invoke if required: flatten an array */ protected void flatten(ArrayItem array, Location locationId, int copyNamespaces) throws XPathException { for (Sequence<?> member : array.members()) { member.iterate().forEachOrFail(it -> append(it, locationId, copyNamespaces)); } }
/** * Process this expression as an instruction, writing results to the current * outputter */ public void process(XPathContext context) throws XPathException { int slot = getLocalSlotNumber(); getSequence().iterate(context).forEachOrFail(item -> { context.setLocalVariable(slot, item); getAction().process(context); }); }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public final void process(XPathContext context) throws XPathException { SequenceIterator<?> iter = call(context, evaluateArguments(context)).iterate(); iter.forEachOrFail( it -> context.getReceiver().append(it, getLocation(), ReceiverOptions.ALL_NAMESPACES) ); }
/** * Process this expression as an instruction, writing results to the current * outputter */ public void process(XPathContext context) throws XPathException { int slot = getLocalSlotNumber(); getSequence().iterate(context).forEachOrFail(item -> { context.setLocalVariable(slot, item); getAction().process(context); }); }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public final void process(XPathContext context) throws XPathException { SequenceIterator<?> iter = call(context, evaluateArguments(context)).iterate(); iter.forEachOrFail( it -> context.getReceiver().append(it, getLocation(), ReceiverOptions.ALL_NAMESPACES) ); }
public void process(XPathContext c) throws XPathException { try { SequenceIterator<?> iter = evaluateVariable(c).iterate(); Receiver out = c.getReceiver(); Location loc = getLocation(); iter.forEachOrFail(item -> out.append(item, loc, ReceiverOptions.ALL_NAMESPACES)); } catch (XPathException err) { err.maybeSetLocation(getLocation()); throw err; } }
@Override public TailCall processLeavingTail(XPathContext context) throws XPathException { Receiver out = context.getReceiver(); try (SequenceIterator<?> iter = iterate(context)) { iter.forEachOrFail(it -> out.append(it, getLocation(), ReceiverOptions.ALL_NAMESPACES)); } catch (XPathException e) { e.maybeSetLocation(getLocation()); e.maybeSetContext(context); throw e; } return null; }
public void process(XPathContext c) throws XPathException { try { SequenceIterator<?> iter = evaluateVariable(c).iterate(); Receiver out = c.getReceiver(); Location loc = getLocation(); iter.forEachOrFail(item -> out.append(item, loc, ReceiverOptions.ALL_NAMESPACES)); } catch (XPathException err) { err.maybeSetLocation(getLocation()); throw err; } }
@Override public TailCall processLeavingTail(XPathContext context) throws XPathException { Receiver out = context.getReceiver(); try (SequenceIterator<?> iter = iterate(context)) { iter.forEachOrFail(it -> out.append(it, getLocation(), ReceiverOptions.ALL_NAMESPACES)); } catch (XPathException e) { e.maybeSetLocation(getLocation()); e.maybeSetContext(context); throw e; } return null; }