16 package org.zorbaxquery.api.xqj;
18 import java.util.ArrayList;
19 import javax.xml.xquery.XQException;
20 import javax.xml.xquery.XQItem;
21 import javax.xml.xquery.XQSequence;
22 import org.zorbaxquery.api.Collection;
23 import org.zorbaxquery.api.ItemSequence;
33 private boolean closed =
false;
34 private Collection collection = null;
35 private java.util.Collection<XQSequence> sequences =
new ArrayList<XQSequence>();
47 public void close() throws XQException {
48 for (XQSequence exp : sequences ){
51 if (collection!=null) {
71 public XQSequence
contents() throws XQException {
72 isClosedXQException();
74 sequences.add(result);
85 isClosedXQException();
86 collection.deleteNodeFirst();
96 isClosedXQException();
97 collection.deleteNodeLast();
110 isClosedXQException();
113 collection.deleteNodes(sequence);
114 }
catch (XQException e) {
126 isClosedXQException();
127 collection.deleteNodesFirst(aNumNodes);
137 isClosedXQException();
138 collection.deleteNodesLast(aNumNodes);
147 isClosedXQException();
148 return collection.getName().getStringValue();
160 isClosedXQException();
174 public long indexOf(XQItem aNode )
throws XQException {
175 isClosedXQException();
176 return collection.indexOf(((org.zorbaxquery.api.xqj.ZorbaXQItem)aNode).getZorbaItem());
194 isClosedXQException();
197 collection.insertNodesAfter(((org.zorbaxquery.api.xqj.ZorbaXQItem)aTarget).getZorbaItem(), sequence);
198 }
catch (XQException e) {
218 isClosedXQException();
221 collection.insertNodesBefore(((org.zorbaxquery.api.xqj.ZorbaXQItem)aTarget).getZorbaItem(), sequence);
222 }
catch (XQException e) {
236 isClosedXQException();
239 collection.insertNodesFirst(sequence);
240 }
catch (XQException e) {
254 isClosedXQException();
257 collection.insertNodesLast(sequence);
258 }
catch (XQException e) {
269 isClosedXQException();
270 return collection.isStatic();
273 private void isClosedXQException() throws XQException {
275 throw new XQException(
"Collection is closed");
void insertNodesBefore(XQItem aTarget, XQSequence aNodes)
This function inserts copies of the given nodes into a collection at the position directly preceding ...
void deleteNodesLast(long aNumNodes)
This function deletes the n last nodes from a collection.
boolean isStatic()
The function checks if this collection has been statically declared.
ZorbaXQCollection(Collection col)
String getName()
Get the name of the collection.
boolean isClosed()
Checks if the collection is closed.
void deleteNodes(XQSequence aNodes)
This function deletes zero of more nodes from a collection.
A Collection is a persistent sequence of node items.
void deleteNodeFirst()
This function deletes the first node from a collection.
void deleteNodesFirst(long aNumNodes)
This function deletes the n first nodes from a collection.
XQSequence contents()
This function returns the sequence of nodes of the collection.
The ZorbaXQItemType class represents an item type as defined in XQuery 1.0: An XML Query language...
void deleteNodeLast()
This function deletes the last node from a collection.
ZorbaXQItemType getType()
Retrieves the sequence type for this (static declared) collection.
This interface represents a sequence of items as defined in the XDM.
void close()
Closes the collection.
void insertNodesAfter(XQItem aTarget, XQSequence aNodes)
This function inserts copies of the given nodes into a collection at the position directly following ...
long indexOf(XQItem aNode)
This function returns the index of the given node in the collection.
void insertNodesFirst(XQSequence aNodes)
This function inserts copies of the given nodes at the beginning of the collection.
void insertNodesLast(XQSequence aNodes)
This function inserts copies of the given nodes at the end of the collection.