Class XPathPatterns.NodeSet
- All Implemented Interfaces:
Iterable<Node>,Collection<Node>,List<Node>,SequencedCollection<Node>
- Enclosing class:
XPathPatterns
Objects of this represent what is called node-sets in XPath 1.0. This is an unfortunate and misleading name, since the elements are always ordered, but in various context-dependent ways. It is thus technically and logically more correct to conceive of this class as a kind of list.
Null elements are not supported; a NullPointerException is
thrown as early as possible.
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Method Summary
Modifier and TypeMethodDescriptionReturns a node-set that contains only those element of this node-set that are selected by the given predicate, in order.listIterator(int index) Returns a list iterator for this node-set.static XPathPatterns.NodeSetReturns a new node-set that contains the lazily given elements in order.static XPathPatterns.NodeSetReturns a new node-set that contains the given elements in order.static XPathPatterns.NodeSetReturns a new node-set that contains the given elements in order.intsize()Returns the number of elements in this node-set.Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, setMethods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Method Details
-
of
Returns a new node-set that contains the lazily given elements in order.The given elements are computed on demand, by means of an iterator on
elems. No data are copied before this method returns. The exact time when each element is demanded is unpredictable. Hence the iteration should be invariant over time; otherwise behavior is unspecified.If lazy iteration produces a null element later during access to the constructed node-set,
NullPointerExceptionis thrown. In that case, the node-set should be considered invalidated and not accessed again.- Parameters:
elems- an object capable of producing elements by iteration- Returns:
- a new node-set that contains
elemsin order - Throws:
NullPointerException- ifelemsis null
-
of
Returns a new node-set that contains the given elements in order.The given array is copied before this method returns. Subsequent changes to the array have no effect on the returned node-set.
- Parameters:
elems- an array of elements- Returns:
- a new node-set that contains
elemsin order - Throws:
NullPointerException- ifelemsis or contains null
-
of
Returns a new node-set that contains the given elements in order.The given list is copied before this method returns. Subsequent changes to the list have no effect on the returned node-set.
- Parameters:
elems- a list of elements- Returns:
- a new node-set that contains
elemsin order - Throws:
NullPointerException- ifelemsis or contains null
-
size
public int size()Returns the number of elements in this node-set.If this list is being populated lazily, a call to this method enforces completion.
- Specified by:
sizein interfaceCollection<Node>- Specified by:
sizein interfaceList<Node>- Specified by:
sizein classAbstractCollection<Node>
-
listIterator
Returns a list iterator for this node-set.Node-sets are immutable; the returned iterator does not support the operations
add,setandremove.The access operations
nextandpreviousdo not tolerate null elements. If a null element is produced lazily on demand from such an access operation, aNullPointerExceptionis thrown.- Specified by:
listIteratorin interfaceList<Node>- Specified by:
listIteratorin classAbstractSequentialList<Node>- Parameters:
index- the first element to be returned from the list iterator (by a call tonext)- Returns:
- an unmodifiable list iterator over the elements of this node-set, in order
-
filter
Returns a node-set that contains only those element of this node-set that are selected by the given predicate, in order.The resulting node-set is computed lazily on demand.
- Parameters:
pred- the predicate to filter this node-set with- Returns:
- a node-set that contains only those element of this node-set that
are selected by
pred - Throws:
NullPointerException- ifpredis null
-