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.BidiMap;
19: import org.apache.commons.collections.MapIterator;
20: import org.apache.commons.collections.map.AbstractMapDecorator;
21:
22: /**
23: * Provides a base decorator that enables additional functionality to be added
24: * to a BidiMap 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 AbstractBidiMapDecorator extends
40: AbstractMapDecorator implements BidiMap {
41:
42: /**
43: * Constructor that wraps (not copies).
44: *
45: * @param map the map to decorate, must not be null
46: * @throws IllegalArgumentException if the collection is null
47: */
48: protected AbstractBidiMapDecorator(BidiMap map) {
49: super (map);
50: }
51:
52: /**
53: * Gets the map being decorated.
54: *
55: * @return the decorated map
56: */
57: protected BidiMap getBidiMap() {
58: return (BidiMap) map;
59: }
60:
61: //-----------------------------------------------------------------------
62: public MapIterator mapIterator() {
63: return getBidiMap().mapIterator();
64: }
65:
66: public Object getKey(Object value) {
67: return getBidiMap().getKey(value);
68: }
69:
70: public Object removeValue(Object value) {
71: return getBidiMap().removeValue(value);
72: }
73:
74: public BidiMap inverseBidiMap() {
75: return getBidiMap().inverseBidiMap();
76: }
77:
78: }
|