Package org.javarosa.xpath
Class XPathNodeset
java.lang.Object
org.javarosa.xpath.XPathNodeset
- Direct Known Subclasses:
XPathLazyNodeset
public class XPathNodeset extends Object
Represents a set of XPath nodes returned from a path or other operation which acts on multiple
paths.
Current encompasses two states.
1) A nodeset which references between 0 and N nodes which are known about (but, for instance,
don't match any predicates or are irrelevant). Some operations cannot be evaluated in this state
directly. If more than one node is referenced, it is impossible to return a normal evaluation, for
instance.
2) A nodeset which wasn't able to reference into any known model (generally a reference which is
written in error). In this state, the size of the nodeset can be evaluated, but the actual reference
cannot be returned, since it doesn't have any semantic value.
(2) may be a deviation from normal XPath. This should be evaluated in the future.
- Author:
- ctsims
-
Field Summary
Fields Modifier and Type Field Description protected EvaluationContextecprotected DataInstanceinstance -
Constructor Summary
Constructors Modifier Constructor Description XPathNodeset(List<TreeReference> nodes, DataInstance instance, EvaluationContext ec)Construct an XPath nodeset.protectedXPathNodeset(DataInstance instance, EvaluationContext ec)for lazy evaluation -
Method Summary
Modifier and Type Method Description static XPathNodesetConstructInvalidPathNodeset(String pathEvaluated, String originalPath)protected XPathTypeMismatchExceptiongetInvalidNodesetException()intgetNonEmptySize()TreeReferencegetRefAt(int i)protected List<TreeReference>getReferences()ObjectgetValAt(int i)protected StringnodeContents()protected voidsetReferences(List<TreeReference> nodes)static XPathNodesetshuffle(XPathNodeset input)Builds and returns a copy of a XPathNodeset with nodes in a randomized order.static XPathNodesetshuffle(XPathNodeset input, long seed)Builds and returns a copy of a XPathNodeset with nodes in a randomized order.intsize()Object[]toArgList()Objectunpack()
-
Field Details
-
Constructor Details
-
XPathNodeset
for lazy evaluation- Parameters:
instance-ec-
-
XPathNodeset
Construct an XPath nodeset.- Parameters:
nodes-instance-ec-
-
-
Method Details
-
ConstructInvalidPathNodeset
-
shuffle
Builds and returns a copy of a XPathNodeset with nodes in a randomized order.- Returns:
- a copy of this nodeset with nodes in a randomized order
-
shuffle
Builds and returns a copy of a XPathNodeset with nodes in a randomized order.- Parameters:
seed- the seed used when building a Random object to get reproducible results. If null, no seed is used- Returns:
- a copy of this nodeset with nodes in a randomized order
-
setReferences
-
getReferences
-
unpack
- Returns:
- The value represented by this xpath. Can only be evaluated when this xpath represents exactly one reference, or when it represents 0 references after a filtering operation (a reference which _could_ have existed, but didn't, rather than a reference which could not represent a real node).
-
toArgList
-
size
public int size() -
getNonEmptySize
public int getNonEmptySize()- Returns:
- The number of nodes that are not empty
-
getRefAt
-
getValAt
-
getInvalidNodesetException
-
nodeContents
-