KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > map > AbstractSortedMapDecorator


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.map;
17
18 import java.util.Comparator JavaDoc;
19 import java.util.SortedMap JavaDoc;
20
21 /**
22  * Provides a base decorator that enables additional functionality to be added
23  * to a Map 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 set/collection 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: 1.5 $ $Date: 2004/04/02 21:16:50 $
35  *
36  * @author Stephen Colebourne
37  */

38 public abstract class AbstractSortedMapDecorator
39         extends AbstractMapDecorator implements SortedMap JavaDoc {
40
41     /**
42      * Constructor only used in deserialization, do not use otherwise.
43      * @since Commons Collections 3.1
44      */

45     protected AbstractSortedMapDecorator() {
46         super();
47     }
48
49     /**
50      * Constructor that wraps (not copies).
51      *
52      * @param map the map to decorate, must not be null
53      * @throws IllegalArgumentException if the collection is null
54      */

55     public AbstractSortedMapDecorator(SortedMap JavaDoc map) {
56         super(map);
57     }
58
59     /**
60      * Gets the map being decorated.
61      *
62      * @return the decorated map
63      */

64     protected SortedMap JavaDoc getSortedMap() {
65         return (SortedMap JavaDoc) map;
66     }
67
68     //-----------------------------------------------------------------------
69
public Comparator JavaDoc comparator() {
70         return getSortedMap().comparator();
71     }
72
73     public Object JavaDoc firstKey() {
74         return getSortedMap().firstKey();
75     }
76
77     public SortedMap JavaDoc headMap(Object JavaDoc toKey) {
78         return getSortedMap().headMap(toKey);
79     }
80
81     public Object JavaDoc lastKey() {
82         return getSortedMap().lastKey();
83     }
84
85     public SortedMap JavaDoc subMap(Object JavaDoc fromKey, Object JavaDoc toKey) {
86         return getSortedMap().subMap(fromKey, toKey);
87     }
88
89     public SortedMap JavaDoc tailMap(Object JavaDoc fromKey) {
90         return getSortedMap().tailMap(fromKey);
91     }
92
93 }
94
Popular Tags