org.apache.commons.collections.list
Class TransformedList<I,O>
java.lang.Object
org.apache.commons.collections.collection.AbstractCollectionDecorator<E>
org.apache.commons.collections.collection.AbstractSerializableCollectionDecorator
org.apache.commons.collections.collection.TransformedCollection<I,O>
org.apache.commons.collections.list.TransformedList<I,O>
- All Implemented Interfaces:
- Serializable, Iterable, Collection, List
public class TransformedList<I,O>
- extends TransformedCollection<I,O>
- implements List
Decorates another 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.
Note: This class cannot support generics without breaking the Collection contract.
- Since:
- Commons Collections 3.0
- Version:
- $Revision: 1.2 $ $Date: 2005/05/23 14:42:13 $
- Author:
- Matt Hall, John Watkinson, Stephen Colebourne
- See Also:
- Serialized Form
Method Summary |
void |
add(int index,
Object object)
|
boolean |
addAll(int index,
Collection coll)
|
void |
addTyped(int index,
I object)
Type-safe version of add(int, Object) (but breaks List interface). |
static
|
decorate(List<I> list,
Transformer<? super I,? extends O> transformer)
Factory method to create a transforming list. |
O |
get(int index)
|
protected List<O> |
getList()
Gets the decorated list. |
int |
indexOf(Object object)
|
int |
lastIndexOf(Object object)
|
ListIterator<O> |
listIterator()
|
ListIterator<O> |
listIterator(int i)
|
Object |
remove(int index)
|
O |
set(int index,
Object object)
|
O |
setTyped(int index,
I object)
Type-safe version of set(int, Object) (but breaks List interface). |
List<O> |
subList(int fromIndex,
int toIndex)
|
Methods inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator |
clear, contains, containsAll, equals, getCollection, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
Methods inherited from interface java.util.List |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
TransformedList
protected TransformedList(List<I> list,
Transformer<? super I,? extends O> transformer)
- Constructor that wraps (not copies).
If there are any elements already in the list being decorated, they
are NOT transformed.
- Parameters:
list
- the list to decorate, must not be nulltransformer
- the transformer to use for conversion, must not be null
- Throws:
IllegalArgumentException
- if list or transformer is null
decorate
public static <I,O> List<O> decorate(List<I> list,
Transformer<? super I,? extends O> transformer)
- Factory method to create a transforming list.
If there are any elements already in the list being decorated, they
are NOT transformed.
- Parameters:
list
- the list to decorate, must not be nulltransformer
- the transformer to use for conversion, must not be null
- Throws:
IllegalArgumentException
- if list or transformer is null
getList
protected List<O> getList()
- Gets the decorated list.
- Returns:
- the decorated list
get
public O get(int index)
- Specified by:
get
in interface List
indexOf
public int indexOf(Object object)
- Specified by:
indexOf
in interface List
lastIndexOf
public int lastIndexOf(Object object)
- Specified by:
lastIndexOf
in interface List
remove
public Object remove(int index)
- Specified by:
remove
in interface List
add
public void add(int index,
Object object)
- Specified by:
add
in interface List
addTyped
public void addTyped(int index,
I object)
- Type-safe version of
add(int, Object)
(but breaks List interface).
addAll
public boolean addAll(int index,
Collection coll)
- Specified by:
addAll
in interface List
listIterator
public ListIterator<O> listIterator()
- Specified by:
listIterator
in interface List
listIterator
public ListIterator<O> listIterator(int i)
- Specified by:
listIterator
in interface List
set
public O set(int index,
Object object)
- Specified by:
set
in interface List
setTyped
public O setTyped(int index,
I object)
- Type-safe version of
set(int, Object)
(but breaks List interface).
subList
public List<O> subList(int fromIndex,
int toIndex)
- Specified by:
subList
in interface List
Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.