KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > map > AbstractOrderedMapDecorator


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.map;
17
18 import org.apache.commons.collections.MapIterator;
19 import org.apache.commons.collections.OrderedMap;
20 import org.apache.commons.collections.OrderedMapIterator;
21
22 /**
23  * Provides a base decorator that enables additional functionality to be added
24  * to an OrderedMap via decoration.
25  * <p>
26  * Methods are forwarded directly to the decorated map.
27  * <p>
28  * This implementation does not perform any special processing with the map views.
29  * Instead it simply returns the set/collection from the wrapped map. This may be
30  * undesirable, for example if you are trying to write a validating implementation
31  * it would provide a loophole around the validation.
32  * But, you might want that loophole, so this class is kept simple.
33  *
34  * @since Commons Collections 3.0
35  * @version $Revision: 1.7 $ $Date: 2004/04/02 21:17:48 $
36  *
37  * @author Stephen Colebourne
38  */

39 public abstract class AbstractOrderedMapDecorator
40         extends AbstractMapDecorator implements OrderedMap {
41
42     /**
43      * Constructor only used in deserialization, do not use otherwise.
44      * @since Commons Collections 3.1
45      */

46     protected AbstractOrderedMapDecorator() {
47         super();
48     }
49
50     /**
51      * Constructor that wraps (not copies).
52      *
53      * @param map the map to decorate, must not be null
54      * @throws IllegalArgumentException if the collection is null
55      */

56     public AbstractOrderedMapDecorator(OrderedMap map) {
57         super(map);
58     }
59
60     /**
61      * Gets the map being decorated.
62      *
63      * @return the decorated map
64      */

65     protected OrderedMap getOrderedMap() {
66         return (OrderedMap) map;
67     }
68
69     //-----------------------------------------------------------------------
70
public Object JavaDoc firstKey() {
71         return getOrderedMap().firstKey();
72     }
73
74     public Object JavaDoc lastKey() {
75         return getOrderedMap().lastKey();
76     }
77
78     public Object JavaDoc nextKey(Object JavaDoc key) {
79         return getOrderedMap().nextKey(key);
80     }
81
82     public Object JavaDoc previousKey(Object JavaDoc key) {
83         return getOrderedMap().previousKey(key);
84     }
85
86     public MapIterator mapIterator() {
87         return getOrderedMap().mapIterator();
88     }
89
90     public OrderedMapIterator orderedMapIterator() {
91         return getOrderedMap().orderedMapIterator();
92     }
93
94 }
95
Popular Tags