Arch4J 1.1

org.arch4j.persistence.domainmapper
Class PersistableList

java.lang.Object
  |
  +--org.arch4j.persistence.domainmapper.PersistableList
All Implemented Interfaces:
Collection, List

public class PersistableList
extends Object
implements List

This class implements the List interface in order to manage the persistent state of its contained items. Besides the main list of objects retrieved from a database, it maintains a list of objects that have been added and a list of objects that have been removed from the main list since the last reset was performed. Reset is typically called when the list is synchronized with the database.

Version:
$Revision: 1.2 $
Author:
$Author: rgreinke $

Constructor Summary
  PersistableList()
          Constructs an empty persistable list.
  PersistableList(Collection c)
          Constructs a list containing the elements of the specified collection.
protected PersistableList(List mainList, List addedList, List removedList)
          Protected constructor used to initialize the receiver.
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 Object get(int index)
           
 List getAddedList()
          Retrieves the list of objects added since the last reset.
 List getMainList()
          Retrieves the main, current list of objects managed by the receiver.
 List getPreExistingList()
          Retrieves a new list of objects from the main list that do not exist in the added list.
 List getRemovedList()
          Retrieves the list of objects removed sinces the last reset.
 int indexOf(Object o)
           
 boolean isEmpty()
           
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 void reset()
          Clears both the added and the removed lists.
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 int size()
           
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

PersistableList

public PersistableList()
Constructs an empty persistable list.


PersistableList

public PersistableList(Collection c)
Constructs a list containing the elements of the specified collection.

Parameters:
c - The collection whose elements are to be placed into the receiver.

PersistableList

protected PersistableList(List mainList,
                          List addedList,
                          List removedList)
Protected constructor used to initialize the receiver.

Method Detail

getMainList

public List getMainList()
Retrieves the main, current list of objects managed by the receiver.

Returns:
The main list.

getAddedList

public List getAddedList()
Retrieves the list of objects added since the last reset.

Returns:
The added list.

getRemovedList

public List getRemovedList()
Retrieves the list of objects removed sinces the last reset.

Returns:
The removed list.

getPreExistingList

public List getPreExistingList()
Retrieves a new list of objects from the main list that do not exist in the added list.

Returns:
The pre-existing list.

reset

public void reset()
Clears both the added and the removed lists.


add

public void add(int index,
                Object element)
Specified by:
add in interface List

add

public boolean add(Object o)
Specified by:
add in interface List

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List

clear

public void clear()
Specified by:
clear in interface List

contains

public boolean contains(Object o)
Specified by:
contains in interface List

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface List

get

public Object get(int index)
Specified by:
get in interface List

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface List

iterator

public Iterator iterator()
Specified by:
iterator in interface List

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List

remove

public Object remove(int index)
Specified by:
remove in interface List

remove

public boolean remove(Object o)
Specified by:
remove in interface List

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface List

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface List

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List

size

public int size()
Specified by:
size in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List

toArray

public Object[] toArray()
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface List

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.