KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > list > AbstractListDecorator


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.collections.list;
17
18 import java.util.Collection JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.ListIterator JavaDoc;
21
22 import org.apache.commons.collections.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.4 $ $Date: 2004/06/02 21:53:02 $
31  *
32  * @author Stephen Colebourne
33  */

34 public abstract class AbstractListDecorator extends AbstractCollectionDecorator implements List JavaDoc {
35
36     /**
37      * Constructor only used in deserialization, do not use otherwise.
38      * @since Commons Collections 3.1
39      */

40     protected AbstractListDecorator() {
41         super();
42     }
43
44     /**
45      * Constructor that wraps (not copies).
46      *
47      * @param list the list to decorate, must not be null
48      * @throws IllegalArgumentException if list is null
49      */

50     protected AbstractListDecorator(List JavaDoc list) {
51         super(list);
52     }
53
54     /**
55      * Gets the list being decorated.
56      *
57      * @return the decorated list
58      */

59     protected List JavaDoc getList() {
60         return (List JavaDoc) getCollection();
61     }
62
63     //-----------------------------------------------------------------------
64
public void add(int index, Object JavaDoc object) {
65         getList().add(index, object);
66     }
67
68     public boolean addAll(int index, Collection JavaDoc coll) {
69         return getList().addAll(index, coll);
70     }
71
72     public Object JavaDoc get(int index) {
73         return getList().get(index);
74     }
75
76     public int indexOf(Object JavaDoc object) {
77         return getList().indexOf(object);
78     }
79
80     public int lastIndexOf(Object JavaDoc object) {
81         return getList().lastIndexOf(object);
82     }
83
84     public ListIterator JavaDoc listIterator() {
85         return getList().listIterator();
86     }
87
88     public ListIterator JavaDoc listIterator(int index) {
89         return getList().listIterator(index);
90     }
91
92     public Object JavaDoc remove(int index) {
93         return getList().remove(index);
94     }
95
96     public Object JavaDoc set(int index, Object JavaDoc object) {
97         return getList().set(index, object);
98     }
99
100     public List JavaDoc subList(int fromIndex, int toIndex) {
101         return getList().subList(fromIndex, toIndex);
102     }
103
104 }
105
Popular Tags