List to transform objects that are added.
The add and set methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Class and Description |
|---|---|
| protected class | TransformedList.TransformedListIterator
Inner class Iterator for the TransformedList |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | TransformedList(final List<E>
the list to decorate, must not be null list, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(final int
index at which the specified element is to be inserted index, E element to be inserted object)Implements java. |
| public boolean | addAll(final int
index at which to insert the first element from the
specified collection index, Collection<? extends E> collection containing elements to be added to this list coll)Implements java. |
| public boolean | equals(final Object
the object to be compared for equality with this list object)Overrides java. Implements java. |
| public E | get(final int
index of the element to return index)Implements java. |
| protected List | |
| public int | hashCode()
Overrides java. Implements java. |
| public int | indexOf(final Object
element to search for object)Implements java. |
| public int | lastIndexOf(final Object
element to search for object)Implements java. |
| public ListIterator | listIterator()
Implements java. |
| public ListIterator | listIterator(final int
index of the first element to be returned from the
list iterator (by a call to i)next)Implements java. |
| public E | remove(final int
the index of the element to be removed index)Implements java. |
| public E | set(final int
index of the element to replace index, E element to be stored at the specified position object)Implements java. |
| public List | subList(final int
low endpoint (inclusive) of the subList fromIndex, final int high endpoint (exclusive) of the subList toIndex)Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| public static < the type of the elements in the list E> TransformedList | Returns: a new transformed Listthe list to decorate, must not be null list, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Factory method to create a transforming list that will transform existing contents of the specified list. |
| public static < the type of the elements in the list E> TransformedList | Returns: a new transformed listthe list to decorate, must not be null list, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Factory method to create a transforming list. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| TransformedList | back to summary |
|---|---|
| protected TransformedList(final List<E> list, final Transformer<? super E, ? extends E> transformer) Constructor that wraps (not copies). If there are any elements already in the list being decorated, they are NOT transformed.
| |
| add | back to summary |
|---|---|
| public void add(final int index, E object) Implements java. Doc from java. Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final int index, Collection<? extends E> coll) Implements java. Doc from java. Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| get | back to summary |
|---|---|
| public E get(final int index) Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| getList | back to summary |
|---|---|
| protected List Gets the decorated list.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two lists,
list1 and list2, as required by the general
contract of Object#hashCode.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(final Object object) Implements java. Doc from java. Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index | |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(final Object object) Implements java. Doc from java. Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the highest index | |
| listIterator | back to summary |
|---|---|
| public ListIterator Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper sequence).
| |
| listIterator | back to summary |
|---|---|
| public ListIterator Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
The specified index indicates the first element that would be
returned by an initial call to
| |
| remove | back to summary |
|---|---|
| public E remove(final int index) Implements java. Doc from java. Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
| |
| set | back to summary |
|---|---|
| public E set(final int index, E object) Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| subList | back to summary |
|---|---|
| public List Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) | |
| transformedList | back to summary |
|---|---|
| public static <E> TransformedList Factory method to create a transforming list that will transform existing contents of the specified list.
If there are any elements already in the list being decorated, they
will be transformed by this method.
Contrast this with
| |
| transformingList | back to summary |
|---|---|
| public static <E> TransformedList Factory method to create a transforming list.
If there are any elements already in the list being decorated, they
are NOT transformed.
Contrast this with
| |
| Access | Constructor and Description |
|---|---|
| protected | TransformedListIterator(final ListIterator<E>
the list iterator to decorate iterator)Create a new transformed list iterator. |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(E
the element to insert object)Overrides org. Implements java. |
| public void | set(E
the element with which to replace the last element returned by
object)next or previousOverrides org. Implements java. next or
previous with the specified element (optional operation).
|
| TransformedListIterator | back to summary |
|---|---|
| protected TransformedListIterator(final ListIterator<E> iterator) Create a new transformed list iterator.
| |
| add | back to summary |
|---|---|
| public void add(E object) Overrides org. Implements java. Doc from org. Inserts the specified element into the list (optional operation).
The element is inserted immediately before the element that
would be returned by
| |
| set | back to summary |
|---|---|
| public void set(E object) Overrides org. Implements java. Doc from org. Replaces the last element returned by
| |