org.jdom
Class PartialList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.AbstractSequentialList
                    |
                    +--java.util.LinkedList
                          |
                          +--org.jdom.PartialList

class PartialList
extends LinkedList

PartialList defines a List that contains only part of a larger List, yet is still completely backed by that List.

Author:
Brett McLaughlin, Jason Hunter
Version: 1.0

Constructor Summary
PartialList(List backingList, Element parent)
           As a starting point, take in the List that is the backing behind this List.
PartialList(List backingList)
           As a starting point, take in the List that is the backing behind this List.

Method Summary
 booleanadd(Object o)
          Appends the specified element to the end of this list.
 voidadd(int index, Object current)
          Inserts the specified element at the specified position in this list.
 booleanaddAll(Collection c)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
 booleanaddAll(int index, Collection c)
          Inserts all of the elements in the specified collection into this list, starting at the specified position.
 voidaddFirst(Object o)
          Inserts the given element at the beginning of this list.
 voidaddLast(Object o)
          Appends the given element to the end of this list.
 voidclear()
          Removes all of the elements from this list.
 booleanremove(Object o)
          Removes the first occurrence of the specified element in this list.
 Objectremove(int index)
          Removes the element at the specified position in this list.
 ObjectremoveFirst()
          Removes and returns the first element from this list.
 ObjectremoveLast()
          Removes and returns the last element from this list.
 Objectset(int index, Object current)
          Replaces the element at the specified position in this list with the specified element.

Methods inherited from class java.util.LinkedList
getFirst, getLast, contains, size, get, indexOf, lastIndexOf, listIterator, clone, toArray, toArray

Methods inherited from class java.util.AbstractSequentialList
iterator

Methods inherited from class java.util.AbstractList
listIterator, subList, equals, hashCode

Methods inherited from class java.util.AbstractCollection
isEmpty, containsAll, removeAll, retainAll, toString

Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait

Constructor Detail

PartialList

public PartialList(List backingList, Element parent)

As a starting point, take in the List that is the backing behind this List. It also takes the Element that is the parent of this List and the children that it contains.

Parameters:
backingList - List that backs this

PartialList

public PartialList(List backingList)

As a starting point, take in the List that is the backing behind this List.

Parameters:
backingList - List that backs this
Method Detail

add

public boolean add(Object o)
Appends the specified element to the end of this list.
Parameters:
o - element to be appended to this list.
Returns: true (as per the general contract of Collection.add).

add

public void add(int index, Object current)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addAll

public boolean addAll(Collection c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addAll

public boolean addAll(int index, Collection c)
Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addFirst

public void addFirst(Object o)
Inserts the given element at the beginning of this list.

addLast

public void addLast(Object o)
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

clear

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

remove

public boolean remove(Object o)
Removes the first occurrence of the specified element in this list. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).
Parameters:
o - element to be removed from this list, if present.
Returns: true if the list contained the specified element.

remove

public Object remove(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
Parameters:
index - the index of the element to removed.
Returns: the element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

removeFirst

public Object removeFirst()
Removes and returns the first element from this list.
Returns: the first element from this list.

removeLast

public Object removeLast()
Removes and returns the last element from this list.
Returns: the last element from this list.

set

public Object set(int index, Object current)
Replaces the element at the specified position in this list with the specified element.
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns: the element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

Association Links

to Class java.util.List

The actual backing List

to Class org.jdom.Element

The parent Element (if applicable) of the list