001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.commons.collections.buffer;
018    
019    import org.apache.commons.collections.Buffer;
020    import org.apache.commons.collections.collection.AbstractCollectionDecorator;
021    
022    /**
023     * Decorates another <code>Buffer</code> to provide additional behaviour.
024     * <p>
025     * Methods are forwarded directly to the decorated buffer.
026     *
027     * @since Commons Collections 3.0
028     * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
029     * 
030     * @author Stephen Colebourne
031     */
032    public abstract class AbstractBufferDecorator extends AbstractCollectionDecorator implements Buffer {
033    
034        /**
035         * Constructor only used in deserialization, do not use otherwise.
036         * @since Commons Collections 3.1
037         */
038        protected AbstractBufferDecorator() {
039            super();
040        }
041    
042        /**
043         * Constructor that wraps (not copies).
044         * 
045         * @param buffer  the buffer to decorate, must not be null
046         * @throws IllegalArgumentException if list is null
047         */
048        protected AbstractBufferDecorator(Buffer buffer) {
049            super(buffer);
050        }
051    
052        /**
053         * Gets the buffer being decorated.
054         * 
055         * @return the decorated buffer
056         */
057        protected Buffer getBuffer() {
058            return (Buffer) getCollection();
059        }
060    
061        //-----------------------------------------------------------------------
062        public Object get() {
063            return getBuffer().get();
064        }
065    
066        public Object remove() {
067            return getBuffer().remove();
068        }
069    
070    }