⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.list

Class TransformedList

java.lang.Object
|
+--org.apache.commons.collections.collection.AbstractCollectionDecorator
   |
   +--org.apache.commons.collections.collection.TransformedCollection
      |
      +--org.apache.commons.collections.list.TransformedList

All Implemented Interfaces:
Collection, List


public class TransformedList
extends TransformedCollection
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.

Since:
Commons Collections 3.0
Author:
Stephen Colebourne

Constructor Summary

TransformedList(List list, Transformer transformer)

Constructor that wraps (not copies).

Method Summary

void

add(int index, Object object)

boolean

addAll(int index, Collection coll)

static List

decorate(List list, Transformer transformer)

Factory method to create a transforming list.

Object

get(int index)

List

getList()

Gets the decorated list.

int

indexOf(Object object)

int

lastIndexOf(Object object)

ListIterator

listIterator()

ListIterator

listIterator(int i)

Object

remove(int index)

Object

set(int index, Object object)

List

subList(int fromIndex, int toIndex)

Constructor Details

TransformedList

protected TransformedList(List list, Transformer 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 null
transformer - the transformer to use for conversion, must not be null
Throws:
- if list or transformer is null

Method Details

add

public void add(int index, Object object)

Parameters:
index
object

addAll

public boolean addAll(int index, Collection coll)

Parameters:
index
coll

decorate

public static List decorate(List list, Transformer 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 null
transformer - the transformer to use for conversion, must not be null
Throws:
- if list or transformer is null

get

public Object get(int index)

Parameters:
index

getList

protected List getList()

Gets the decorated list.

Returns:
the decorated list

indexOf

public int indexOf(Object object)

Parameters:
object

lastIndexOf

public int lastIndexOf(Object object)

Parameters:
object

listIterator

public ListIterator listIterator()


listIterator

public ListIterator listIterator(int i)

Parameters:
i

remove

public Object remove(int index)

Parameters:
index

set

public Object set(int index, Object object)

Parameters:
index
object

subList

public List subList(int fromIndex, int toIndex)

Parameters:
fromIndex
toIndex