Package org.datanucleus.store.query
Class AbstractLazyLoadList<E>
- java.lang.Object
-
- org.datanucleus.store.query.AbstractLazyLoadList<E>
-
- Type Parameters:
E- Type of the element of this list
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.List<E>
- Direct Known Subclasses:
AbstractCandidateLazyLoadList
public abstract class AbstractLazyLoadList<E> extends java.lang.Object implements java.util.List<E>Abstract implementation of a lazy loaded list of (persistent) objects. Needs to be extended to implement theretrieveObjectForIndex()method to retrieve the object at the specified index from whatever datasource is being used, and to implement thegetSize()method to return the size of the list. The "datasource" could be results for a query, or a connection to a datastore, or whatever ... just a source of objects. TODO Change Localised message numbers to be generic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAbstractLazyLoadList.LazyLoadListIteratorIterator for the elements of the List.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,E>itemsByIndexMap of object, keyed by the index (0, 1, etc).protected intsizeCached size of the list.
-
Constructor Summary
Constructors Constructor Description AbstractLazyLoadList(java.lang.String cacheType)Constructor for a lazy load list.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object element)booleanadd(java.lang.Object e)booleanaddAll(int index, java.util.Collection c)booleanaddAll(java.util.Collection c)voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection c)Eget(int index)protected abstract intgetSize()Method to return the size of the list.intindexOf(java.lang.Object o)booleanisEmpty()protected booleanisOpen()Accessor whether the list is open.java.util.Iterator<E>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<E>listIterator()java.util.ListIterator<E>listIterator(int index)Eremove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection c)booleanretainAll(java.util.Collection c)protected abstract EretrieveObjectForIndex(int index)Accessor to retrieve the object at an index.Eset(int index, java.lang.Object element)intsize()java.util.List<E>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()<T> T[]toArray(T[] a)
-
-
-
Field Detail
-
itemsByIndex
private java.util.Map<java.lang.Integer,E> itemsByIndex
Map of object, keyed by the index (0, 1, etc).
-
size
protected int size
Cached size of the list. -1 when not known.
-
-
Method Detail
-
retrieveObjectForIndex
protected abstract E retrieveObjectForIndex(int index)
Accessor to retrieve the object at an index. Is only called if the object is not currently cached.- Parameters:
index- The list index- Returns:
- The object
-
getSize
protected abstract int getSize()
Method to return the size of the list.- Returns:
- The size
-
isOpen
protected boolean isOpen()
Accessor whether the list is open. Always open in this implementation but can be overridden if you want to allow closure.- Returns:
- Whether it is open.
-
add
public void add(int index, java.lang.Object element)- Specified by:
addin interfacejava.util.List<E>
-
add
public boolean add(java.lang.Object e)
-
addAll
public boolean addAll(java.util.Collection c)
-
addAll
public boolean addAll(int index, java.util.Collection c)- Specified by:
addAllin interfacejava.util.List<E>
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection c)
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List<E>
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<E> iterator()
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<E>
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection c)
-
retainAll
public boolean retainAll(java.util.Collection c)
-
set
public E set(int index, java.lang.Object element)
- Specified by:
setin interfacejava.util.List<E>
-
size
public int size()
-
subList
public java.util.List<E> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfacejava.util.List<E>
-
toArray
public java.lang.Object[] toArray()
-
-