|
||||||||||
| 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<T>
facets.util.ItemList<T>
public class ItemList<T>
An array-friendly List.
ItemList extends ArrayList with methods that encapsulate
the complications of adding and extracting simple arrays from a List.
The problem of constructing generic arrays is circumvented by passing in the storage type during construction. Run-time checking protects against the unlikely error of passing in the wrong type; compile-time checking of the generics type protects against more subtle code weaknesses.
ItemList<Integer> ints = new ItemList(Integer.class); ints.addItems(1,2,3); ints.addItem(4); Integer[] items = ints.items();
| Nested Class Summary | |
|---|---|
static class |
ItemList.TreeItems<C>
ItemList that can traverse a generic tree. |
| Field Summary | |
|---|---|
protected static int |
defaultSize
|
java.lang.Class |
itemType
|
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
ItemList(java.lang.Class itemType)
Unique constructor. |
|
ItemList(T[] src)
|
|
| Method Summary | |
|---|---|
void |
addItem(T item)
Add item which must be non-null and of the type passed to
the constructor. |
void |
addItems(T... items)
Add items which must be an array of the type passed to the constructor. |
T[] |
items()
Returns an array of the storage type passed to the constructor. |
| Methods inherited from class java.util.ArrayList |
|---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
|---|
equals, hashCode, iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, 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, removeAll, retainAll, subList |
| Field Detail |
|---|
protected static final int defaultSize
public final java.lang.Class itemType
| Constructor Detail |
|---|
public ItemList(java.lang.Class itemType)
Sets initial size as specified by class constant defaultSize.
itemType - - the type of object to be allowed in the listpublic ItemList(T[] src)
| Method Detail |
|---|
public final void addItem(T item)
item which must be non-null and of the type passed to
the constructor.
Wraps List.add(Object).
public final void addItems(T... items)
items which must be an array of the type passed to the constructor.
Wraps List.addAll(Collection).
public final T[] items()
Wraps ).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||