for a list of items.
Usage
Object lazylist =null;
while(loopCondition)
{
Object item = getItem();
if (item.isToBeAdded())
lazylist = LazyList.add(lazylist,item);
}
return LazyList.getList(lazylist);
An ArrayList of default size is used as the initial LazyList.
See Also: List
,
Serialized Form
Method Summary
static java.lang.Object
add (java.lang.Object list,
int index,
java.lang.Object item)
Add an item to a LazyList
static java.lang.Object
add (java.lang.Object list,
java.lang.Object item)
Add an item to a LazyList
static java.lang.Object
addArray (java.lang.Object list,
java.lang.Object[] array)
Add the contents of an array to a LazyList
static java.lang.Object
addCollection (java.lang.Object list,
java.util.Collection<?> collection)
Add the contents of a Collection to a LazyList
static java.lang.Object[]
addToArray (java.lang.Object[] array,
java.lang.Object item,
java.lang.Class<?> type)
Add element to an array
static
array2List (E[] array)
static java.lang.Object
clone (java.lang.Object list)
static boolean
contains (java.lang.Object list,
java.lang.Object item)
static java.lang.Object
ensureSize (java.lang.Object list,
int initialSize)
Ensure the capcity of the underlying list.
static
get (java.lang.Object list,
int i)
Get item from the list
static
getList (java.lang.Object list)
Get the real List from a LazyList.
static
getList (java.lang.Object list,
boolean nullForEmpty)
Get the real List from a LazyList.
static
<E> java.util.Iterator<E>
iterator (java.lang.Object list)
static
<E> java.util.ListIterator<E>
listIterator (java.lang.Object list)
static java.lang.Object
remove (java.lang.Object list,
int i)
static java.lang.Object
remove (java.lang.Object list,
java.lang.Object o)
static java.lang.Object
removeFromArray (java.lang.Object[] array,
java.lang.Object item)
static int
size (java.lang.Object list)
The size of a lazy List
static java.lang.Object
toArray (java.lang.Object list,
java.lang.Class<?> clazz)
Convert a lazylist to an array
static java.lang.String
toString (java.lang.Object list)
static java.lang.String[]
toStringArray (java.lang.Object list)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add
public static java.lang.Object add (java.lang.Object list,
java.lang.Object item)
Add an item to a LazyList
Parameters: list
- The list to add to or null if none yet created.item
- The item to add.
Returns: The lazylist created or added to.
add
public static java.lang.Object add (java.lang.Object list,
int index,
java.lang.Object item)
Add an item to a LazyList
Parameters: list
- The list to add to or null if none yet created.index
- The index to add the item at.item
- The item to add.
Returns: The lazylist created or added to.
addCollection
public static java.lang.Object addCollection (java.lang.Object list,
java.util.Collection<?> collection)
Add the contents of a Collection to a LazyList
Parameters: list
- The list to add to or null if none yet created.collection
- The Collection whose contents should be added.
Returns: The lazylist created or added to.
addArray
public static java.lang.Object addArray (java.lang.Object list,
java.lang.Object[] array)
Add the contents of an array to a LazyList
Parameters: list
- The list to add to or null if none yet created.array
- The array whose contents should be added.
Returns: The lazylist created or added to.
ensureSize
public static java.lang.Object ensureSize (java.lang.Object list,
int initialSize)
Ensure the capcity of the underlying list.
remove
public static java.lang.Object remove (java.lang.Object list,
java.lang.Object o)
remove
public static java.lang.Object remove (java.lang.Object list,
int i)
getList
public static <E> java.util.List<E> getList (java.lang.Object list)
Get the real List from a LazyList.
Parameters: list
- A LazyList returned from LazyList.add(Object)
Returns: The List of added items, which may be an EMPTY_LIST
or a SingletonList.
getList
public static <E> java.util.List<E> getList (java.lang.Object list,
boolean nullForEmpty)
Get the real List from a LazyList.
Parameters: list
- A LazyList returned from LazyList.add(Object) or nullnullForEmpty
- If true, null is returned instead of an
empty list.
Returns: The List of added items, which may be null, an EMPTY_LIST
or a SingletonList.
toStringArray
public static java.lang.String[] toStringArray (java.lang.Object list)
toArray
public static java.lang.Object toArray (java.lang.Object list,
java.lang.Class<?> clazz)
Convert a lazylist to an array
Parameters: list
- The list to convertclazz
- The class of the array, which may be a primitive type
Returns: array of the lazylist entries passed in
size
public static int size (java.lang.Object list)
The size of a lazy List
Parameters: list
- A LazyList returned from LazyList.add(Object) or null
Returns: the size of the list.
get
public static <E> E get (java.lang.Object list,
int i)
Get item from the list
Parameters: list
- A LazyList returned from LazyList.add(Object) or nulli
- int index
Returns: the item from the list.
contains
public static boolean contains (java.lang.Object list,
java.lang.Object item)
clone
public static java.lang.Object clone (java.lang.Object list)
toString
public static java.lang.String toString (java.lang.Object list)
iterator
public static <E> java.util.Iterator<E> iterator (java.lang.Object list)
listIterator
public static <E> java.util.ListIterator<E> listIterator (java.lang.Object list)
array2List
public static <E> java.util.List<E> array2List (E[] array)
Parameters: array
- Any array of object
Returns: A new modifiable list initialised with the elements from array
.
addToArray
public static java.lang.Object[] addToArray (java.lang.Object[] array,
java.lang.Object item,
java.lang.Class<?> type)
Add element to an array
Parameters: array
- The array to add to (or null)item
- The item to addtype
- The type of the array (in case of null array)
Returns: new array with contents of array plus item
removeFromArray
public static java.lang.Object removeFromArray (java.lang.Object[] array,
java.lang.Object item)
Copyright © 1995-2010 Mort Bay Consulting . All Rights Reserved.