Package com.saxonica.xqj
Class SaxonXQForwardSequence
- java.lang.Object
-
- com.saxonica.xqj.Closable
-
- com.saxonica.xqj.SaxonXQForwardSequence
-
- All Implemented Interfaces:
XQItemAccessor,XQResultSequence,XQSequence
public class SaxonXQForwardSequence extends Closable implements XQResultSequence
The class is a Saxon implementation of the XQJ interface XQResultSequence. This implementation is used to represent a sequence that can only be read in a forwards direction.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSaxonXQForwardSequence(FocusTrackingIterator iterator, SaxonXQPreparedExpression expression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanabsolute(int itempos)Moves theXQSequence's position to the given item number in this object.voidafterLast()Move to the position after the last item.voidbeforeFirst()Moves to the position before the first item.intcount()Returns a number indicating the number of items in the sequence.booleanfirst()Moves to the first item in the sequence.java.lang.StringgetAtomicValue()Gets the current item as a JavaString.booleangetBoolean()Gets the current item as aboolean.bytegetByte()Gets the current item as abyte.XQConnectiongetConnection()Gets the XQuery connection associated with this result sequencedoublegetDouble()Gets the current item as adouble.floatgetFloat()Gets the current item as afloat.intgetInt()Gets the current item as anint.XQItemgetItem()Get the current item as an immutableXQItemobject.javax.xml.stream.XMLStreamReadergetItemAsStream()Read the current item as anXMLStreamReaderobject, as described in Section 12.1 Serializing an XDM instance into a StAX event stream (XMLStreamReader), XQuery API for Java (XQJ) 1.0.java.lang.StringgetItemAsString(java.util.Properties props)Serializes the current item according to the XSLT 2.0 and XQuery 1.0 serialization.XQItemTypegetItemType()Gets the type of the item.longgetLong()Gets the current item as along.org.w3c.dom.NodegetNode()Gets the item as a DOM node.java.net.URIgetNodeUri()Returns the URI for this item.java.lang.ObjectgetObject()Gets the current item as anObject.intgetPosition()Gets the current cursor position.javax.xml.stream.XMLStreamReadergetSequenceAsStream()Read the entire sequence starting from the current position as anXMLStreamReaderobject, as described in Section 12.1 Serializing an XDM instance into a StAX event stream (XMLStreamReader), XQuery API for Java (XQJ) 1.0.java.lang.StringgetSequenceAsString(java.util.Properties props)Serializes the sequence starting from the current position to a String according to the XSLT 2.0 and XQuery 1.0 serialization.shortgetShort()Gets the current item as ashort.booleaninstanceOf(XQItemType 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.booleanisAfterLast()Checks if the current position is after the last item in the sequence.booleanisBeforeFirst()Checks if the current position before the first item in the sequence.booleanisFirst()Checks if the current position at the first item in the sequence.booleanisLast()Checks if the current position at the last item in the sequence.booleanisOnItem()Check if the sequence is positioned on an item or not.booleanisScrollable()Checks if the sequence is scrollable.booleanlast()Moves to the last item in the sequence.booleannext()Moves to the next item in the sequence.booleanprevious()Moves to the previous item in the sequence.booleanrelative(int itempos)Moves the cursor a relative number of items, either positive or negative.voidwriteItem(java.io.OutputStream os, java.util.Properties props)Serializes the current item to aWriteraccording to XSLT 2.0 and XQuery 1.0 serialization.voidwriteItem(java.io.Writer ow, java.util.Properties props)Serializes the current item to aWriteraccording to XSLT 2.0 and XQuery 1.0 serialization.voidwriteItemToResult(javax.xml.transform.Result result)Writes the current item to aResult.voidwriteItemToSAX(org.xml.sax.ContentHandler saxHandler)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.voidwriteSequence(java.io.OutputStream os, java.util.Properties props)Serializes the sequence starting from the current position to anOutputStreamaccording to the XSLT 2.0 and XQuery 1.0 serialization.voidwriteSequence(java.io.Writer ow, java.util.Properties props)Serializes the sequence starting from the current position to a Writer according to the XSLT 2.0 and XQuery 1.0 serialization.voidwriteSequenceToResult(javax.xml.transform.Result result)Writes the entire sequence starting from the current position to aResult.voidwriteSequenceToSAX(org.xml.sax.ContentHandler saxHandler)Writes the entire sequence starting from the current position to a SAX handler, as described in Section 12.2 Serializing an XDM instance into a SAX event stream, XQuery API for Java (XQJ) 1.0.-
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.XQSequence
close, isClosed
-
-
-
-
Constructor Detail
-
SaxonXQForwardSequence
protected SaxonXQForwardSequence(FocusTrackingIterator iterator, SaxonXQPreparedExpression expression)
-
-
Method Detail
-
getConnection
public XQConnection getConnection() throws XQException
Description copied from interface:XQResultSequenceGets the XQuery connection associated with this result sequence- Specified by:
getConnectionin interfaceXQResultSequence- Returns:
- the connection associated with this result sequence
- Throws:
XQException- if the result sequence is in a closed state
-
getAtomicValue
public java.lang.String getAtomicValue() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as a JavaString. The current item must be an atomic value. This function casts the current item to anxs:stringvalue 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 JavaString.- Specified by:
getAtomicValuein interfaceXQItemAccessor- Returns:
- the string representation of the item
- Throws:
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
-
getBoolean
public boolean getBoolean() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as aboolean. The current item must be an atomic value of typexs:booleanor a subtype.- Specified by:
getBooleanin interfaceXQItemAccessor- Returns:
- a
booleanrepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to abooleanfails, (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
-
getByte
public byte getByte() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as abyte. The current item must be an atomic value of typexs:decimalor a subtype, and its value must be in the value space ofbyte.- Specified by:
getBytein interfaceXQItemAccessor- Returns:
- a
byterepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to abytefails, (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
-
getDouble
public double getDouble() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as adouble. The current item must be an atomic value of typexs:doubleor a subtype.- Specified by:
getDoublein interfaceXQItemAccessor- Returns:
- a
doublerepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to adoublefails, (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
-
getFloat
public float getFloat() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as afloat. The current item must be an atomic value of typexs:floator a subtype.- Specified by:
getFloatin interfaceXQItemAccessor- Returns:
- a
floatrepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to afloatfails, (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
-
getInt
public int getInt() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as anint. The current item must be an atomic value of typexs:decimalor a subtype, and its value must be in the value space ofint.- Specified by:
getIntin interfaceXQItemAccessor- Returns:
- an
intrepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to aintfails, (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
-
getItemAsStream
public javax.xml.stream.XMLStreamReader getItemAsStream() throws XQExceptionDescription copied from interface:XQItemAccessorRead the current item as anXMLStreamReaderobject, 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 aXQExceptionis 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.- Specified by:
getItemAsStreamin interfaceXQItemAccessor- Returns:
- an XML reader object as
XMLStreamReader - Throws:
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
-
getItemAsString
public java.lang.String getItemAsString(java.util.Properties props) throws XQExceptionDescription copied from interface:XQItemAccessorSerializes 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.- Specified by:
getItemAsStringin interfaceXQItemAccessor- Parameters:
props- specifies the serialization parameters,nullis considered equivalent to an emptyPropertiesobject- Returns:
- the serialized representation of the item
- Throws:
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
-
getItemType
public XQItemType getItemType() throws XQException
Description copied from interface:XQItemAccessorGets 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.- Specified by:
getItemTypein interfaceXQItemAccessor- Returns:
- the type of the item
- Throws:
XQException- if (1) there are errors accessing the type of the item, or (2) the underlying sequence or item is in a closed state
-
getLong
public long getLong() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as along. The current item must be an atomic value of typexs:decimalor a subtype, and its value must be in the value space oflong.- Specified by:
getLongin interfaceXQItemAccessor- Returns:
- a
longrepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to alongfails, (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
-
getNode
public org.w3c.dom.Node getNode() throws XQExceptionDescription copied from interface:XQItemAccessorGets 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.- Specified by:
getNodein interfaceXQItemAccessor- Returns:
- a DOM node representing the current item
- Throws:
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
-
getNodeUri
public java.net.URI getNodeUri() throws XQExceptionDescription copied from interface:XQItemAccessorReturns 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 iffn:document-uriwere 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.- Specified by:
getNodeUriin interfaceXQItemAccessor- Returns:
- the document URI for this document node or the empty string if not available. For other node kinds, the result is implementation-defined
- Throws:
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
-
getObject
public java.lang.Object getObject() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as anObject. The data type of the returned object will be the JavaObjecttype 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.- Specified by:
getObjectin interfaceXQItemAccessor- Returns:
- an object representing the current item
- Throws:
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
-
getShort
public short getShort() throws XQExceptionDescription copied from interface:XQItemAccessorGets the current item as ashort. The current item must be an atomic value of typexs:decimalor a subtype, and its value must be in the value space ofshort.- Specified by:
getShortin interfaceXQItemAccessor- Returns:
- a
shortrepresenting the current item - Throws:
XQException- if (1) the conversion of the current item to ashortfails, (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
-
instanceOf
public boolean instanceOf(XQItemType type) throws XQException
Description copied from interface:XQItemAccessorChecks 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 -... XQItemType strType = conn.createAtomicType(XQItemType.XQBASETYPE_STRING); XQItemType nodeType = conn.createNodeType(); XQSequence result = preparedExpr.executeQuery(); while (result.next()) { // Generic check for node.. if (result.instanceOf(nodeType)) org.w3.dom.Node node = result.getNode(); else if (result.instanceOf(strType)) String str = result.getAtomicValue(); }
If either the type of theXQItemAccessoror the inputXQItemTypeis not a built-in type, then this method is allowed to raise exception if it can NOT determine the instanceOf relationship due to the lack of the access of the XML schema that defines the user defined schema types if theXQMetaData.isUserDefinedXMLSchemaTypeSupported()method returnsfalse.
Otherwise, this method must determine if the type of theXQItemAccessoris an instance of the inputXQItemType. Note even ifisUserDefinedXMLSchemaTypeSupported()returnsfalse, an XQJ implementation may still be able to determine the instanceOf relationship for certain cases involving user defined schema type. For example, if the type of anXQItemAccessoris ofmySchema:hatSizesequence type and the input parameterXQItemTypeis ofitem()sequence type, the return value for instanceOf relationship should always betrueeven though the XQJ implementation does not know the precise type information ofmySchema:hatSizetype defined in XML schema'mySchema'.- Specified by:
instanceOfin interfaceXQItemAccessor- Parameters:
type- item type to match- Returns:
trueif this item matches the input item type as defined in 2.5.4.2 Matching an Item Type and an Item, XQuery 1.0: An XML Query Language, andfalseif it does not- Throws:
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) thetypeparameter isnull
-
writeItem
public void writeItem(java.io.OutputStream os, java.util.Properties props) throws XQExceptionDescription copied from interface:XQItemAccessorSerializes the current item to aWriteraccording 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.- Specified by:
writeItemin interfaceXQItemAccessor- Parameters:
os- the output stream into which the current item is to be serializedprops- specifies the serialization parameters,nullis considered equivalent to an emptyPropertiesobject- Throws:
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) theosparameter isnull
-
writeItem
public void writeItem(java.io.Writer ow, java.util.Properties props) throws XQExceptionDescription copied from interface:XQItemAccessorSerializes the current item to aWriteraccording 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 aWriter, make sure the writer's encoding matches the encoding parameter if specified as a property or the default encoding.- Specified by:
writeItemin interfaceXQItemAccessor- Parameters:
ow- the writer object into which the current item is to be serializedprops- specifies the serialization parameters,nullis considered equivalent to an emptyPropertiesobject- Throws:
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) theowparameter isnull
-
writeItemToResult
public void writeItemToResult(javax.xml.transform.Result result) throws XQExceptionDescription copied from interface:XQItemAccessorWrites the current item to aResult. First the item is normalized as described in XSLT 2.0 and XQuery 1.0 serialization. Subsequently it is serialized to theResultobject.
Note that the normalization process can fail, in which case anXQExceptionis thrown. An XQJ implementation must at least support the following implementations:javax.xml.transform.dom.DOMResultjavax.xml.transform.sax.SAXResultjavax.xml.transform.stream.StreamResult
- Specified by:
writeItemToResultin interfaceXQItemAccessor- Parameters:
result- the result object into which the item is to be serialized- Throws:
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 theResultobject, or (5) theresultparameter isnull
-
writeItemToSAX
public void writeItemToSAX(org.xml.sax.ContentHandler saxHandler) throws XQExceptionDescription copied from interface:XQItemAccessorWrites 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 aXQExceptionis thrown. The specifiedorg.xml.sax.ContentHandlercan optionally implement theorg.xml.sax.LexicalHandlerinterface. An implementation must check if the specifiedContentHandlerimplementsLexicalHandler. If the handler is aLexicalHandlercomment nodes are reported, otherwise they will be silently ignored.- Specified by:
writeItemToSAXin interfaceXQItemAccessor- Parameters:
saxHandler- the SAX content handler, optionally a lexical handler- Throws:
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) thesaxhdlrparameter isnull
-
absolute
public boolean absolute(int itempos) throws XQExceptionDescription copied from interface:XQSequenceMoves theXQSequence's position to the given item number in this object. If the item number is positive, theXQSequencemoves to the given item number with respect to the beginning of theXQSequence.The first item is item 1, the second is item 2, and so on.
If the given item number is negative, the
For example, calling the methodXQSequencepositions itself on an absolute item position with respect to the end of the sequence.absolute(-1)positions theXQSequenceon the last item; calling the methodabsolute(-2)moves theXQSequenceto the next-to-last item, and so on.absolute(0)will position the sequence before the first item. An attempt to position the sequence beyond the first/last item set leaves the current position to be before the first item or after the last item.
Calling this method on an empty sequence will returnfalse.- Specified by:
absolutein interfaceXQSequence- Parameters:
itempos- the item position to jump to- Returns:
trueif the current position is within the sequence,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
afterLast
public void afterLast() throws XQExceptionDescription copied from interface:XQSequenceMove to the position after the last item.- Specified by:
afterLastin interfaceXQSequence- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
beforeFirst
public void beforeFirst() throws XQExceptionDescription copied from interface:XQSequenceMoves to the position before the first item.- Specified by:
beforeFirstin interfaceXQSequence- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
count
public int count() throws XQExceptionDescription copied from interface:XQSequenceReturns a number indicating the number of items in the sequence.- Specified by:
countin interfaceXQSequence- Returns:
- the number of items in this sequence
- Throws:
XQException- if (1) the sequence is forward-only, or (2) the sequence is closed
-
first
public boolean first() throws XQExceptionDescription copied from interface:XQSequenceMoves to the first item in the sequence. The method returnstrue, if it was able to move to the first item in the sequencefalse, otherwise. Calling this method on an empty sequence will returnfalse.- Specified by:
firstin interfaceXQSequence- Returns:
trueif the sequence was positioned on the first item,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
getItem
public XQItem getItem() throws XQException
Description copied from interface:XQSequenceGet the current item as an immutableXQItemobject. In case of anXQResultSequence, the item is anXQResultItem. In the case of forward only sequences, this method or any other get or write method may only be called once on the curent item.
TheXQItemobject is dependent on the sequence from which it was created and is only valid for the duration ofXQSequencelifetime. Thus, theXQSequenceis closed, thisXQItemobject will be implicitly closed and it can no longer be used.- Specified by:
getItemin interfaceXQSequence- Returns:
- an
XQItemobject - Throws:
XQException- if (1) there are errors retrieving the item, or (2) in the case of a forward only sequence, a get or write method has already been invoked on the current item.
-
getPosition
public int getPosition() throws XQExceptionDescription copied from interface:XQSequenceGets the current cursor position.0 indicates that the position is before the first item and
count() + 1indicates position after the last item. A specific position indicates that the cursor is positioned on the item at that position. Use theisOnItemmethod to verify if the cursor is positioned on the item.
Calling this method on an empty sequence will return0.- Specified by:
getPositionin interfaceXQSequence- Throws:
XQException- if (1) the sequence is forward-only, or (2) the sequence is closed
-
getSequenceAsStream
public javax.xml.stream.XMLStreamReader getSequenceAsStream() throws XQExceptionDescription copied from interface:XQSequenceRead the entire sequence starting from the current position as anXMLStreamReaderobject, 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 aXQExceptionis thrown. While the stream is being read, the application MUST NOT do any other concurrent operations on the sequence. The operation on the stream is undefined if the underlying sequence position or state is changed by concurrent operations. After all items are written to the stream, the current position of the cursor is set to point after the last item. Also, in the case of forward only sequences, this method may only be called if the current item has not yet been read through any of the get or write methods.- Specified by:
getSequenceAsStreamin interfaceXQSequence- Returns:
- an XML reader object as
XMLStreamReader - Throws:
XQException- if (1) there are errors accessing any of the items in the sequence, (2) the sequence 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 sequence 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
-
getSequenceAsString
public java.lang.String getSequenceAsString(java.util.Properties props) throws XQExceptionDescription copied from interface:XQSequenceSerializes the sequence starting from the current position to a String 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. Reading the sequence during the serialization process performs implicit next operations to read the items. After all items are written to the stream, the current position of the cursor is set to point after the last item. Also, in the case of forward only sequences, this method may only be called if the current item has not yet been read through any of the get or write methods.- Specified by:
getSequenceAsStringin interfaceXQSequence- Parameters:
props- specifies the serialization parameters,nullis considered equivalent to an emptyPropertiesobject- Returns:
- the serialized representation of the sequence
- Throws:
XQException- if (1) there are errors accessing the items in the sequence, (2) there are errors during serialization, (3) the sequence is in a closed state, or (4) in the case of a forward only sequence, a get or write method has already been invoked on the current item
-
isAfterLast
public boolean isAfterLast() throws XQExceptionDescription copied from interface:XQSequenceChecks if the current position is after the last item in the sequence. Calling this method on an empty sequence will returnfalse.- Specified by:
isAfterLastin interfaceXQSequence- Returns:
trueif the current position is after the last item,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
isBeforeFirst
public boolean isBeforeFirst() throws XQExceptionDescription copied from interface:XQSequenceChecks if the current position before the first item in the sequence. Calling this method on an empty sequence will returnfalse.- Specified by:
isBeforeFirstin interfaceXQSequence- Returns:
trueif the current position is before the first item,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
isFirst
public boolean isFirst() throws XQExceptionDescription copied from interface:XQSequenceChecks if the current position at the first item in the sequence. Calling this method on an empty sequence will returnfalse.- Specified by:
isFirstin interfaceXQSequence- Returns:
trueif the current position is at the first item,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
isLast
public boolean isLast() throws XQExceptionDescription copied from interface:XQSequenceChecks if the current position at the last item in the sequence. Calling this method on an empty sequence will returnfalse.- Specified by:
isLastin interfaceXQSequence- Returns:
trueif the current position is at the last item,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
isOnItem
public boolean isOnItem() throws XQExceptionDescription copied from interface:XQSequenceCheck if the sequence is positioned on an item or not. Calling this method on an empty sequence will returnfalse.- Specified by:
isOnItemin interfaceXQSequence- Returns:
trueif the sequence is currently positioned on an item,falseif sequence is positioned before the first item, or after the last item- Throws:
XQException- if the sequence is in a closed state
-
isScrollable
public boolean isScrollable() throws XQExceptionDescription copied from interface:XQSequenceChecks if the sequence is scrollable.- Specified by:
isScrollablein interfaceXQSequence- Returns:
trueif the sequence can be scrolled backward or forward,falseotherwise- Throws:
XQException- if the sequence is in a closed state
-
last
public boolean last() throws XQExceptionDescription copied from interface:XQSequenceMoves to the last item in the sequence. This method returnstrue, if it was able to move to the last item in the sequencefalse, otherwise. Calling this method on an empty sequence will returnfalse.- Specified by:
lastin interfaceXQSequence- Returns:
trueif the sequence was positioned on the last item,falseotherwise- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state
-
next
public boolean next() throws XQExceptionDescription copied from interface:XQSequenceMoves to the next item in the sequence. Calling this method on an empty sequence will returnfalse.- Specified by:
nextin interfaceXQSequence- Returns:
trueif the new item is valid,falseif there are no more items- Throws:
XQException- if the sequence is in a closed state
-
previous
public boolean previous() throws XQExceptionDescription copied from interface:XQSequenceMoves to the previous item in the sequence. Calling this method on an empty sequence will returnfalse.- Specified by:
previousin interfaceXQSequence- Returns:
trueif the new current position is within the sequence, (i.e., not before first);falseotherwise.- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state.
-
relative
public boolean relative(int itempos) throws XQExceptionDescription copied from interface:XQSequenceMoves the cursor a relative number of items, either positive or negative. Attempting to move beyond the first/last item in the sequence positions the sequence before/after the the first/last item. Callingrelative(0)is valid, but does not change the cursor position. Note: Calling the methodrelative(1)is identical to calling the methodnextand calling the methodrelative(-1)is identical to calling the methodprevious(). Calling this method on an empty sequence will returnfalse.- Specified by:
relativein interfaceXQSequence- Parameters:
itempos- the item position to jump to- Returns:
trueif the new current position is within the sequence (i.e., not before first or after last);falseotherwise.- Throws:
XQException- if (1) the sequence is forward only, or (2) the sequence is in a closed state.
-
writeSequence
public void writeSequence(java.io.OutputStream os, java.util.Properties props) throws XQExceptionDescription copied from interface:XQSequenceSerializes the sequence starting from the current position to anOutputStreamaccording 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. Reading the sequence during the serialization process performs implicit next operations to read the items. After all items are written to the stream, the current position of the cursor is set to point after the last item. Also, in the case of forward only sequences, this method may only be called if the current item has not yet been read through any of the get or write methods.- Specified by:
writeSequencein interfaceXQSequence- Parameters:
os- the output stream into which the sequence is to be serializedprops- specifies the serialization parameters,nullis considered equivalent to an emptyPropertiesobject- Throws:
XQException- if (1) there are errors accessing the items in the sequence, (2) there are errors during serialization, (3) the sequence is in a closed state, (4) in the case of a forward only sequence, a get or write method has already been invoked on the current item, or (5) theosparameter isnull
-
writeSequence
public void writeSequence(java.io.Writer ow, java.util.Properties props) throws XQExceptionDescription copied from interface:XQSequenceSerializes the sequence starting from the current position to a Writer 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.
Warning: When outputting to aWriter, make sure the writer's encoding matches the encoding parameter if specified as a property or the default encoding.
Reading the sequence during the serialization process performs implicit next operations to read the items. After all items are written to the stream, the current position of the cursor is set to point after the last item. Also, in the case of forward only sequences, this method may only be called if the current item has not yet been read through any of the get or write methods.- Specified by:
writeSequencein interfaceXQSequence- Parameters:
ow- the writer object into which the sequence is to be serializedprops- specifies the serialization parameters,nullis considered equivalent to an emptyPropertiesobject- Throws:
XQException- if (1) there are errors accessing the items in the sequence, (2) there are errors during serialization, (3) the sequence is in a closed state, (4) in the case of a forward only sequence, a get or write method has already been invoked on the current item, or (5) theowparameter isnull
-
writeSequenceToResult
public void writeSequenceToResult(javax.xml.transform.Result result) throws XQExceptionDescription copied from interface:XQSequenceWrites the entire sequence starting from the current position to aResult. First the sequence is normalized as described in XSLT 2.0 and XQuery 1.0 serialization. Subsequently it is serialized to theResultobject.
Note that the normalization process can fail, in which case anXQExceptionis thrown. An XQJ implementation must at least support the following implementations:
javax.xml.transform.dom.DOMResultjavax.xml.transform.sax.SAXResultjavax.xml.transform.stream.StreamResult
- Specified by:
writeSequenceToResultin interfaceXQSequence- Parameters:
result- the result object into which the sequence is to be serialized- Throws:
XQException- if (1) there are errors accessing any of the items in the sequence, (2) the sequence 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 sequence into theResultobject, or (5) theresultparameter isnull
-
writeSequenceToSAX
public void writeSequenceToSAX(org.xml.sax.ContentHandler saxHandler) throws XQExceptionDescription copied from interface:XQSequenceWrites the entire sequence starting from the current position to a SAX handler, as described 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 aXQExceptionis thrown. After all items are written to the stream, the current position of the cursor is set to point after the last item. Also, in the case of forward only sequences, this method may only be called if the current item has not yet been read through any of the get or write methods. The specifiedorg.xml.sax.ContentHandlercan optionally implement theorg.xml.sax.LexicalHandlerinterface. An implementation must check if the specifiedContentHandlerimplementsLexicalHandler. If the handler is aLexicalHandlercomment nodes are reported, otherwise they will be silently ignored.- Specified by:
writeSequenceToSAXin interfaceXQSequence- Parameters:
saxHandler- the SAX content handler, optionally a lexical handler- Throws:
XQException- if (1) there are errors accessing any of the items in the sequence, (2) the sequence 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 during serializing the XDM instance into a SAX event stream, or (5) thesaxhdlrparameter isnull
-
-