1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.collections15.list;
17
18 import java.util.Collection;
19 import java.util.List;
20 import java.util.ListIterator;
21
22 import net.sf.collections15.collection.AbstractCollectionDecorator;
23
24 /***
25 * Decorates another <code>List</code> to provide additional behaviour.
26 * <p>
27 * Methods are forwarded directly to the decorated list.
28 *
29 * @since Commons Collections 3.0
30 * @version $Revision: 1.2 $ $Date: 2005/05/03 22:45:38 $
31 *
32 * @author Stephen Colebourne
33 * @author Mauro Franceschini
34 */
35 public abstract class AbstractListDecorator<E>
36 extends AbstractCollectionDecorator<E>
37 implements List<E> {
38
39
40
41
42 /***
43 * Constructor only used in deserialization, do not use otherwise.
44 * @since Commons Collections 3.1
45 */
46 protected AbstractListDecorator() {
47 super();
48 }
49
50 /***
51 * Constructor that wraps (not copies).
52 *
53 * @param list the list to decorate, must not be null
54 * @throws IllegalArgumentException if list is null
55 */
56 protected AbstractListDecorator(List<E> list) {
57 super(list);
58 }
59
60
61
62
63 /***
64 * Gets the list being decorated.
65 *
66 * @return the decorated list
67 */
68 protected final List<E> getList() {
69 return (List<E>)getCollection();
70 }
71
72
73
74
75 public void add(final int index, final E object) {
76 getList().add(index, object);
77 }
78
79 public boolean addAll(final int index, final Collection<? extends E> coll) {
80 return getList().addAll(index, coll);
81 }
82
83 public E get(final int index) {
84 return getList().get(index);
85 }
86
87 public int indexOf(final Object object) {
88 return getList().indexOf(object);
89 }
90
91 public int lastIndexOf(final Object object) {
92 return getList().lastIndexOf(object);
93 }
94
95 public ListIterator<E> listIterator() {
96 return getList().listIterator();
97 }
98
99 public ListIterator<E> listIterator(final int index) {
100 return getList().listIterator(index);
101 }
102
103 public E remove(final int index) {
104 return getList().remove(index);
105 }
106
107 public E set(final int index, final E object) {
108 return getList().set(index, object);
109 }
110
111 public List<E> subList(final int fromIndex, final int toIndex) {
112 return getList().subList(fromIndex, toIndex);
113 }
114
115 }