KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > bag > AbstractBagDecorator


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

33 public abstract class AbstractBagDecorator
34         extends AbstractCollectionDecorator implements Bag {
35
36     /**
37      * Constructor only used in deserialization, do not use otherwise.
38      * @since Commons Collections 3.1
39      */

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

50     protected AbstractBagDecorator(Bag bag) {
51         super(bag);
52     }
53
54     /**
55      * Gets the bag being decorated.
56      *
57      * @return the decorated bag
58      */

59     protected Bag getBag() {
60         return (Bag) getCollection();
61     }
62
63     //-----------------------------------------------------------------------
64
public int getCount(Object JavaDoc object) {
65         return getBag().getCount(object);
66     }
67
68     public boolean add(Object JavaDoc object, int count) {
69         return getBag().add(object, count);
70     }
71
72     public boolean remove(Object JavaDoc object, int count) {
73         return getBag().remove(object, count);
74     }
75
76     public Set JavaDoc uniqueSet() {
77         return getBag().uniqueSet();
78     }
79
80 }
81
Popular Tags