This class represents an immutable item object obtained from an XQResultSequence using the getItem method. More...
Inherits org.zorbaxquery.api.xqj.ZorbaXQItem.
Public Member Functions | |
void | close () throws XQException |
Close the item and release all the resources associated with this item. | |
String | getAtomicValue () throws XQException |
Gets the current item as a Java String. | |
boolean | getBoolean () throws XQException |
Gets the current item as a boolean. | |
byte | getByte () throws XQException |
Gets the current item as a byte. | |
XQConnection | getConnection () throws XQException |
Gets the XQuery connection associated with this result item. | |
double | getDouble () throws XQException |
Gets the current item as a double. | |
float | getFloat () throws XQException |
Gets the current item as a float. | |
int | getInt () throws XQException |
Gets the current item as an int. | |
XMLStreamReader | getItemAsStream () throws XQException |
Read the current item as an XMLStreamReader object. | |
String | getItemAsString (Properties prprts) throws XQException |
Serializes the current item according to the XSLT 2.0 and XQuery 1.0 serialization. | |
XQItemType | getItemType () throws XQException |
Gets the type of the item. | |
long | getLong () throws XQException |
Gets the current item as a long. | |
Node | getNode () throws XQException |
Gets the item as a DOM node. | |
URI | getNodeUri () throws XQException |
Returns the URI for this item. | |
Object | getObject () throws XQException |
Gets the current item as an Object. | |
short | getShort () throws XQException |
Gets the current item as a short. | |
boolean | instanceOf (XQItemType xqit) throws XQException |
Checks if the item "matches" an item type. | |
boolean | isClosed () |
Checks if the item is closed. | |
void | writeItem (OutputStream out, Properties prprts) throws XQException |
Serializes the current item to a Writer. | |
void | writeItem (Writer writer, Properties prprts) throws XQException |
Serializes the current item to a Writer. | |
void | writeItemToResult (Result result) throws XQException |
Writes the current item to a Result. | |
void | writeItemToSAX (ContentHandler ch) throws XQException |
Writes the current item to a SAX handler. | |
ZorbaXQResultItem (Item item, XQConnection conn) |
Protected Member Functions | |
Item | getZorbaItem () |
This class represents an immutable item object obtained from an XQResultSequence using the getItem method.
A forward only result sequence does not support calling the getter methods multiple times on the same item. To work around this case, the getItem method can be used to obtain a result item and then getter methods may be called multiple times on this item.
The ZorbaXQResultItem object is dependent on the connection, expression and the sequence from which it was created and is only valid for the duration of those objects. Thus, if any one of those objects is closed, this ZorbaXQResultItem object will be implicitly closed, and it can no longer be used. Similarly re-executing the expression also implicitly closes the associated result sequences, which in turn implicitly closes this result item.
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.
Example -
Definition at line 53 of file ZorbaXQResultItem.java.
|
inline |
Definition at line 58 of file ZorbaXQResultItem.java.
|
inlineinherited |
Close the item and release all the resources associated with this item.
No method other than the isClosed or close method may be called once the item is closed. Calling close on an ZorbaXQItem object that is already closed has no effect.
XQException | - if there is an error during closing the item |
Definition at line 121 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as a Java String.
The current item must be an atomic value. This function casts the current item to an xs:string value according to the casting rules defined in 17.1.2 Casting to xs:string and xs:untypedAtomic, XQuery 1.0 and XPath 2.0 Functions and Operators, and then returns the value as a Java String.
XQException | - if (1) there are errors accessing the item's value, (2) the item is not an atomic value, (3) there is an error when casting the item to a string representation, (4) the underlying sequence or item is in a closed state, or (5) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 277 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as a boolean.
The current item must be an atomic value of type xs:boolean or a subtype.
XQException | - if (1) the conversion of the current item to a boolean fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 146 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as a byte.
The current item must be an atomic value of type xs:decimal or a subtype, and its value must be in the value space of byte.
XQException | - if (1) the conversion of the current item to a byte fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 168 of file ZorbaXQItem.java.
|
inline |
Gets the XQuery connection associated with this result item.
XQException | - if the result item is in a closed state |
Definition at line 69 of file ZorbaXQResultItem.java.
|
inlineinherited |
Gets the current item as a double.
The current item must be an atomic value of type xs:double or a subtype.
XQException | - if (1) the conversion of the current item to a double fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 192 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as a float.
The current item must be an atomic value of type xs:float or a subtype.
XQException | - if (1) the conversion of the current item to a float fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 216 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as an int.
Gets the current item as an int. The current item must be an atomic value of type xs:decimal or a subtype, and its value must be in the value space of int.
XQException | - if (1) the conversion of the current item to a int fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 240 of file ZorbaXQItem.java.
|
inlineinherited |
Read the current item as an XMLStreamReader object.
Read the current item as an XMLStreamReader object, as described in Section 12.1 Serializing an XDM instance into a StAX event stream (XMLStreamReader), XQuery API for Java (XQJ) 1.0. Note that the serialization process might fail, in which case a XQException is thrown. While the stream is being read, the application MUST NOT do any other concurrent operations on the underlying item or sequence. The operation on the stream is undefined if the underlying sequence is repositioned or the state of the underlying item or sequence is changed by concurrent operations.
XQException | - if (1) there are errors accessing the current item or the underlying sequence, (2) the underlying sequence or item is in a closed state, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, or (4) in case of an error during serialization of the current item into a StAX event stream as defined in Section 12.1 Serializing an XDM instance into a StAX event stream (XMLStreamReader), XQuery API for Java (XQJ) 1.0 |
Definition at line 584 of file ZorbaXQItem.java.
|
inlineinherited |
Serializes the current item according to the XSLT 2.0 and XQuery 1.0 serialization.
Serialization parameters, which influence how serialization is performed, can be specified. Refer to the XSLT 2.0 and XQuery 1.0 serialization and Section 12 Serialization, XQuery API for Java (XQJ) 1.0 for more information.
prprts | - specifies the serialization parameters, null is considered equivalent to an empty Properties object |
XQException | - if (1) there are errors accessing the current item or the underlying sequence, (2) the underlying sequence or item is in a closed state, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, or (4) if there are errors during serialization |
Definition at line 605 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the type of the item.
On a forward only sequence this method can be called independent of any other get or write method. It will not raise an error if such method has been called already, nor will it affect subsequent invocations of any other get or write method.
XQException | - if (1) there are errors accessing the type of the item, or (2) the underlying sequence or item is in a closed state |
Definition at line 264 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as a long.
The current item must be an atomic value of type xs:decimal or a subtype, and its value must be in the value space of long.
XQException | - if (1) the conversion of the current item to a long fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 303 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the item as a DOM node.
The current item must be a node. The type of the returned DOM node is governed by Table 7 - XQuery Node Types and Corresponding Java Object Types XQuery API for Java (XQJ) 1.0 The instance of the returned node is implementation dependent. The node may be a reference or a copy of the internal state of the item. It is advisable to make a copy of the node if the application plans to modify it.
XQException | - if (1) if there are errors accessing the current item, (2) the current item is not a node, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 327 of file ZorbaXQItem.java.
|
inlineinherited |
Returns the URI for this item.
If the item is a document node, then this method returns the absolute URI of the resource from which the document node was constructed. If the document URI is not available, then the empty string is returned. If the document URI is available, the returned value is the same as if fn:document-uri were evaluated on this document node. If the item is of a node kind other than document node, then the returned URI is implementation-defined. On a forward only sequence this method can be called independent of any other get or write method. It will not raise an error if such method has been called already, nor will it affect subsequent invocations of any other get or write method on the current item.
XQException | - if (1) if there are errors accessing the current item, (2) the current item is not a node, (3) if the underlying sequence or item is in a closed state |
Definition at line 385 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as an Object.
The data type of the returned object will be the Java Object type as specified in 14.4 Mapping an XQuery Atomic Value to a Java Object Type and 14.5 Mapping an XQuery Node to a Java Object Type, XQuery API for Java (XQJ) 1.0.
XQException | - if (1) if there are errors accessing the current item, (2) if the underlying sequence or item is in a closed state, or (3) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 424 of file ZorbaXQItem.java.
|
inlineinherited |
Gets the current item as a short.
The current item must be an atomic value of type xs:decimal or a subtype, and its value must be in the value space of short.
XQException | - if (1) the conversion of the current item to a short fails, (2) if there are errors accessing the current item, (3) if the underlying sequence or item is in a closed state, or (4) in the case of forward only sequences, a get or write method was already invoked on the current item |
Definition at line 631 of file ZorbaXQItem.java.
|
inlineprotectedinherited |
Definition at line 91 of file ZorbaXQItem.java.
|
inlineinherited |
Checks if the item "matches" an item type.
Checks if the item "matches" an item type, as defined in 2.5.4.2 Matching an Item Type and an Item, XQuery 1.0: An XML Query Language. You can use this method to first check the type of the result before calling the specific get methods.
Example -
xqit | - item type to match |
XQException | - if (1) there are errors accessing the item's type, (2) if the underlying sequence or item is in a closed state, (3) if the implementation is unable to determine the schema definition of a user defined schema type, or (4) the type parameter is null |
Definition at line 676 of file ZorbaXQItem.java.
|
inlineinherited |
Checks if the item is closed.
Definition at line 134 of file ZorbaXQItem.java.
|
inlineinherited |
Serializes the current item to a Writer.
Serializes the current item to a Writer according to XSLT 2.0 and XQuery 1.0 serialization. Serialization parameters, which influence how serialization is performed, can be specified. Refer to the XSLT 2.0 and XQuery 1.0 serialization and Section 12 Serialization, XQuery API for Java (XQJ) 1.0 for more information.
out | - the output stream into which the current item is to be serialized |
prprts | - specifies the serialization parameters, null is considered equivalent to an empty Properties object |
XQException | - if (1) there are errors accessing the current item or the underlying sequence, (2) the underlying sequence or item is in a closed state, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, (4) if there are errors during serialization, or (5) the os parameter is null |
Definition at line 690 of file ZorbaXQItem.java.
|
inlineinherited |
Serializes the current item to a Writer.
Serializes the current item to a Writer according to XSLT 2.0 and XQuery 1.0 serialization. Serialization parameters, which influence how serialization is performed, can be specified. Refer to the XSLT 2.0 and XQuery 1.0 serialization and Section 12 Serialization, XQuery API for Java (XQJ) 1.0 for more information.
Warning: When outputting to a Writer, make sure the writer's encoding matches the encoding parameter if specified as a property or the default encoding.
writer | - the output stream into which the current item is to be serialized |
prprts | - specifies the serialization parameters, null is considered equivalent to an empty Properties object |
XQException | - if (1) there are errors accessing the current item or the underlying sequence, (2) the underlying sequence or item is in a closed state, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, (4) if there are errors during serialization, or (5) the os parameter is null |
Definition at line 719 of file ZorbaXQItem.java.
|
inlineinherited |
Writes the current item to a Result.
First the item is normalized as described in XSLT 2.0 and XQuery 1.0 serialization. Subsequently it is serialized to the Result object. Note that the normalization process can fail, in which case an XQException is thrown. An XQJ implementation must at least support the following implementations:
result | - the result object into which the item is to be serialized |
XQException | - if (1) there are errors accessing the current item or the underlying sequence, (2) the underlying sequence or item is in a closed state, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, (4) in case of an error while serializing the current item into the Result object, or (5) the result parameter is null |
Definition at line 793 of file ZorbaXQItem.java.
|
inlineinherited |
Writes the current item to a SAX handler.
Writes the current item to a SAX handler, as described in in Section 12.2 Serializing an XDM instance into a SAX event stream, XQuery API for Java (XQJ) 1.0. Note that the serialization process might fail, in which case a XQException is thrown. The specified org.xml.sax.ContentHandler can optionally implement the org.xml.sax.LexicalHandler interface. An implementation must check if the specified ContentHandler implements LexicalHandler. If the handler is a LexicalHandler comment nodes are reported, otherwise they will be silently ignored.
ch | - the SAX content handler, optionally a lexical handler |
XQException | - if (1) there are errors accessing the current item or the underlying sequence, (2) the underlying sequence or item is in a closed state, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, (4) in case of an error while serializing the XDM instance into a SAX event stream, or (5) the saxhdlr parameter is null |
Definition at line 747 of file ZorbaXQItem.java.