use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.
the class ValueSequence method selectDescendants.
@Override
public Sequence selectDescendants(final MemoryNodeSet descendants) {
sortInDocumentOrder();
final ValueSequence nodes = new ValueSequence(true);
nodes.keepUnOrdered(keepUnOrdered);
for (int i = 0; i <= size; i++) {
final NodeImpl node = (NodeImpl) values[i];
for (int j = 0; j < descendants.size(); j++) {
final NodeImpl descendant = descendants.get(j);
if (descendant.getNodeId().isDescendantOrSelfOf(node.getNodeId())) {
nodes.add(node);
}
}
}
return nodes;
}
use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.
the class ValueSequence method getParents.
@Override
public Sequence getParents(final NodeTest test) throws XPathException {
sortInDocumentOrder();
final ValueSequence nodes = new ValueSequence(true);
nodes.keepUnOrdered(keepUnOrdered);
for (int i = 0; i <= size; i++) {
final NodeImpl node = (NodeImpl) values[i];
final NodeImpl parent = (NodeImpl) node.selectParentNode();
if (parent != null && test.matches(parent)) {
nodes.add(parent);
}
}
return nodes;
}
use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.
the class ValueSequence method getDescendants.
@Override
public Sequence getDescendants(final boolean includeSelf, final NodeTest test) throws XPathException {
sortInDocumentOrder();
final ValueSequence nodes = new ValueSequence(true);
nodes.keepUnOrdered(keepUnOrdered);
for (int i = 0; i <= size; i++) {
final NodeImpl node = (NodeImpl) values[i];
node.selectDescendants(includeSelf, test, nodes);
}
return nodes;
}
use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.
the class ValueSequence method getAncestors.
@Override
public Sequence getAncestors(final boolean includeSelf, final NodeTest test) throws XPathException {
sortInDocumentOrder();
final ValueSequence nodes = new ValueSequence(true);
nodes.keepUnOrdered(keepUnOrdered);
for (int i = 0; i <= size; i++) {
final NodeImpl node = (NodeImpl) values[i];
node.selectAncestors(includeSelf, test, nodes);
}
return nodes;
}
use of org.exist.dom.memtree.NodeImpl in project exist by eXist-db.
the class ValueSequence method getPrecedingSiblings.
@Override
public Sequence getPrecedingSiblings(final NodeTest test) throws XPathException {
sortInDocumentOrder();
final ValueSequence nodes = new ValueSequence(true);
nodes.keepUnOrdered(keepUnOrdered);
for (int i = 0; i <= size; i++) {
final NodeImpl node = (NodeImpl) values[i];
// if the context node is an attribute or namespace node, the preceding-sibling axis is empty
if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
node.selectPrecedingSiblings(test, nodes);
}
}
return nodes;
}
Aggregations