|
Dashboard Builder Commons 6.0.0.Beta1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
org.jboss.dashboard.commons.collections.LazyList
public abstract class LazyList
List designed to manage large amount of instances.
Internally, it only stores identifiers (as a list passed at initialization). Instances are only retrieved when invoking the get(int index) method of the list. This load-on-demand technique is also known as lazy materialization.
Instances can be added or removed from list via class methods. You can both add the instance to the list or instance identifier. If you need to retrieve the list of identifiers stored internally use the getIds method which returns an array of strings.
| Field Summary | |
|---|---|
protected boolean |
discardDuplicates
Flag indicating if duplicated elements are allowed. |
protected int |
fetchSize
The number of elements fetched when invoking the get(index) method. |
protected List |
instanceList
List of instances already retrieved by the lazy calls. |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
LazyList(boolean discardDuplicates)
Constructs an empty list. |
|
LazyList(Collection c,
boolean discardDuplicates)
Constructs a list from the identifiers of the specified collection, in the order they are returned by the collection's iterator. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Object o)
Inserts the specified element at the specified position in this list. |
boolean |
add(Object o)
Appends the specified element to the end of this list. |
boolean |
addAll(Collection c)
Appends all of the elements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. |
boolean |
addAll(int index,
Collection c)
Not supported. |
boolean |
contains(Object o)
Returns true if this list contains the specified element. |
abstract LazyList |
createLazyList(Collection c)
Creates a brand new lazy list initialiaed with the given list of identifiers. |
Object |
get(int index)
Retrieves the instance at specified position. |
int |
getFetchSize()
The number of elements fetched when invoking the get(index) method. |
String |
getId(int index)
Retrieve identifier stored at given position. |
String[] |
getIds()
Retrieve identifiers stored internally in the lazy list. |
abstract String |
getInstanceId(Object o)
Retreives the identifier of an instance. |
int |
indexOf(Object elem)
Searches for the first occurence of the given argument, testing for equality using the equals method. |
abstract boolean |
isInstance(Object o)
Check if object is an business object or an identifier. |
int |
lastIndexOf(Object elem)
Returns the index of the last occurrence of the specified object in this list. |
abstract List |
loadInstances(String[] ids)
Loads the instances with the given identifiers. |
boolean |
remove(Object o)
Removes the process from the collection |
boolean |
removeAll(Collection c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation). |
boolean |
removeId(String id)
Remove identifier from list. |
Object |
set(int index,
Object element)
Replaces the element at the specified position in this list with the specified element. |
void |
setFetchSize(int fetchSize)
The number of elements fetched when invoking the get(index) method. |
List |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this list between fromIndex, inclusive, and toIndex, exclusive. |
| Methods inherited from class java.util.ArrayList |
|---|
clear, clone, ensureCapacity, isEmpty, remove, removeRange, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, 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, iterator, listIterator, listIterator, retainAll |
| Field Detail |
|---|
protected List instanceList
protected boolean discardDuplicates
protected int fetchSize
| Constructor Detail |
|---|
public LazyList(boolean discardDuplicates)
discardDuplicates - Ensure list not contains duplicates.
public LazyList(Collection c,
boolean discardDuplicates)
c - the collection of ids.discardDuplicates - Ensure list not contains duplicates.| Method Detail |
|---|
public int getFetchSize()
public void setFetchSize(int fetchSize)
public abstract boolean isInstance(Object o)
public abstract String getInstanceId(Object o)
public abstract List loadInstances(String[] ids)
public abstract LazyList createLazyList(Collection c)
public String[] getIds()
public String getId(int index)
index -
public boolean removeId(String id)
public Object get(int index)
get in interface Listget in class ArrayListindex -
public boolean remove(Object o)
remove in interface Collectionremove in interface Listremove in class ArrayListo - The instance to remove (the identifier is also accepted).
public boolean contains(Object o)
contains in interface Collectioncontains in interface Listcontains in class ArrayListo - element whose presence in this List is to be tested.public int indexOf(Object elem)
indexOf in interface ListindexOf in class ArrayListelem - an object.
Object.equals(Object)public int lastIndexOf(Object elem)
lastIndexOf in interface ListlastIndexOf in class ArrayListelem - the desired element.
public boolean add(Object o)
add in interface Collectionadd in interface Listadd in class ArrayListo - element to be appended to this list.
public void add(int index,
Object o)
add in interface Listadd in class ArrayListindex - index at which the specified element is to be inserted.o - element to be inserted.
If trying to add an instance then its identifier is added instead of the whole instance.
IndexOutOfBoundsException - if index is out of range
(index < 0 || index > size()).public boolean addAll(Collection c)
addAll in interface CollectionaddAll in interface ListaddAll in class ArrayListc - the collection of both instances or ids.
If trying to add an instance then its identifier is added instead of the whole instance.
IndexOutOfBoundsException - if index out of range (index
< 0 || index > size()).
public boolean addAll(int index,
Collection c)
addAll in interface ListaddAll in class ArrayListpublic boolean removeAll(Collection c)
This implementation retrieves the elements from the target collection and performs single remove operations for each one of these elements.
removeAll in interface CollectionremoveAll in interface ListremoveAll in class AbstractCollectionc - elements to be removed from this collection.
public Object set(int index,
Object element)
set in interface Listset in class ArrayListindex - index of element to replace.element - element to be stored at the specified position.
IndexOutOfBoundsException - if index out of range
(index < 0 || index >= size()).
public List subList(int fromIndex,
int toIndex)
subList in interface ListsubList in class AbstractList
|
Dashboard Builder Commons 6.0.0.Beta1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||