global.sandbox.xmlutilities
Class NodeListCollection<E extends Node>

java.lang.Object
  extended by global.sandbox.xmlutilities.NodeListCollection<E>
Type Parameters:
E - element type
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>

public class NodeListCollection<E extends Node>
extends Object
implements List<E>

ArrayList like implementation for NodeList which is unmodifiable, not serializable and exposes access to original NodeList. The under-layering implementation is based on a copy, modifications made to the original NodeList have no effect to iterators. The name of this class has been chosen in respect to possible collision with org.w3c.dom.NodeList which may occur during import.

Version:
1.2
Author:
Petr Hadraba

Field Summary
private  Class<E> elementType
          Class type of elements.
private static Logger LOGGER
          Logger.
private  NodeList nodeList
          Original NodeList.
private  List<E> nodes
          Unmodifiable implementation.
 
Constructor Summary
NodeListCollection(NodeList nodeList, Class<E> elementType)
          Creates new instance from NodeList.
 
Method Summary
 boolean add(E e)
          
 void add(int index, E element)
          
 boolean addAll(Collection<? extends E> c)
          
 boolean addAll(int index, Collection<? extends E> c)
          
 void clear()
          
 boolean contains(Object o)
          
 boolean containsAll(Collection<?> c)
          
 boolean equals(Object obj)
          
 E get(int index)
          
 Class<E> getElementType()
          Returns class type of element.
 NodeList getNodeList()
          Returns under-layering NodeList.
 int hashCode()
          
 int indexOf(Object o)
          
 boolean isEmpty()
          
 Iterator<E> iterator()
          
 int lastIndexOf(Object o)
          
 ListIterator<E> listIterator()
          
 ListIterator<E> listIterator(int index)
          
 E remove(int index)
          
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> c)
          
 boolean retainAll(Collection<?> c)
          
 E set(int index, E element)
          
 int size()
          
 List<E> subList(int fromIndex, int toIndex)
          
 Object[] toArray()
          
<T> T[]
toArray(T[] a)
          
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

private static final Logger LOGGER
Logger.


elementType

private final Class<E extends Node> elementType
Class type of elements.


nodeList

private final NodeList nodeList
Original NodeList.


nodes

private final List<E extends Node> nodes
Unmodifiable implementation.

Constructor Detail

NodeListCollection

public NodeListCollection(NodeList nodeList,
                          Class<E> elementType)
                   throws XmlUtilitiesException
Creates new instance from NodeList. The under-layering implementation is constant, read only, unmodifiable. The implementation is intentionally not serializable.

Parameters:
nodeList - under-layering NodeList
elementType - class type of element
Throws:
XmlUtilitiesException - on error (casting, data type conversion)
Method Detail

getElementType

public Class<E> getElementType()
Returns class type of element.

Returns:
class type of element

getNodeList

public NodeList getNodeList()
Returns under-layering NodeList.

Returns:
under-layering NodeList

size

public int size()

Specified by:
size in interface Collection<E extends Node>
Specified by:
size in interface List<E extends Node>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Collection<E extends Node>
Specified by:
isEmpty in interface List<E extends Node>

contains

public boolean contains(Object o)

Specified by:
contains in interface Collection<E extends Node>
Specified by:
contains in interface List<E extends Node>

iterator

public Iterator<E> iterator()

Specified by:
iterator in interface Iterable<E extends Node>
Specified by:
iterator in interface Collection<E extends Node>
Specified by:
iterator in interface List<E extends Node>

toArray

public Object[] toArray()

Specified by:
toArray in interface Collection<E extends Node>
Specified by:
toArray in interface List<E extends Node>

toArray

public <T> T[] toArray(T[] a)

Specified by:
toArray in interface Collection<E extends Node>
Specified by:
toArray in interface List<E extends Node>

add

public boolean add(E e)

Specified by:
add in interface Collection<E extends Node>
Specified by:
add in interface List<E extends Node>

remove

public boolean remove(Object o)

Specified by:
remove in interface Collection<E extends Node>
Specified by:
remove in interface List<E extends Node>

containsAll

public boolean containsAll(Collection<?> c)

Specified by:
containsAll in interface Collection<E extends Node>
Specified by:
containsAll in interface List<E extends Node>

addAll

public boolean addAll(Collection<? extends E> c)

Specified by:
addAll in interface Collection<E extends Node>
Specified by:
addAll in interface List<E extends Node>

addAll

public boolean addAll(int index,
                      Collection<? extends E> c)

Specified by:
addAll in interface List<E extends Node>

removeAll

public boolean removeAll(Collection<?> c)

Specified by:
removeAll in interface Collection<E extends Node>
Specified by:
removeAll in interface List<E extends Node>

retainAll

public boolean retainAll(Collection<?> c)

Specified by:
retainAll in interface Collection<E extends Node>
Specified by:
retainAll in interface List<E extends Node>

clear

public void clear()

Specified by:
clear in interface Collection<E extends Node>
Specified by:
clear in interface List<E extends Node>

get

public E get(int index)

Specified by:
get in interface List<E extends Node>

set

public E set(int index,
             E element)

Specified by:
set in interface List<E extends Node>

add

public void add(int index,
                E element)

Specified by:
add in interface List<E extends Node>

remove

public E remove(int index)

Specified by:
remove in interface List<E extends Node>

indexOf

public int indexOf(Object o)

Specified by:
indexOf in interface List<E extends Node>

lastIndexOf

public int lastIndexOf(Object o)

Specified by:
lastIndexOf in interface List<E extends Node>

listIterator

public ListIterator<E> listIterator()

Specified by:
listIterator in interface List<E extends Node>

listIterator

public ListIterator<E> listIterator(int index)

Specified by:
listIterator in interface List<E extends Node>

subList

public List<E> subList(int fromIndex,
                       int toIndex)

Specified by:
subList in interface List<E extends Node>

equals

public boolean equals(Object obj)

Specified by:
equals in interface Collection<E extends Node>
Specified by:
equals in interface List<E extends Node>
Overrides:
equals in class Object

hashCode

public int hashCode()

Specified by:
hashCode in interface Collection<E extends Node>
Specified by:
hashCode in interface List<E extends Node>
Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2006–2017. All rights reserved.