Subversion Repositories bacoAlunos

Rev

Rev 1306 | Blame | Compare with Previous | Last modification | View Log | RSS feed

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

package pt.estgp.estgweb.utils;

import java.util.Collection;
import java.util.Iterator;

/**
 * Decorates another <code>Collection</code> to provide additional behaviour.
 * <p>
 * Each method call made on this <code>Collection</code> is forwarded to the
 * decorated <code>Collection</code>. This class is used as a framework on which
 * to build to extensions such as synchronized and unmodifiable behaviour. The
 * main advantage of decoration is that one decorator can wrap any implementation
 * of <code>Collection</code>, whereas sub-classing requires a new class to be
 * written for each implementation.
 * <p>
 * This implementation does not perform any special processing with
 * {@link #iterator()}. Instead it simply returns the value from the
 * wrapped collection. This may be undesirable, for example if you are trying
 * to write an unmodifiable implementation it might provide a loophole.
 *
 * @since Commons Collections 3.0
 * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:03 $
 *
 * @author Stephen Colebourne
 * @author Paul Jack
 */

public abstract class AbstractCollectionDecorator implements 1.5.0/docs/api/java/util/Collection.html">Collection {

    /** The collection being decorated */
    protected 1.5.0/docs/api/java/util/Collection.html">Collection collection;

    /**
     * Constructor only used in deserialization, do not use otherwise.
     * @since Commons Collections 3.1
     */

    protected AbstractCollectionDecorator() {
        super();
    }

    /**
     * Constructor that wraps (not copies).
     *
     * @param coll  the collection to decorate, must not be null
     * @throws IllegalArgumentException if the collection is null
     */

    protected AbstractCollectionDecorator(1.5.0/docs/api/java/util/Collection.html">Collection coll) {
        if (coll == null) {
            throw new 1.5.0/docs/api/java/lang/IllegalArgumentException.html">IllegalArgumentException("Collection must not be null");
        }
        this.collection = coll;
    }

    /**
     * Gets the collection being decorated.
     *
     * @return the decorated collection
     */

    protected 1.5.0/docs/api/java/util/Collection.html">Collection getCollection() {
        return collection;
    }

    //-----------------------------------------------------------------------
    public boolean add(5+0%2Fdocs%2Fapi+Object">Object object) {
        return collection.add(object);
    }

    public boolean addAll(1.5.0/docs/api/java/util/Collection.html">Collection coll) {
        return collection.addAll(coll);
    }

    public void clear() {
        collection.clear();
    }

    public boolean contains(5+0%2Fdocs%2Fapi+Object">Object object) {
        return collection.contains(object);
    }

    public boolean isEmpty() {
        return collection.isEmpty();
    }

    public 1.5.0/docs/api/java/util/Iterator.html">Iterator iterator() {
        return collection.iterator();
    }

    public boolean remove(5+0%2Fdocs%2Fapi+Object">Object object) {
        return collection.remove(object);
    }

    public int size() {
        return collection.size();
    }

    public 5+0%2Fdocs%2Fapi+Object">Object[] toArray() {
        return collection.toArray();
    }

    public 5+0%2Fdocs%2Fapi+Object">Object[] toArray(5+0%2Fdocs%2Fapi+Object">Object[] object) {
        return collection.toArray(object);
    }

    public boolean containsAll(1.5.0/docs/api/java/util/Collection.html">Collection coll) {
        return collection.containsAll(coll);
    }

    public boolean removeAll(1.5.0/docs/api/java/util/Collection.html">Collection coll) {
        return collection.removeAll(coll);
    }

    public boolean retainAll(1.5.0/docs/api/java/util/Collection.html">Collection coll) {
        return collection.retainAll(coll);
    }

    public boolean equals(5+0%2Fdocs%2Fapi+Object">Object object) {
        if (object == this) {
            return true;
        }
        return collection.equals(object);
    }

    public int hashCode() {
        return collection.hashCode();
    }

    public 1.5.0/docs/api/java/lang/String.html">String toString() {
        return collection.toString();
    }

}