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 class
AbstractLazyLoadList.LazyLoadListIterator
Iterator for the elements of the List.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,E>
itemsByIndex
Map of object, keyed by the index (0, 1, etc).protected int
size
Cached 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 void
add(int index, java.lang.Object element)
boolean
add(java.lang.Object e)
boolean
addAll(int index, java.util.Collection c)
boolean
addAll(java.util.Collection c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection c)
E
get(int index)
protected abstract int
getSize()
Method to return the size of the list.int
indexOf(java.lang.Object o)
boolean
isEmpty()
protected boolean
isOpen()
Accessor whether the list is open.java.util.Iterator<E>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<E>
listIterator()
java.util.ListIterator<E>
listIterator(int index)
E
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection c)
boolean
retainAll(java.util.Collection c)
protected abstract E
retrieveObjectForIndex(int index)
Accessor to retrieve the object at an index.E
set(int index, java.lang.Object element)
int
size()
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:
add
in 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:
addAll
in 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:
indexOf
in 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:
lastIndexOf
in interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIterator
in 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:
set
in interfacejava.util.List<E>
-
size
public int size()
-
subList
public java.util.List<E> subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfacejava.util.List<E>
-
toArray
public java.lang.Object[] toArray()
-
-