01: /*
02: * Copyright 2003-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
36: *
37: * @author Stephen Colebourne
38: */
39: public abstract class AbstractOrderedMapDecorator extends
40: 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 firstKey() {
71: return getOrderedMap().firstKey();
72: }
73:
74: public Object lastKey() {
75: return getOrderedMap().lastKey();
76: }
77:
78: public Object nextKey(Object key) {
79: return getOrderedMap().nextKey(key);
80: }
81:
82: public Object previousKey(Object 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: }
|