KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > bidimap > AbstractSortedBidiMapDecorator


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.bidimap;
17
18 import java.util.Comparator JavaDoc;
19 import java.util.SortedMap JavaDoc;
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: 1.4 $ $Date: 2004/02/18 00:57:39 $
37  *
38  * @author Stephen Colebourne
39  */

40 public abstract class AbstractSortedBidiMapDecorator
41         extends 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 JavaDoc comparator() {
68         return getSortedBidiMap().comparator();
69     }
70
71     public SortedMap JavaDoc subMap(Object JavaDoc fromKey, Object JavaDoc toKey) {
72         return getSortedBidiMap().subMap(fromKey, toKey);
73     }
74
75     public SortedMap JavaDoc headMap(Object JavaDoc toKey) {
76         return getSortedBidiMap().headMap(toKey);
77     }
78
79     public SortedMap JavaDoc tailMap(Object JavaDoc fromKey) {
80         return getSortedBidiMap().tailMap(fromKey);
81     }
82
83 }
84
Popular Tags