KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > set > AbstractSortedSetDecorator


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.set;
17
18 import java.util.Comparator JavaDoc;
19 import java.util.Set JavaDoc;
20 import java.util.SortedSet JavaDoc;
21
22 /**
23  * Decorates another <code>SortedSet</code> to provide additional behaviour.
24  * <p>
25  * Methods are forwarded directly to the decorated set.
26  *
27  * @since Commons Collections 3.0
28  * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:03 $
29  *
30  * @author Stephen Colebourne
31  */

32 public abstract class AbstractSortedSetDecorator extends AbstractSetDecorator implements SortedSet JavaDoc {
33
34     /**
35      * Constructor only used in deserialization, do not use otherwise.
36      * @since Commons Collections 3.1
37      */

38     protected AbstractSortedSetDecorator() {
39         super();
40     }
41
42     /**
43      * Constructor that wraps (not copies).
44      *
45      * @param set the set to decorate, must not be null
46      * @throws IllegalArgumentException if set is null
47      */

48     protected AbstractSortedSetDecorator(Set JavaDoc set) {
49         super(set);
50     }
51
52     /**
53      * Gets the sorted set being decorated.
54      *
55      * @return the decorated set
56      */

57     protected SortedSet JavaDoc getSortedSet() {
58         return (SortedSet JavaDoc) getCollection();
59     }
60     
61     //-----------------------------------------------------------------------
62
public SortedSet JavaDoc subSet(Object JavaDoc fromElement, Object JavaDoc toElement) {
63         return getSortedSet().subSet(fromElement, toElement);
64     }
65
66     public SortedSet JavaDoc headSet(Object JavaDoc toElement) {
67         return getSortedSet().headSet(toElement);
68     }
69
70     public SortedSet JavaDoc tailSet(Object JavaDoc fromElement) {
71         return getSortedSet().tailSet(fromElement);
72     }
73
74     public Object JavaDoc first() {
75         return getSortedSet().first();
76     }
77
78     public Object JavaDoc last() {
79         return getSortedSet().last();
80     }
81
82     public Comparator JavaDoc comparator() {
83         return getSortedSet().comparator();
84     }
85
86 }
87
Popular Tags