Package com.saxonica.xqj
Class SaxonXQPreparedExpression
- java.lang.Object
-
- com.saxonica.xqj.Closable
-
- com.saxonica.xqj.SaxonXQDynamicContext
-
- com.saxonica.xqj.SaxonXQPreparedExpression
-
- All Implemented Interfaces:
XQDynamicContext,XQPreparedExpression
public class SaxonXQPreparedExpression extends SaxonXQDynamicContext implements XQPreparedExpression
Saxon implementation of the XQJ interface XQPreparedExpression. This represents a compiled XQuery expression, together with the dynamic context for its evaluation. Note that this means the object should not be used in more than one thread concurrently.Note that an expression is scrollable or not depending on the scrollability property of the XQConnection that was used to compile this expression (at the time it was compiled). If the expression is scrollable then its results are delivered in an XQSequence that supports scrolling backwards as well as forwards.
For full Javadoc details, see the XQJ interface specification.
-
-
Field Summary
-
Fields inherited from class com.saxonica.xqj.SaxonXQDynamicContext
connection
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSaxonXQPreparedExpression(SaxonXQConnection connection, XQueryExpression expression, SaxonXQStaticContext sqc, DynamicQueryContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Attempts to cancel the execution if both the XQuery engine and XQJ driver support aborting the execution of anXQPreparedExpression.XQResultSequenceexecuteQuery()Executes the prepared query expression.protected booleanexternalVariableExists(javax.xml.namespace.QName name)javax.xml.namespace.QName[]getAllExternalVariables()Retrieves all the external variables defined in the prolog of the prepared expression.javax.xml.namespace.QName[]getAllUnboundExternalVariables()Retrieves the names of all unbound external variables.protected SaxonXQConnectiongetConnection()protected SaxonXQDataFactorygetDataFactory()protected DynamicQueryContextgetDynamicContext()protected SaxonXQStaticContextgetSaxonXQStaticContext()XQStaticContextgetStaticContext()Gets anXQStaticContextrepresenting the values for all expression properties.XQSequenceTypegetStaticResultType()Gets the static type information of the result sequence.XQSequenceTypegetStaticVariableType(javax.xml.namespace.QName name)Retrieves the static type of a given external variable.protected XQueryExpressiongetXQueryExpression()-
Methods inherited from class com.saxonica.xqj.SaxonXQDynamicContext
bindAtomicValue, bindBoolean, bindByte, bindDocument, bindDocument, bindDocument, bindDocument, bindDocument, bindDouble, bindFloat, bindInt, bindItem, bindLong, bindNode, bindObject, bindSequence, bindShort, bindString, getConfiguration, getImplicitTimeZone, setImplicitTimeZone
-
Methods inherited from class com.saxonica.xqj.Closable
close, isClosed, setClosableContainer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.xml.xquery.XQDynamicContext
bindAtomicValue, bindBoolean, bindByte, bindDocument, bindDocument, bindDocument, bindDocument, bindDocument, bindDouble, bindFloat, bindInt, bindItem, bindLong, bindNode, bindObject, bindSequence, bindShort, bindString, getImplicitTimeZone, setImplicitTimeZone
-
Methods inherited from interface javax.xml.xquery.XQPreparedExpression
close, isClosed
-
-
-
-
Constructor Detail
-
SaxonXQPreparedExpression
protected SaxonXQPreparedExpression(SaxonXQConnection connection, XQueryExpression expression, SaxonXQStaticContext sqc, DynamicQueryContext context) throws XQException
- Throws:
XQException
-
-
Method Detail
-
getDynamicContext
protected DynamicQueryContext getDynamicContext()
- Specified by:
getDynamicContextin classSaxonXQDynamicContext
-
getConnection
protected SaxonXQConnection getConnection()
-
getDataFactory
protected SaxonXQDataFactory getDataFactory() throws XQException
- Specified by:
getDataFactoryin classSaxonXQDynamicContext- Throws:
XQException
-
getXQueryExpression
protected XQueryExpression getXQueryExpression()
-
getSaxonXQStaticContext
protected SaxonXQStaticContext getSaxonXQStaticContext()
-
cancel
public void cancel() throws XQExceptionDescription copied from interface:XQPreparedExpressionAttempts to cancel the execution if both the XQuery engine and XQJ driver support aborting the execution of anXQPreparedExpression. This method can be used by one thread to cancel anXQPreparedExpression, that is being executed in another thread. If cancellation is not supported or the attempt to cancel the execution was not successful, the method returns without any error. If the cancellation is successful, anXQExceptionis thrown, to indicate that it has been aborted, byexecuteQuery,executeCommandor any method accessing theXQResultSequencereturned byexecuteQuery. If applicable, any openXQResultSequenceandXQResultItemobjects will also be implicitly closed in this case.- Specified by:
cancelin interfaceXQPreparedExpression- Throws:
XQException- if the prepared expression is in a closed state
-
executeQuery
public XQResultSequence executeQuery() throws XQException
Description copied from interface:XQPreparedExpressionExecutes the prepared query expression. Calling this method implicitly closes any previous result sequence obtained from this expression.- Specified by:
executeQueryin interfaceXQPreparedExpression- Returns:
- the xquery sequence object containing the result of the query execution
- Throws:
XQException- if (1) there are errors when executing the prepared expression, (2) the prepared expression is in a closed state, or (3) the query execution is cancelled
-
getAllExternalVariables
public javax.xml.namespace.QName[] getAllExternalVariables() throws XQExceptionDescription copied from interface:XQPreparedExpressionRetrieves all the external variables defined in the prolog of the prepared expression.- Specified by:
getAllExternalVariablesin interfaceXQPreparedExpression- Returns:
- an array of
QNameobjects for all the external variables defined in the prolog of a prepared expression. Empty array if there are no external variables present. - Throws:
XQException- if the prepared expression is in a closed state
-
getAllUnboundExternalVariables
public javax.xml.namespace.QName[] getAllUnboundExternalVariables() throws XQExceptionDescription copied from interface:XQPreparedExpressionRetrieves the names of all unbound external variables.- Specified by:
getAllUnboundExternalVariablesin interfaceXQPreparedExpression- Returns:
- the
QNamefor all the external variables defined in the prolog of a prepared expression that are yet to be bound with a value. If there are no such variables an empty array is returned - Throws:
XQException- if the prepared expression is in a closed state
-
getStaticContext
public XQStaticContext getStaticContext() throws XQException
Description copied from interface:XQPreparedExpressionGets anXQStaticContextrepresenting the values for all expression properties. Note that these properties cannot be changed; in order to change, a newXQPreparedExpressionneeds to be created.- Specified by:
getStaticContextin interfaceXQPreparedExpression- Returns:
- an
XQStaticContextrepresenting the values for all expression properties - Throws:
XQException- if the expression is in a closed state
-
getStaticResultType
public XQSequenceType getStaticResultType() throws XQException
Description copied from interface:XQPreparedExpressionGets the static type information of the result sequence. If an implementation does not do static typing of the query, then this method must return anXQSequenceTypeobject corresponding to the XQuery sequence typeitem()*.- Specified by:
getStaticResultTypein interfaceXQPreparedExpression- Returns:
XQSequenceTypecontaining the static result information.- Throws:
XQException- if the prepared expression is in a closed state
-
getStaticVariableType
public XQSequenceType getStaticVariableType(javax.xml.namespace.QName name) throws XQException
Description copied from interface:XQPreparedExpressionRetrieves the static type of a given external variable.- Specified by:
getStaticVariableTypein interfaceXQPreparedExpression- Parameters:
name- the name of the external variable- Returns:
- the static type information of the variable as defined in the prolog of the prepared expression
- Throws:
XQException- if (1) the variable does not exist in the static context of the expression, or (2) the sequence is in a closed state, or (3) thenameparameter isnull
-
externalVariableExists
protected boolean externalVariableExists(javax.xml.namespace.QName name)
- Specified by:
externalVariableExistsin classSaxonXQDynamicContext
-
-