001: /*
002: * Copyright 2003-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.collections.list;
017:
018: import java.util.Collection;
019: import java.util.List;
020: import java.util.ListIterator;
021:
022: import org.apache.commons.collections.collection.AbstractCollectionDecorator;
023:
024: /**
025: * Decorates another <code>List</code> to provide additional behaviour.
026: * <p>
027: * Methods are forwarded directly to the decorated list.
028: *
029: * @since Commons Collections 3.0
030: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
031: *
032: * @author Stephen Colebourne
033: */
034: public abstract class AbstractListDecorator extends
035: AbstractCollectionDecorator implements List {
036:
037: /**
038: * Constructor only used in deserialization, do not use otherwise.
039: * @since Commons Collections 3.1
040: */
041: protected AbstractListDecorator() {
042: super ();
043: }
044:
045: /**
046: * Constructor that wraps (not copies).
047: *
048: * @param list the list to decorate, must not be null
049: * @throws IllegalArgumentException if list is null
050: */
051: protected AbstractListDecorator(List list) {
052: super (list);
053: }
054:
055: /**
056: * Gets the list being decorated.
057: *
058: * @return the decorated list
059: */
060: protected List getList() {
061: return (List) getCollection();
062: }
063:
064: //-----------------------------------------------------------------------
065: public void add(int index, Object object) {
066: getList().add(index, object);
067: }
068:
069: public boolean addAll(int index, Collection coll) {
070: return getList().addAll(index, coll);
071: }
072:
073: public Object get(int index) {
074: return getList().get(index);
075: }
076:
077: public int indexOf(Object object) {
078: return getList().indexOf(object);
079: }
080:
081: public int lastIndexOf(Object object) {
082: return getList().lastIndexOf(object);
083: }
084:
085: public ListIterator listIterator() {
086: return getList().listIterator();
087: }
088:
089: public ListIterator listIterator(int index) {
090: return getList().listIterator(index);
091: }
092:
093: public Object remove(int index) {
094: return getList().remove(index);
095: }
096:
097: public Object set(int index, Object object) {
098: return getList().set(index, object);
099: }
100:
101: public List subList(int fromIndex, int toIndex) {
102: return getList().subList(fromIndex, toIndex);
103: }
104:
105: }
|