/** * Ask whether the query is an updating query: that is, whether it returns a Pending Update List * rather than a Value. Note that queries using the XUpdate copy-modify syntax are not considered * to be updating queries. * * @return true if the query is an updating query, false if not * @since 9.1 */ public boolean isUpdateQuery() { return exp.isUpdateQuery(); }
/** * Ask whether the query is an updating query: that is, whether it returns a Pending Update List * rather than a Value. Note that queries using the XUpdate copy-modify syntax are not considered * to be updating queries. * * @return true if the query is an updating query, false if not * @since 9.1 */ public boolean isUpdateQuery() { return exp.isUpdateQuery(); }
/** * Evaluate the query, and return an iterator over its results. * <p>This method must not be used with an updating query.</p> * * @return an Iterator<XdmItem>. The XdmSequenceIterator class is a standard Java Iterator with an additional close() * method, which should be called to release resources if the client does not intend to read any more items * from the iterator. * * @throws SaxonApiUncheckedException if a dynamic error is detected while constructing the iterator. * It is also possible for an SaxonApiUncheckedException to be thrown by the hasNext() method of the * returned iterator if a dynamic error occurs while evaluating the result sequence. * @throws IllegalStateException if this is an updating query * @since 9.5.1.5. Previously the method returned Iterator<XdmItem>; the signature changed in Saxon 9.5.1.5 for reasons * described in bug 2016. */ public XdmSequenceIterator<XdmItem> iterator() throws SaxonApiUncheckedException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { return new XdmSequenceIterator<>(expression.iterator(context)); } catch (XPathException e) { throw new SaxonApiUncheckedException(e); } }
/** * Execute a the compiled Query, returning the results as a List of objects * obtained by converting the items in the query result to the nearest appropriate * Java type * * @param env Provides the dynamic query evaluation context * @return The results of the expression, as a List. The List represents the sequence * of items returned by the expression. Each item in the list will either be an * object representing a node, or an object representing an atomic value. * For the types of Java object that may be returned, see the description of the * {@link net.sf.saxon.xpath.XPathEvaluator#evaluate evaluate} method * of class XPathProcessor * @throws XPathException if a dynamic error occurs during query evaluation */ /*@NotNull*/ public List<Object> evaluate(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluate() on an updating query"); } ArrayList<Object> list = new ArrayList<>(100); iterator(env).forEachOrFail(item -> list.add(SequenceTool.convertToJava(item))); return list; }
/** * Evaluate the query, and return an iterator over its results. * <p>This method must not be used with an updating query.</p> * * @return an Iterator<XdmItem>. The XdmSequenceIterator class is a standard Java Iterator with an additional close() * method, which should be called to release resources if the client does not intend to read any more items * from the iterator. * * @throws SaxonApiUncheckedException if a dynamic error is detected while constructing the iterator. * It is also possible for an SaxonApiUncheckedException to be thrown by the hasNext() method of the * returned iterator if a dynamic error occurs while evaluating the result sequence. * @throws IllegalStateException if this is an updating query * @since 9.5.1.5. Previously the method returned Iterator<XdmItem>; the signature changed in Saxon 9.5.1.5 for reasons * described in bug 2016. */ public XdmSequenceIterator<XdmItem> iterator() throws SaxonApiUncheckedException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { return new XdmSequenceIterator<>(expression.iterator(context)); } catch (XPathException e) { throw new SaxonApiUncheckedException(e); } }
/** * Execute a the compiled Query, returning the results as a List of objects * obtained by converting the items in the query result to the nearest appropriate * Java type * * @param env Provides the dynamic query evaluation context * @return The results of the expression, as a List. The List represents the sequence * of items returned by the expression. Each item in the list will either be an * object representing a node, or an object representing an atomic value. * For the types of Java object that may be returned, see the description of the * {@link net.sf.saxon.xpath.XPathEvaluator#evaluate evaluate} method * of class XPathProcessor * @throws XPathException if a dynamic error occurs during query evaluation */ /*@NotNull*/ public List<Object> evaluate(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluate() on an updating query"); } ArrayList<Object> list = new ArrayList<>(100); iterator(env).forEachOrFail(item -> list.add(SequenceTool.convertToJava(item))); return list; }
/** * Perform the query, returning the results as an XdmValue. This method * must not be used with an updating query * * @return an XdmValue representing the results of the query * @throws SaxonApiException if the query fails with a dynamic error * @throws IllegalStateException if this is an updating query */ public XdmValue evaluate() throws SaxonApiException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { SequenceIterator<?> iter = expression.iterator(context); return XdmValue.wrap(iter.materialize()); } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Perform the query, returning the results as an XdmValue. This method * must not be used with an updating query * * @return an XdmValue representing the results of the query * @throws SaxonApiException if the query fails with a dynamic error * @throws IllegalStateException if this is an updating query */ public XdmValue evaluate() throws SaxonApiException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { SequenceIterator<?> iter = expression.iterator(context); return XdmValue.wrap(iter.materialize()); } catch (XPathException e) { throw new SaxonApiException(e); } }
if (expression.isUpdateQuery()) { Set<MutableNodeInfo> docs = expression.runUpdate(context); updatedDocuments = new HashSet<>();
if (expression.isUpdateQuery()) { Set<MutableNodeInfo> docs = expression.runUpdate(context); updatedDocuments = new HashSet<>();
/** * Perform the query, sending the results to a specified destination. * <p>This method must not be used with an updating query.</p> * <p>This method is designed for use with a query that produces a single node (typically * a document node or element node) as its result. If the query produces multiple nodes, * the effect depends on the kind of destination. For example, if the result is an * <code>XdmDestination</code>, only the last of the nodes will be accessible.</p> * * @param destination The destination where the result document will be sent * @throws net.sf.saxon.s9api.SaxonApiException * if any dynamic error occurs during the query * @throws IllegalStateException if this is an updating query */ public void run(Destination destination) throws SaxonApiException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { Receiver out = getDestinationReceiver(destination); expression.run(context, out, null); destination.closeAndNotify(); } catch (TransformerException e) { throw new SaxonApiException(e); } }
/** * Perform the query, sending the results to a specified destination. * <p>This method must not be used with an updating query.</p> * <p>This method is designed for use with a query that produces a single node (typically * a document node or element node) as its result. If the query produces multiple nodes, * the effect depends on the kind of destination. For example, if the result is an * <code>XdmDestination</code>, only the last of the nodes will be accessible.</p> * * @param destination The destination where the result document will be sent * @throws net.sf.saxon.s9api.SaxonApiException * if any dynamic error occurs during the query * @throws IllegalStateException if this is an updating query */ public void run(Destination destination) throws SaxonApiException { if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating"); } try { Receiver out = getDestinationReceiver(destination); expression.run(context, out, null); destination.closeAndNotify(); } catch (TransformerException e) { throw new SaxonApiException(e); } }
/** * Execute the compiled Query, returning the first item in the result. * This is useful where it is known that the expression will only return * a singleton value (for example, a single node, or a boolean). * * @param env Provides the dynamic query evaluation context * @return The first item in the sequence returned by the expression. If the expression * returns an empty sequence, this method returns null. Otherwise, it returns the first * item in the result sequence, represented as a Java object using the same mapping as for * the {@link XQueryExpression#evaluate evaluate} method * @throws XPathException if evaluation fails with a dynamic error */ /*@Nullable*/ public Object evaluateSingle(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluateSingle() on an updating query"); } SequenceIterator iterator = iterator(env); Item item = iterator.next(); if (item == null) { return null; } return SequenceTool.convertToJava(item); }
/** * Execute the compiled Query, returning the first item in the result. * This is useful where it is known that the expression will only return * a singleton value (for example, a single node, or a boolean). * * @param env Provides the dynamic query evaluation context * @return The first item in the sequence returned by the expression. If the expression * returns an empty sequence, this method returns null. Otherwise, it returns the first * item in the result sequence, represented as a Java object using the same mapping as for * the {@link XQueryExpression#evaluate evaluate} method * @throws XPathException if evaluation fails with a dynamic error */ /*@Nullable*/ public Object evaluateSingle(/*@NotNull*/ DynamicQueryContext env) throws XPathException { if (isUpdateQuery()) { throw new XPathException("Cannot call evaluateSingle() on an updating query"); } SequenceIterator iterator = iterator(env); Item item = iterator.next(); if (item == null) { return null; } return SequenceTool.convertToJava(item); }
if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating; cannot run with streaming");
if (expression.isUpdateQuery()) { throw new IllegalStateException("Query is updating; cannot run with streaming");
if (isUpdateQuery()) { throw new XPathException("Cannot call iterator() on an updating query");
if (isUpdateQuery()) { throw new XPathException("Cannot call iterator() on an updating query");
if (isUpdateQuery()) { throw new XPathException("Cannot call run() on an updating query");
if (isUpdateQuery()) { throw new XPathException("Cannot call run() on an updating query");