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