This class describes an expression that can be prepared for multiple subsequent executions.
More...
Inherits XQPreparedExpression.
|
| void | bindAtomicValue (QName varName, String value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindBoolean (QName varName, boolean value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindByte (QName varName, byte value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindDocument (QName varName, String value, String baseURI, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindDocument (QName varName, Reader value, String baseURI, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindDocument (QName varName, InputStream value, String baseURI, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindDocument (QName varName, XMLStreamReader value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindDocument (QName varName, Source value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindDouble (QName varName, double value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindFloat (QName varName, float value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindInt (QName varName, int value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindItem (QName varName, XQItem value) throws XQException |
| | Binds a value to the given external variable. More...
|
| |
| void | bindLong (QName varName, long value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindNode (QName varName, Node value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindObject (QName varName, Object value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindSequence (QName varName, XQSequence value) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindShort (QName varName, short value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | bindString (QName varName, String value, XQItemType type) throws XQException |
| | Binds a value to the given external variable or the context item. More...
|
| |
| void | cancel () throws XQException |
| | Attempts to cancel the execution if both the XQuery engine and XQJ driver support aborting the execution of an ZorbaXQPreparedExpression. More...
|
| |
| void | close () throws XQException |
| | Closes the expression object and release all resources associated with this prepared expression. More...
|
| |
| XQResultSequence | executeQuery () throws XQException |
| | Executes the prepared query expression. More...
|
| |
| QName[] | getAllExternalVariables () throws XQException |
| | Retrieves all the external variables defined in the prolog of the prepared expression. More...
|
| |
| QName[] | getAllUnboundExternalVariables () throws XQException |
| | Retrieves the names of all unbound external variables. More...
|
| |
| TimeZone | getImplicitTimeZone () throws XQException |
| | Gets the implicit timezone. More...
|
| |
| XQStaticContext | getStaticContext () throws XQException |
| | Gets an ZorbaXQStaticContext representing the values for all expression properties. More...
|
| |
| XQSequenceType | getStaticResultType () throws XQException |
| | Gets the static type information of the result sequence. More...
|
| |
| XQSequenceType | getStaticVariableType (QName varName) throws XQException |
| | Retrieves the static type of a given external variable. More...
|
| |
| boolean | isClosed () |
| | Checks if the prepared expression in a closed state. More...
|
| |
| void | setImplicitTimeZone (TimeZone value) throws XQException |
| | Sets the implicit timezone. More...
|
| |
| | ZorbaXQPreparedExpression (XQConnection conn, String string) throws XQException |
| |
| | ZorbaXQPreparedExpression (XQConnection conn, Reader reader) throws XQException |
| |
| | ZorbaXQPreparedExpression (XQConnection conn, InputStream input) throws XQException |
| |
| | ZorbaXQPreparedExpression (XQConnection conn, String string, XQStaticContext sc) throws XQException |
| |
| | ZorbaXQPreparedExpression (XQConnection conn, Reader reader, XQStaticContext sc) throws XQException |
| |
| | ZorbaXQPreparedExpression (XQConnection conn, InputStream input, XQStaticContext sc) throws XQException |
| |
This class describes an expression that can be prepared for multiple subsequent executions.
A prepared expression can be created from the connection.
The preparation of the expression does the static analysis of the expression using the static context information.
The dynamic context information, such as values for bind variables, can then be set using the setter methods. When setting values for bind variables, these variables should be present as external variables in the prolog of the prepared expression.
The static type information of the query can also be retrieved if the XQuery implementation provides it using the getStaticResultType method.
When the expression is executed using the executeQuery method, if the execution is successful, then an ZorbaXQResultSequence object is returned. The ZorbaXQResultSequence object is tied to the ZorbaXQPreparedExpression from which it was prepared and is closed implicitly if that expression is either closed or if re-executed.
The ZorbaXQPreparedExpression object is dependent on the ZorbaXQConnection object from which it was created and is only valid for the duration of that object. Thus, if the ZorbaXQConnection object is closed then this ZorbaXQPreparedExpression object will be implicitly closed and it can no longer be used.
An XQJ driver is not required to provide finalizer methods for the connection and other objects. Hence it is strongly recommended that users call close method explicitly to free any resources. It is also recommended that they do so under a final block to ensure that the object is closed even when there are exceptions. Not closing this object implicitly or explicitly might result in serious memory leaks.
When the ZorbaXQPreparedExpression is closed any ZorbaXQResultSequence object obtained from it is also implicitly closed.
Example -
ZorbaXQConnection conn = XQDataSource.getconnection();
("for $i in (1) return 'abc' ");
ZorbaXQSequenceType type = expr.getStaticResultType();
XQSequence result1 = expr.executeQuery();
result1.next();
System.out.println(" First result1 "+ result1.getAtomicValue());
ZorbaXQResultSequence result2 = expr.executeQuery();
while (result2.next())
System.out.println(" result is "+ result2.getAtomicValue());
result2.close();
expr.close();
conn.close();
Definition at line 84 of file ZorbaXQPreparedExpression.java.
| void org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument |
( |
QName |
varName, |
|
|
String |
value, |
|
|
String |
baseURI, |
|
|
XQItemType |
type |
|
) |
| throws XQException |
|
inline |
Binds a value to the given external variable or the context item.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must be null, XQITEMKIND_DOCUMENT_ELEMENT, or XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the conversion fails, or if there is a mismatch between the static and dynamic types, an XQException is raised either by this method, or during query evaluation. If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.
- Parameters
-
| varName | - the name of the external variable to bind to, cannot be null |
| value | - the value to be converted, cannot be null |
| baseURI | - an optional base URI, can be null. It can be used, for example, to resolve relative URIs and to include in error messages. |
| type | - the type of the value for the created document node. If null is specified, it behaves as if XQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, ZorbaXQItemType.XQBASETYPE_XS_UNTYPED)) were passed in as the type parameter. That is, the type represents the XQuery sequence type document-node(element(*, xs:untyped)) |
- Exceptions
-
| XQException | - if (1) the varName or value argument is null, (2) the conversion of the value to an XDM instance failed, (3) in case of an ZorbaXQPreparedExpression, the dynamic type of the bound value is not compatible with the static type of the variable, (4) in case of an ZorbaXQPreparedExpression, the variable is not defined in the prolog of the expression, or (5) if the expression is in a closed state |
Definition at line 501 of file ZorbaXQPreparedExpression.java.
Referenced by org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument().
| void org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument |
( |
QName |
varName, |
|
|
Reader |
value, |
|
|
String |
baseURI, |
|
|
XQItemType |
type |
|
) |
| throws XQException |
|
inline |
Binds a value to the given external variable or the context item.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must be null, XQITEMKIND_DOCUMENT_ELEMENT, or XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the conversion fails, or if there is a mismatch between the static and dynamic types, an XQException is raised either by this method, or during query evaluation. If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.
- Parameters
-
| varName | - the name of the external variable to bind to, cannot be null |
| value | - the value to be converted, cannot be null |
| baseURI | - an optional base URI, can be null. It can be used, for example, to resolve relative URIs and to include in error messages. |
| type | - the type of the value for the created document node. If null is specified, it behaves as if XQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, ZorbaXQItemType.XQBASETYPE_XS_UNTYPED)) were passed in as the type parameter. That is, the type represents the XQuery sequence type document-node(element(*, xs:untyped)) |
- Exceptions
-
| XQException | - if (1) the varName or value argument is null, (2) the conversion of the value to an XDM instance failed, (3) in case of an ZorbaXQPreparedExpression, the dynamic type of the bound value is not compatible with the static type of the variable, (4) in case of an ZorbaXQPreparedExpression, the variable is not defined in the prolog of the expression, or (5) if the expression is in a closed state |
Definition at line 543 of file ZorbaXQPreparedExpression.java.
References org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument().
| void org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument |
( |
QName |
varName, |
|
|
InputStream |
value, |
|
|
String |
baseURI, |
|
|
XQItemType |
type |
|
) |
| throws XQException |
|
inline |
Binds a value to the given external variable or the context item.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must be null, XQITEMKIND_DOCUMENT_ELEMENT, or XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the conversion fails, or if there is a mismatch between the static and dynamic types, an XQException is raised either by this method, or during query evaluation. If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.
- Parameters
-
| varName | - the name of the external variable to bind to, cannot be null |
| value | - the value to be converted, cannot be null |
| baseURI | - an optional base URI, can be null. It can be used, for example, to resolve relative URIs and to include in error messages. |
| type | - the type of the value for the created document node. If null is specified, it behaves as if XQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, ZorbaXQItemType.XQBASETYPE_XS_UNTYPED)) were passed in as the type parameter. That is, the type represents the XQuery sequence type document-node(element(*, xs:untyped)) |
- Exceptions
-
| XQException | - if (1) the varName or value argument is null, (2) the conversion of the value to an XDM instance failed, (3) in case of an ZorbaXQPreparedExpression, the dynamic type of the bound value is not compatible with the static type of the variable, (4) in case of an ZorbaXQPreparedExpression, the variable is not defined in the prolog of the expression, or (5) if the expression is in a closed state |
Definition at line 589 of file ZorbaXQPreparedExpression.java.
References org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument().
| void org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument |
( |
QName |
varName, |
|
|
XMLStreamReader |
value, |
|
|
XQItemType |
type |
|
) |
| throws XQException |
|
inline |
Binds a value to the given external variable or the context item.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must be null, XQITEMKIND_DOCUMENT_ELEMENT, or XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the conversion fails, or if there is a mismatch between the static and dynamic types, an XQException is raised either by this method, or during query evaluation. If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.
- Parameters
-
| varName | - the name of the external variable to bind to, cannot be null |
| value | - the value to be converted, cannot be null |
| type | - the type of the value for the created document node. If null is specified, it behaves as if XQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, ZorbaXQItemType.XQBASETYPE_XS_UNTYPED)) were passed in as the type parameter. That is, the type represents the XQuery sequence type document-node(element(*, xs:untyped)) |
- Exceptions
-
| XQException | - if (1) the varName or value argument is null, (2) the conversion of the value to an XDM instance failed, (3) in case of an ZorbaXQPreparedExpression, the dynamic type of the bound value is not compatible with the static type of the variable, (4) in case of an ZorbaXQPreparedExpression, the variable is not defined in the prolog of the expression, or (5) if the expression is in a closed state |
Definition at line 628 of file ZorbaXQPreparedExpression.java.
References org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument().
| void org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument |
( |
QName |
varName, |
|
|
Source |
value, |
|
|
XQItemType |
type |
|
) |
| throws XQException |
|
inline |
Binds a value to the given external variable or the context item.
Binds a value to the given external variable or the context item from the given Source. An XQJ implementation must at least support the following implementations:
- javax.xml.transform.dom.DOMSource
- javax.xml.transform.sax.SAXSource
- javax.xml.transform.stream.StreamSource
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must be null, XQITEMKIND_DOCUMENT_ELEMENT, or XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the conversion fails, or if there is a mismatch between the static and dynamic types, an XQException is raised either by this method, or during query evaluation. If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.
- Parameters
-
| varName | - the name of the external variable to bind to, cannot be null |
| value | - the value to be converted, cannot be null |
| type | - the type of the value for the created document node. If null is specified, it behaves as if XQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, ZorbaXQItemType.XQBASETYPE_XS_UNTYPED)) were passed in as the type parameter. That is, the type represents the XQuery sequence type document-node(element(*, xs:untyped)) |
- Exceptions
-
| XQException | - if (1) the varName or value argument is null, (2) the conversion of the value to an XDM instance failed, (3) in case of an ZorbaXQPreparedExpression, the dynamic type of the bound value is not compatible with the static type of the variable, (4) in case of an ZorbaXQPreparedExpression, the variable is not defined in the prolog of the expression, or (5) if the expression is in a closed state |
Definition at line 691 of file ZorbaXQPreparedExpression.java.
References org.zorbaxquery.api.xqj.ZorbaXQPreparedExpression.bindDocument().