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.bidimap;
17:
18: import org.apache.commons.collections.OrderedBidiMap;
19: import org.apache.commons.collections.OrderedMapIterator;
20:
21: /**
22: * Provides a base decorator that enables additional functionality to be added
23: * to an OrderedBidiMap via decoration.
24: * <p>
25: * Methods are forwarded directly to the decorated map.
26: * <p>
27: * This implementation does not perform any special processing with the map views.
28: * Instead it simply returns the inverse from the wrapped map. This may be
29: * undesirable, for example if you are trying to write a validating implementation
30: * it would provide a loophole around the validation.
31: * But, you might want that loophole, so this class is kept simple.
32: *
33: * @since Commons Collections 3.0
34: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
35: *
36: * @author Stephen Colebourne
37: */
38: public abstract class AbstractOrderedBidiMapDecorator extends
39: AbstractBidiMapDecorator implements OrderedBidiMap {
40:
41: /**
42: * Constructor that wraps (not copies).
43: *
44: * @param map the map to decorate, must not be null
45: * @throws IllegalArgumentException if the collection is null
46: */
47: protected AbstractOrderedBidiMapDecorator(OrderedBidiMap map) {
48: super (map);
49: }
50:
51: /**
52: * Gets the map being decorated.
53: *
54: * @return the decorated map
55: */
56: protected OrderedBidiMap getOrderedBidiMap() {
57: return (OrderedBidiMap) map;
58: }
59:
60: //-----------------------------------------------------------------------
61: public OrderedMapIterator orderedMapIterator() {
62: return getOrderedBidiMap().orderedMapIterator();
63: }
64:
65: public Object firstKey() {
66: return getOrderedBidiMap().firstKey();
67: }
68:
69: public Object lastKey() {
70: return getOrderedBidiMap().lastKey();
71: }
72:
73: public Object nextKey(Object key) {
74: return getOrderedBidiMap().nextKey(key);
75: }
76:
77: public Object previousKey(Object key) {
78: return getOrderedBidiMap().previousKey(key);
79: }
80:
81: public OrderedBidiMap inverseOrderedBidiMap() {
82: return getOrderedBidiMap().inverseOrderedBidiMap();
83: }
84:
85: }
|