org.planx.xpath.object
Class XNodeSet

java.lang.Object
  extended by org.planx.xpath.expr.Expression
      extended by org.planx.xpath.object.XObject
          extended by org.planx.xpath.object.XNodeSet
All Implemented Interfaces:
Iterable, Collection, List

public class XNodeSet
extends XObject
implements List

A node set returned by an XPath expression. Note: This class is not synchronized. The terms "set" and "list" are used interchangably in this class, since semantically it should be a set but this is not inforced due to performance considerations. In fact it is a list. However, the XPath implementation garuantees that only XNodeSets without duplicates are returned.


Constructor Summary
XNodeSet()
          Creates an empty node set.
XNodeSet(Collection c)
          Creates a node set containing all elements in the specified collection.
XNodeSet(int initialCapacity)
          Creates an empty node set with the specified initial capacity.
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(Object o)
          Appends the specified element.
 boolean addAll(Collection c)
          Appends all of the elements in the specified collection.
 boolean addAll(int index, Collection c)
          Inserts all of the elements in the specified collection at the specified position.
 boolean booleanValue()
          Returns true if this node set contains any elements.
 void clear()
          Removes all of the elements from this set.
 boolean contains(Object o)
          Returns true if this set contains the specified element.
 boolean containsAll(Collection c)
          Returns true if this set contains all of the elements of the specified collection.
 boolean equals(Object o)
          Compares the specified object with this set for equality.
 Object get(int index)
          Returns the element at the specified position in this list.
 int hashCode()
          Returns the hash code value for this set.
 int indexOf(Object o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 boolean isEmpty()
          Returns true if this set contains no elements.
 Iterator iterator()
          Returns an iterator over the elements in this set.
 int lastIndexOf(Object o)
          Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
 ListIterator listIterator()
          Returns a list iterator of the elements in this list.
 ListIterator listIterator(int index)
          Returns a list iterator of the elements in this list, starting at the specified position in this list.
 Object remove(int index)
          Removes the element at the specified position in this list.
 boolean remove(Object o)
          Removes the specified element from this set if it is present.
 boolean removeAll(Collection c)
          Removes from this set all of its elements that are contained in the specified collection.
 boolean retainAll(Collection c)
          Retains only the elements in this set that are contained in the specified collection.
 Object set(int index, Object element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the number of elements in this set.
 List subList(int fromIndex, int toIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 Object[] toArray()
          Returns an array containing all of the elements in this set.
 Object[] toArray(Object[] a)
          Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
 String toString()
          Returns a comma-separated list in square brackets of the contents of this node set.
 
Methods inherited from class org.planx.xpath.object.XObject
evaluate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XNodeSet

public XNodeSet()
Creates an empty node set.


XNodeSet

public XNodeSet(int initialCapacity)
Creates an empty node set with the specified initial capacity.


XNodeSet

public XNodeSet(Collection c)
Creates a node set containing all elements in the specified collection.

Method Detail

booleanValue

public boolean booleanValue()
Returns true if this node set contains any elements. Otherwise returns false.

Specified by:
booleanValue in class XObject

toString

public String toString()
Returns a comma-separated list in square brackets of the contents of this node set. Each element in the list is converted to a string using the toString() method.

Overrides:
toString in class Object

size

public int size()
Returns the number of elements in this set.

Specified by:
size in interface Collection
Specified by:
size in interface List

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List

contains

public boolean contains(Object o)
Returns true if this set contains the specified element.

Specified by:
contains in interface Collection
Specified by:
contains in interface List

iterator

public Iterator iterator()
Returns an iterator over the elements in this set.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List

toArray

public Object[] toArray()
Returns an array containing all of the elements in this set.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

add

public boolean add(Object o)
Appends the specified element.

Specified by:
add in interface Collection
Specified by:
add in interface List

remove

public boolean remove(Object o)
Removes the specified element from this set if it is present.

Specified by:
remove in interface Collection
Specified by:
remove in interface List

containsAll

public boolean containsAll(Collection c)
Returns true if this set contains all of the elements of the specified collection.

Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List

addAll

public boolean addAll(Collection c)
Appends all of the elements in the specified collection.

Specified by:
addAll in interface Collection
Specified by:
addAll in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Inserts all of the elements in the specified collection at the specified position.

Specified by:
addAll in interface List

retainAll

public boolean retainAll(Collection c)
Retains only the elements in this set that are contained in the specified collection.

Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List

removeAll

public boolean removeAll(Collection c)
Removes from this set all of its elements that are contained in the specified collection.

Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List

clear

public void clear()
Removes all of the elements from this set.

Specified by:
clear in interface Collection
Specified by:
clear in interface List

equals

public boolean equals(Object o)
Compares the specified object with this set for equality.

Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code value for this set.

Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object

get

public Object get(int index)
Returns the element at the specified position in this list.

Specified by:
get in interface List

set

public Object set(int index,
                  Object element)
Replaces the element at the specified position in this list with the specified element.

Specified by:
set in interface List

add

public void add(int index,
                Object element)
Inserts the specified element at the specified position in this list.

Specified by:
add in interface List

remove

public Object remove(int index)
Removes the element at the specified position in this list.

Specified by:
remove in interface List

indexOf

public int indexOf(Object o)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

Specified by:
indexOf in interface List

lastIndexOf

public int lastIndexOf(Object o)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.

Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Returns a list iterator of the elements in this list.

Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Returns a list iterator of the elements in this list, starting at the specified position in this list.

Specified by:
listIterator in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

Specified by:
subList in interface List


Copyright © 2010. All Rights Reserved.