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.iterators;
018    
019    import org.apache.commons.collections.OrderedMapIterator;
020    
021    /**
022     * Provides basic behaviour for decorating an ordered map iterator with extra functionality.
023     * <p>
024     * All methods are forwarded to the decorated map iterator.
025     *
026     * @since Commons Collections 3.0
027     * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
028     * 
029     * @author Stephen Colebourne
030     */
031    public class AbstractOrderedMapIteratorDecorator implements OrderedMapIterator {
032    
033        /** The iterator being decorated */
034        protected final OrderedMapIterator iterator;
035    
036        //-----------------------------------------------------------------------
037        /**
038         * Constructor that decorates the specified iterator.
039         *
040         * @param iterator  the iterator to decorate, must not be null
041         * @throws IllegalArgumentException if the collection is null
042         */
043        public AbstractOrderedMapIteratorDecorator(OrderedMapIterator iterator) {
044            super();
045            if (iterator == null) {
046                throw new IllegalArgumentException("OrderedMapIterator must not be null");
047            }
048            this.iterator = iterator;
049        }
050    
051        /**
052         * Gets the iterator being decorated.
053         * 
054         * @return the decorated iterator
055         */
056        protected OrderedMapIterator getOrderedMapIterator() {
057            return iterator;
058        }
059    
060        //-----------------------------------------------------------------------
061        public boolean hasNext() {
062            return iterator.hasNext();
063        }
064    
065        public Object next() {
066            return iterator.next();
067        }
068    
069        public boolean hasPrevious() {
070            return iterator.hasPrevious();
071        }
072    
073        public Object previous() {
074            return iterator.previous();
075        }
076    
077        public void remove() {
078            iterator.remove();
079        }
080        
081        public Object getKey() {
082            return iterator.getKey();
083        }
084    
085        public Object getValue() {
086            return iterator.getValue();
087        }
088    
089        public Object setValue(Object obj) {
090            return iterator.setValue(obj);
091        }
092    
093    }