|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection java.util.AbstractList org.apache.commons.clazz.reflect.common.ReflectedList
public class ReflectedList
This is an implementation of the List
interface
that is based on a List property. Whenever possible, it
uses concrete methods on the owner of the property to manipulate
the list or array.
Consider the following example:
List list = (List)clazz.getProperty("fooList").get(instance); Object value = list.get(3);If
instance
has a getFoo(int index)
method,
this code will implicitly invoke it like this: getFoo(3)
,
otherwise it will obtain the whole list or array and extract the
requested element.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ReflectedList(Object instance,
ReflectedListProperty property)
Constructor for ReflectedList. |
Method Summary | |
---|---|
void |
add(int index,
Object element)
Will perform the following steps: If the instance has an add(index,element) ,
calls that method.
Othewise, if the instance has an add(element) method and
index == size(), calls that method.
Othewise, if the instance has a List getFoo [plural
suffix]() method, calls that and inserts the element into the
list.
Othewise, if the instance has a Foo[] getFoo[plural suffix]
() method as well as a setFoo[plural suffix]
(Foo[]) method, calls the read method, copies the array into a
new, one-longer, array inserting the additional element and calls the
write method to assign the new array to the property.
|
boolean |
add(Object element)
Will perform the following steps: If the instance has an addFoo(element) , calls that
method.
Otherwise, if the instance has an add(index,element) ,
computes the size of the list and calls add(size(),element)
.
Othewise, if the instance has a List getFoo[plural suffix]
() method, calls that and adds the element to the list.
Othewise, if the instance has a Foo[] getFoo[plural suffix]
() method as well as a setFoo[plural suffix]
(Foo[]) method, calls the read method, copies the array into a
new array with an additional element and calls the write method to assign
the new array to the property.
|
Object |
get(int index)
|
Object |
getPropertyValue()
|
Iterator |
iterator()
|
ListIterator |
listIterator()
|
ListIterator |
listIterator(int index)
|
Object |
remove(int index)
Will perform the following steps: If the instance has a remove(index) , calls that method. |
boolean |
remove(Object element)
Will perform the following steps: If the instance has an removeFoo(element) , calls that
method.
Otherwise, if iterates over elements of the collection until it
finds one equal to the supplied value. |
Object |
set(int index,
Object element)
|
void |
setPropertyValue(Object value)
|
int |
size()
|
Methods inherited from class java.util.AbstractList |
---|
addAll, clear, equals, hashCode, indexOf, lastIndexOf, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public ReflectedList(Object instance, ReflectedListProperty property)
Method Detail |
---|
public Object getPropertyValue()
public void setPropertyValue(Object value)
public int size()
size
in interface Collection
size
in interface List
size
in class AbstractCollection
Collection.size()
public Object get(int index)
get
in interface List
get
in class AbstractList
List.get(int)
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface List
iterator
in class AbstractList
Collection.iterator()
public ListIterator listIterator()
listIterator
in interface List
listIterator
in class AbstractList
List.listIterator()
public ListIterator listIterator(int index)
listIterator
in interface List
listIterator
in class AbstractList
List.listIterator(int)
public Object set(int index, Object element)
set
in interface List
set
in class AbstractList
List.set(int, java.lang.Object)
public boolean add(Object element)
addFoo(element)
, calls that
method.add(index,element)
,
computes the size of the list and calls add(size(),element)
.List getFoo[plural suffix]
()
method, calls that and adds the element to the list.Foo[] getFoo[plural suffix]
()
method as well as a setFoo[plural suffix]
(Foo[])
method, calls the read method, copies the array into a
new array with an additional element and calls the write method to assign
the new array to the property.
add
in interface Collection
add
in interface List
add
in class AbstractList
Collection.add(java.lang.Object)
public void add(int index, Object element)
add(index,element)
,
calls that method.add(element)
method and
index == size(), calls that method.List getFoo [plural
suffix]()
method, calls that and inserts the element into the
list.Foo[] getFoo[plural suffix]
()
method as well as a setFoo[plural suffix]
(Foo[])
method, calls the read method, copies the array into a
new, one-longer, array inserting the additional element and calls the
write method to assign the new array to the property.
add
in interface List
add
in class AbstractList
List.add(int, java.lang.Object)
public boolean remove(Object element)
removeFoo(element)
, calls that
method.remove(index)
remove
in interface Collection
remove
in interface List
remove
in class AbstractCollection
Collection.remove(java.lang.Object)
public Object remove(int index)
remove(index)
, calls that method.
add(element)
method and
index == size(), calls that method.List getFoo [plural
suffix]()
method, calls that and removes the element from the
list.
Foo[] getFoo[plural suffix]
()
method as well as a setFoo[plural suffix]
(Foo[])
method, calls the read method, copies the array into a
new, one-shorter, array removing the supplied element and calls the write
method to assign the new array to the property.
remove
in interface List
remove
in class AbstractList
List.add(int, java.lang.Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |