net.sf.spif.persistence
Class PersistenceOptimizingArrayList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--net.sf.spif.persistence.PersistenceOptimizingArrayList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class PersistenceOptimizingArrayList
extends java.util.ArrayList

An array list which automatically remembers it add and remove history. This history makes StorePersister able to skip unnecessary db updates, which speeds things up.

To make your db updates more affective, just use this class for your collections and make sure that you return iterators through one of the iterator methods on this class, i.e. Collections.unmodifiableCollection(myLisat).iterator will not make things any fatser.

Version:
$Id: PersistenceOptimizingArrayList.java,v 1.2 2003/02/05 22:15:48 bratseth Exp $
Author:
Jon S Bratseth
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PersistenceOptimizingArrayList()
           
PersistenceOptimizingArrayList(boolean referencesOnly)
           
 
Method Summary
 void add(int i, java.lang.Object element)
           
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 void clear()
           
 java.lang.Object get(int index)
           
 java.util.Iterator iterator()
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int index)
           
 void recordChanges(boolean doRecord)
          Set to false to make changes which won't cause this class to feel changed or accessed.
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
           
 java.lang.Object set(int index, java.lang.Object element)
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, indexOf, isEmpty, lastIndexOf, removeRange, size, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, removeAll, retainAll, subList
 

Constructor Detail

PersistenceOptimizingArrayList

public PersistenceOptimizingArrayList()

PersistenceOptimizingArrayList

public PersistenceOptimizingArrayList(boolean referencesOnly)
Method Detail

add

public void add(int i,
                java.lang.Object element)
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.List
Overrides:
add in class java.util.ArrayList

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.ArrayList

clear

public void clear()
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.ArrayList

get

public java.lang.Object get(int index)
Specified by:
get in interface java.util.List
Overrides:
get in class java.util.ArrayList

remove

public java.lang.Object remove(int index)
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.ArrayList

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.AbstractCollection

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List
Overrides:
set in class java.util.ArrayList

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class java.util.ArrayList

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.List
Overrides:
toArray in class java.util.ArrayList

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.util.List
Overrides:
iterator in class java.util.AbstractList

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.AbstractList

listIterator

public java.util.ListIterator listIterator(int index)
Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class java.util.AbstractList

recordChanges

public void recordChanges(boolean doRecord)
Set to false to make changes which won't cause this class to feel changed or accessed. This is useful to do changes which we know won't affect persistence, like sorting



Spif 1.01 (2003-04-03). http://spif.sf.net