eXo Kernel :: Commons Utils 2.4.9-GA

org.exoplatform.commons.utils
Class LazyList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by org.exoplatform.commons.utils.LazyList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, RandomAccess

public class LazyList<E>
extends AbstractList<E>
implements RandomAccess

A lazy list and uses a ListAccess object to load the elements of the list. The list is read only and any write access to the list will not be permitted.

The loading policy is based on a simple batch algorithm that loads the elements by batches.

The list also keeps a cache of the retrieved elements. The cache use soft references to provide eviction of the elements if necessary. When a soft reference is cleared and access is made to an evicted element then the elements will be reloaded from the list access object.

If the list access fails to load a batch by throwing a checked exception, it will cause the list to throw an IllegalStateException wrapping the original exception. Any other kind of non checked throwable will be propagated to the caller as it is.

The implementation does not perform any kind of versionning check of the underlying data and if the underlying list access changes the state it exposes the lazy list will not be aware of it and may behave in an unexpected manner.

Version:
$Revision$
Author:
Julien Viet

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LazyList(ListAccess<E> listAccess, int batchSize)
           
 
Method Summary
 E get(int index)
           
 int size()
           
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

LazyList

public LazyList(ListAccess<E> listAccess,
                int batchSize)
Method Detail

get

public E get(int index)
Specified by:
get in interface List<E>
Specified by:
get in class AbstractList<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>

eXo Kernel :: Commons Utils 2.4.9-GA

Copyright © 2014 eXo Platform SAS. All Rights Reserved.