Package org.htmlunit.xpath.objects
Class XNodeSet
- java.lang.Object
-
- org.htmlunit.xpath.Expression
-
- org.htmlunit.xpath.objects.XObject
-
- org.htmlunit.xpath.axes.NodeSequence
-
- org.htmlunit.xpath.objects.XNodeSet
-
- All Implemented Interfaces:
java.lang.Cloneable
,javax.xml.transform.SourceLocator
,PathComponent
,ExpressionNode
,DTMIterator
,XPathVisitable
public class XNodeSet extends NodeSequence
This class represents an XPath nodeset object, and is capable of converting the nodeset to other types, such as a string.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static EqualComparator
S_EQ
Equal comparator(package private) static GreaterThanComparator
S_GT
Greater than comparator(package private) static GreaterThanOrEqualComparator
S_GTE
Greater than or equal comparator(package private) static LessThanComparator
S_LT
Less than comparator(package private) static LessThanOrEqualComparator
S_LTE
Less than or equal comparator(package private) static NotEqualComparator
S_NEQ
Not equal comparator-
Fields inherited from class org.htmlunit.xpath.axes.NodeSequence
m_dtmMgr, m_iter, m_last, m_next
-
Fields inherited from class org.htmlunit.xpath.objects.XObject
CLASS_BOOLEAN, CLASS_NODESET, CLASS_NULL, CLASS_NUMBER, CLASS_RTREEFRAG, CLASS_STRING, CLASS_UNKNOWN, m_obj
-
Fields inherited from interface org.htmlunit.xpath.xml.dtm.DTMIterator
FILTER_ACCEPT, FILTER_SKIP
-
-
Constructor Summary
Constructors Constructor Description XNodeSet(DTMIterator val)
Construct a XNodeSet object.XNodeSet(DTMManager dtmMgr)
Construct an empty XNodeSet object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
bool()
Cast result object to a boolean.boolean
boolWithSideEffects()
Cast result object to a boolean, but allow side effects, such as the incrementing of an iterator.boolean
compare(XObject obj2, Comparator comparator)
Tell if one object is less than the other.boolean
equals(XObject obj2)
Tell if two objects are functionally equal.double
getNumberFromNode(int n)
Get numeric value of the string conversion from a single node.XString
getStringFromNode(int n)
Get the string conversion from a single node.int
getType()
Tell what kind of class this is.java.lang.String
getTypeString()
Given a request type, return the equivalent string.boolean
greaterThan(XObject obj2)
Tell if one object is greater than the other.boolean
greaterThanOrEqual(XObject obj2)
Tell if one object is greater than or equal to the other.DTMIterator
iter()
Cast result object to a nodelist.DTMIterator
iterRaw()
Return the iterator without cloning, etc.boolean
lessThan(XObject obj2)
Tell if one object is less than the other.boolean
lessThanOrEqual(XObject obj2)
Tell if one object is less than or equal to the other.NodeSetDTM
mutableNodeset()
Cast result object to a nodelist.org.w3c.dom.NodeList
nodelist()
Cast result object to a nodelist.org.w3c.dom.traversal.NodeIterator
nodeset()
Cast result object to a nodelist.boolean
notEquals(XObject obj2)
Tell if two objects are functionally not equal.double
num()
Cast result object to a number.double
numWithSideEffects()
Cast result object to a number, but allow side effects, such as the incrementing of an iterator.java.lang.Object
object()
Return a java object that's closest to the representation that should be handed to an extension.java.lang.String
str()
Cast result object to a string.XString
xstr()
Cast result object to a string.-
Methods inherited from class org.htmlunit.xpath.axes.NodeSequence
addNodeInDocOrder, clone, cloneWithReset, detach, getAnalysisBits, getAxis, getCurrentNode, getCurrentPos, getDTM, getDTMManager, getExpandEntityReferences, getIteratorCache, getLength, getRoot, getVector, getWhatToShow, hasCache, isDocOrdered, isFresh, item, nextNode, previousNode, reset, runTo, setCurrentPos, setIter, setObject, setRoot, setShouldCacheNodes, setVector
-
Methods inherited from class org.htmlunit.xpath.objects.XObject
callVisitors, deepEquals, error, error, execute, toString
-
Methods inherited from class org.htmlunit.xpath.Expression
asIterator, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, execute, execute, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isSameClass, isStableNumber, num
-
-
-
-
Field Detail
-
S_LT
static final LessThanComparator S_LT
Less than comparator
-
S_LTE
static final LessThanOrEqualComparator S_LTE
Less than or equal comparator
-
S_GT
static final GreaterThanComparator S_GT
Greater than comparator
-
S_GTE
static final GreaterThanOrEqualComparator S_GTE
Greater than or equal comparator
-
S_EQ
static final EqualComparator S_EQ
Equal comparator
-
S_NEQ
static final NotEqualComparator S_NEQ
Not equal comparator
-
-
Constructor Detail
-
XNodeSet
public XNodeSet(DTMIterator val)
Construct a XNodeSet object.- Parameters:
val
- Value of the XNodeSet object
-
XNodeSet
public XNodeSet(DTMManager dtmMgr)
Construct an empty XNodeSet object. This is used to create a mutable nodeset to which random nodes may be added.
-
-
Method Detail
-
getType
public int getType()
Tell what kind of class this is.
-
getTypeString
public java.lang.String getTypeString()
Given a request type, return the equivalent string. For diagnostic purposes.- Overrides:
getTypeString
in classXObject
- Returns:
- type string "#UNKNOWN" + object class name
-
getNumberFromNode
public double getNumberFromNode(int n)
Get numeric value of the string conversion from a single node.- Parameters:
n
- Node to convert- Returns:
- numeric value of the string conversion from a single node.
-
num
public double num()
Cast result object to a number. Always issues an error.
-
numWithSideEffects
public double numWithSideEffects()
Cast result object to a number, but allow side effects, such as the incrementing of an iterator.- Overrides:
numWithSideEffects
in classXObject
- Returns:
- numeric value of the string conversion from the next node in the NodeSetDTM, or NAN if no node was found
-
bool
public boolean bool()
Cast result object to a boolean. Always issues an error.
-
boolWithSideEffects
public boolean boolWithSideEffects()
Cast result object to a boolean, but allow side effects, such as the incrementing of an iterator.- Overrides:
boolWithSideEffects
in classXObject
- Returns:
- True if there is a next node in the nodeset
-
getStringFromNode
public XString getStringFromNode(int n)
Get the string conversion from a single node.- Parameters:
n
- Node to convert- Returns:
- the string conversion from a single node.
-
xstr
public XString xstr()
Cast result object to a string.
-
str
public java.lang.String str()
Cast result object to a string.
-
object
public java.lang.Object object()
Return a java object that's closest to the representation that should be handed to an extension.
-
nodeset
public org.w3c.dom.traversal.NodeIterator nodeset() throws javax.xml.transform.TransformerException
Cast result object to a nodelist. Always issues an error.
-
nodelist
public org.w3c.dom.NodeList nodelist() throws javax.xml.transform.TransformerException
Cast result object to a nodelist. Always issues an error.
-
iterRaw
public DTMIterator iterRaw()
Return the iterator without cloning, etc.
-
iter
public DTMIterator iter()
Cast result object to a nodelist. Always issues an error.
-
mutableNodeset
public NodeSetDTM mutableNodeset()
Cast result object to a nodelist. Always issues an error.- Overrides:
mutableNodeset
in classXObject
- Returns:
- The object as a NodeSetDTM.
-
compare
public boolean compare(XObject obj2, Comparator comparator) throws javax.xml.transform.TransformerException
Tell if one object is less than the other.- Parameters:
obj2
- Object to compare this nodeset tocomparator
- Comparator to use- Returns:
- See the comments below for each object type comparison
- Throws:
javax.xml.transform.TransformerException
- in case of error
-
lessThan
public boolean lessThan(XObject obj2) throws javax.xml.transform.TransformerException
Tell if one object is less than the other.
-
lessThanOrEqual
public boolean lessThanOrEqual(XObject obj2) throws javax.xml.transform.TransformerException
Tell if one object is less than or equal to the other.- Overrides:
lessThanOrEqual
in classXObject
- Parameters:
obj2
- Object to compare this to- Returns:
- True if this object is less than or equal to the given object
- Throws:
javax.xml.transform.TransformerException
- in case of error
-
greaterThan
public boolean greaterThan(XObject obj2) throws javax.xml.transform.TransformerException
Tell if one object is greater than the other.- Overrides:
greaterThan
in classXObject
- Parameters:
obj2
- Object to compare this to- Returns:
- True if this object is greater than the given object
- Throws:
javax.xml.transform.TransformerException
- in case of error
-
greaterThanOrEqual
public boolean greaterThanOrEqual(XObject obj2) throws javax.xml.transform.TransformerException
Tell if one object is greater than or equal to the other.- Overrides:
greaterThanOrEqual
in classXObject
- Parameters:
obj2
- Object to compare this to- Returns:
- True if this object is greater than or equal to the given object
- Throws:
javax.xml.transform.TransformerException
- in case of error
-
equals
public boolean equals(XObject obj2)
Tell if two objects are functionally equal.
-
notEquals
public boolean notEquals(XObject obj2) throws javax.xml.transform.TransformerException
Tell if two objects are functionally not equal.
-
-