|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.xquery.value.AbstractSequence
org.exist.dom.AbstractNodeSet
org.exist.dom.ExtArrayNodeSet
public class ExtArrayNodeSet
A fast node set implementation, based on arrays to store nodes and documents.
The class uses an array to store all nodes belonging to one document. Another sorted
array is used to keep track of the document ids. For each document, we maintain an inner
class, Part, which stores the array of nodes.
Nodes are just appended to the nodes array. No order is guaranteed and calls to
get/contains may fail although a node is present in the array (get/contains
do a binary search and thus assume that the set is sorted). Also, duplicates
are allowed. If you have to ensure that calls to get/contains return valid
results at any time and no duplicates occur, use class
AVLTreeNodeSet
.
Use this class, if you can either ensure that items are added in order, or
no calls to contains/get are required during the creation phase. Only after
a call to one of the iterator methods, the set will get sorted and
duplicates removed.
Field Summary |
---|
Fields inherited from interface org.exist.dom.NodeSet |
---|
ANCESTOR, DESCENDANT, EMPTY_SET, FOLLOWING, PRECEDING |
Fields inherited from interface org.exist.xquery.value.Sequence |
---|
EMPTY_SEQUENCE |
Constructor Summary | |
---|---|
ExtArrayNodeSet()
|
|
ExtArrayNodeSet(int initialArraySize)
|
|
ExtArrayNodeSet(int initialDocsCount,
int initialArraySize)
|
Method Summary | |
---|---|
void |
add(NodeProxy proxy)
Add a new proxy object to the node set. |
void |
add(NodeProxy proxy,
int sizeHint)
Add a new node to the set. |
void |
addAll(NodeSet other)
Add all nodes from the given node set. |
boolean |
contains(NodeProxy proxy)
Check if this node set contains a node matching the document and node-id of the given NodeProxy object. |
boolean |
containsDoc(DocumentImpl doc)
Check if this node set contains nodes belonging to the given document. |
java.lang.String |
debugParts()
|
NodeProxy |
get(DocumentImpl doc,
NodeId nodeId)
|
NodeProxy |
get(int pos)
Get the node at position pos within this node set. |
NodeProxy |
get(NodeProxy p)
Get a node from this node set matching the document and node id of the given NodeProxy. |
NodeSet |
getDescendantsInSet(NodeSet al,
boolean childOnly,
boolean includeSelf,
int mode,
int contextId)
|
DocumentSet |
getDocumentSet()
Returns the set of documents from which the node items in this sequence have been selected. |
int |
getIndexType()
If all nodes in this set have an index, returns the common supertype used to build the index, e.g. |
int |
getItemType()
Return the primary type to which all items in this sequence belong. |
int |
getLength()
Return the number of nodes contained in this node set. |
int |
getSizeHint(DocumentImpl doc)
Get a hint about how many nodes in this node set belong to the specified document. |
int |
getState()
|
boolean |
hasChanged(int previousState)
|
boolean |
hasOne()
Returns whether the sequence has just one item or not. |
boolean |
isEmpty()
Returns whether the sequence is empty or not. |
org.w3c.dom.Node |
item(int pos)
|
Item |
itemAt(int pos)
Returns the item located at the specified position within this sequence. |
SequenceIterator |
iterate()
Returns an iterator over all items in the sequence. |
ByDocumentIterator |
iterateByDocument()
|
NodeSetIterator |
iterator()
Return an iterator on the nodes in this list. |
void |
mergeDuplicates()
Remove all duplicate nodes, but merge their contexts. |
NodeProxy |
parentWithChild(DocumentImpl doc,
NodeId nodeId,
boolean directParent,
boolean includeSelf)
Check if the node identified by its node id has an ancestor contained in this node set and return the ancestor found. |
void |
reset()
|
NodeSet |
selectAncestorDescendant(NodeSet al,
int mode,
boolean includeSelf,
int contextId)
Check if any descendant nodes are found within this node set for a given set of potential ancestor nodes. |
NodeSet |
selectAncestors(NodeSet al,
boolean includeSelf,
int contextId)
For a given set of potential ancestor nodes, return all ancestors having descendants in this node set. |
NodeSet |
selectFollowingSiblings(NodeSet siblings,
int contextId)
Select all nodes from the passed node set, which are following siblings of the nodes in this set. |
NodeSet |
selectParentChild(NodeSet al,
int mode,
int contextId)
Check if any child nodes are found within this node set for a given set of potential ancestor nodes. |
NodeSet |
selectPrecedingSiblings(NodeSet siblings,
int contextId)
Select all nodes from the passed node set, which are preceding or following siblings of the nodes in this set. |
void |
setDocumentSet(DocumentSet docs)
|
void |
setSelfAsContext(int contextId)
|
void |
setSorted(DocumentImpl document,
boolean sorted)
|
void |
sort()
|
void |
sort(boolean mergeContexts)
|
void |
sortInDocumentOrder()
|
java.lang.String |
toString()
|
SequenceIterator |
unorderedIterator()
Returns an iterator over all items in the sequence. |
Methods inherited from class org.exist.dom.AbstractNodeSet |
---|
add, addAll, clearContext, deepIntersection, directSelectAttribute, except, getAncestors, getContextNodes, getParents, getProcessInReverseOrder, hasMixedContent, hasTextIndex, intersection, isCached, isPersistentSet, parentWithChild, removeDuplicates, selectFollowing, selectParentChild, selectPreceding, setIsCached, setProcessInReverseOrder, toNodeSet, union |
Methods inherited from class org.exist.xquery.value.AbstractSequence |
---|
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, hasMany, toJavaObject |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.exist.xquery.value.Sequence |
---|
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, hasMany, toJavaObject |
Constructor Detail |
---|
public ExtArrayNodeSet()
public ExtArrayNodeSet(int initialDocsCount, int initialArraySize)
public ExtArrayNodeSet(int initialArraySize)
Method Detail |
---|
public void reset()
public boolean containsDoc(DocumentImpl doc)
AbstractNodeSet
containsDoc
in interface NodeSet
containsDoc
in class AbstractNodeSet
public boolean isEmpty()
Sequence
isEmpty
in interface Sequence
isEmpty
in class AbstractSequence
true
is the sequence is emptypublic boolean hasOne()
Sequence
hasOne
in interface Sequence
hasOne
in class AbstractSequence
true
is the sequence has just one itempublic void add(NodeProxy proxy)
AbstractNodeSet
add
in interface NodeSet
add
in class AbstractNodeSet
public void add(NodeProxy proxy, int sizeHint)
add
in interface NodeSet
add
in class AbstractNodeSet
public int getItemType()
Sequence
Type.NODE
for node sets, Type.ITEM
for other sequences with mixed items.
getItemType
in interface Sequence
getItemType
in class AbstractNodeSet
public int getSizeHint(DocumentImpl doc)
AbstractNodeSet
getSizeHint
in interface NodeSet
getSizeHint
in class AbstractNodeSet
public NodeSetIterator iterator()
AbstractNodeSet
iterator
in interface NodeSet
iterator
in class AbstractNodeSet
public SequenceIterator iterate() throws XPathException
Sequence
iterate
in interface Sequence
iterate
in class AbstractNodeSet
XPathException
- TODOpublic SequenceIterator unorderedIterator()
Sequence
unorderedIterator
in interface Sequence
unorderedIterator
in class AbstractNodeSet
public ByDocumentIterator iterateByDocument()
public boolean contains(NodeProxy proxy)
AbstractNodeSet
contains
in interface NodeSet
contains
in class AbstractNodeSet
public void addAll(NodeSet other)
AbstractNodeSet
addAll
in interface NodeSet
addAll
in class AbstractNodeSet
public int getLength()
AbstractNodeSet
getLength
in interface Sequence
getLength
in interface org.w3c.dom.NodeList
getLength
in class AbstractNodeSet
public org.w3c.dom.Node item(int pos)
item
in interface org.w3c.dom.NodeList
item
in class AbstractNodeSet
public NodeProxy get(int pos)
AbstractNodeSet
get
in interface NodeSet
get
in class AbstractNodeSet
public NodeProxy get(NodeProxy p)
AbstractNodeSet
get
in interface NodeSet
get
in class AbstractNodeSet
public NodeProxy get(DocumentImpl doc, NodeId nodeId)
public Item itemAt(int pos)
Sequence
itemAt
in interface Sequence
itemAt
in class AbstractSequence
public NodeSet getDescendantsInSet(NodeSet al, boolean childOnly, boolean includeSelf, int mode, int contextId)
public NodeSet selectParentChild(NodeSet al, int mode, int contextId)
AbstractNodeSet
NodeSet.DESCENDANT
, the returned node set will contain
all child nodes found in this node set for each parent node. If mode is
NodeSet.ANCESTOR
, the returned set will contain those parent nodes,
for which children have been found.
selectParentChild
in interface NodeSet
selectParentChild
in class AbstractNodeSet
al
- a node set containing potential parent nodesmode
- selection modecontextId
- used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID
, the current context
will be added to each result of the of the selection.public void setSorted(DocumentImpl document, boolean sorted)
public void mergeDuplicates()
public void sort()
public void sort(boolean mergeContexts)
public final void sortInDocumentOrder()
public void setSelfAsContext(int contextId)
setSelfAsContext
in interface Sequence
setSelfAsContext
in class AbstractSequence
public NodeSet selectAncestorDescendant(NodeSet al, int mode, boolean includeSelf, int contextId)
AbstractNodeSet
NodeSet.DESCENDANT
, the returned node set will contain
all descendant nodes found in this node set for each ancestor. If mode is
NodeSet.ANCESTOR
, the returned set will contain those ancestor nodes,
for which descendants have been found.
selectAncestorDescendant
in interface NodeSet
selectAncestorDescendant
in class AbstractNodeSet
al
- a node set containing potential parent nodesmode
- selection modeincludeSelf
- if true, check if the ancestor node itself is contained in
the set of descendant nodes (descendant-or-self axis)contextId
- used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID
, the current context
will be added to each result of the of the selection.public NodeSet selectPrecedingSiblings(NodeSet siblings, int contextId)
AbstractNodeSet
NodeSet.FOLLOWING
, only nodes following
the context node are selected. NodeSet.PRECEDING
selects
preceding nodes.
selectPrecedingSiblings
in interface NodeSet
selectPrecedingSiblings
in class AbstractNodeSet
siblings
- a node set containing potential siblingscontextId
- used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID
, the current context
will be added to each result of the of the selection.public NodeSet selectFollowingSiblings(NodeSet siblings, int contextId)
NodeSet
selectFollowingSiblings
in interface NodeSet
selectFollowingSiblings
in class AbstractNodeSet
siblings
- a node set containing potential siblingscontextId
- used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID
, the current context
will be added to each result of the of the selection.public NodeSet selectAncestors(NodeSet al, boolean includeSelf, int contextId)
AbstractNodeSet
selectAncestors
in interface NodeSet
selectAncestors
in class AbstractNodeSet
includeSelf
- if true, check if the ancestor node itself is contained
in this node set (ancestor-or-self axis)contextId
- used to track context nodes when evaluating predicate
expressions. If contextId != Expression.NO_CONTEXT_ID
, the current context
will be added to each result of the of the selection.public NodeProxy parentWithChild(DocumentImpl doc, NodeId nodeId, boolean directParent, boolean includeSelf)
NodeSet
parentWithChild
in interface NodeSet
parentWithChild
in class AbstractNodeSet
public java.lang.String debugParts()
public int getIndexType()
AbstractNodeSet
Type.ITEM
.
getIndexType
in interface NodeSet
getIndexType
in class AbstractNodeSet
GeneralComparison
,
ValueComparison
public DocumentSet getDocumentSet()
Sequence
getDocumentSet
in interface NodeSet
getDocumentSet
in interface Sequence
getDocumentSet
in class AbstractNodeSet
public void setDocumentSet(DocumentSet docs)
public boolean hasChanged(int previousState)
hasChanged
in interface NodeSet
hasChanged
in class AbstractNodeSet
public int getState()
getState
in interface NodeSet
getState
in class AbstractNodeSet
public java.lang.String toString()
toString
in class AbstractNodeSet
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |