org.apache.commons.collections.bag

Class UnmodifiableBag

Implemented Interfaces:
Serializable, Bag, Collection, Unmodifiable

public final class UnmodifiableBag
extends AbstractBagDecorator
implements Unmodifiable, Serializable

Decorates another Bag to ensure it can't be altered.

This class is Serializable from Commons Collections 3.1.

Version:
$Revision: 1.8 $ $Date: 2004/06/02 21:56:19 $
Author:
Stephen Colebourne
Since:
Commons Collections 3.0

Field Summary

Fields inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator

collection

Method Summary

boolean
add(Object object)
boolean
add(Object object, int count)
boolean
addAll(Collection coll)
void
clear()
static Bag
decorate(Bag bag)
Factory method to create an unmodifiable bag.
Iterator
iterator()
boolean
remove(Object object)
boolean
remove(Object object, int count)
boolean
removeAll(Collection coll)
boolean
retainAll(Collection coll)
Set
uniqueSet()

Methods inherited from class org.apache.commons.collections.bag.AbstractBagDecorator

add, getBag, getCount, remove, uniqueSet

Methods inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator

add, addAll, clear, contains, containsAll, equals, getCollection, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString

Method Details

add

public boolean add(Object object)
Specified by:
add in interface Bag
Overrides:
add in interface AbstractCollectionDecorator

add

public boolean add(Object object,
                   int count)
Specified by:
add in interface Bag
Overrides:
add in interface AbstractBagDecorator

addAll

public boolean addAll(Collection coll)
Overrides:
addAll in interface AbstractCollectionDecorator

clear

public void clear()
Overrides:
clear in interface AbstractCollectionDecorator

decorate

public static Bag decorate(Bag bag)
Factory method to create an unmodifiable bag.

If the bag passed in is already unmodifiable, it is returned.

Parameters:
bag - the bag to decorate, must not be null
Returns:
an unmodifiable Bag

iterator

public Iterator iterator()
Specified by:
iterator in interface Bag
Overrides:
iterator in interface AbstractCollectionDecorator

remove

public boolean remove(Object object)
Specified by:
remove in interface Bag
Overrides:
remove in interface AbstractCollectionDecorator

remove

public boolean remove(Object object,
                      int count)
Specified by:
remove in interface Bag
Overrides:
remove in interface AbstractBagDecorator

removeAll

public boolean removeAll(Collection coll)
Specified by:
removeAll in interface Bag
Overrides:
removeAll in interface AbstractCollectionDecorator

retainAll

public boolean retainAll(Collection coll)
Specified by:
retainAll in interface Bag
Overrides:
retainAll in interface AbstractCollectionDecorator

uniqueSet

public Set uniqueSet()
Specified by:
uniqueSet in interface Bag
Overrides:
uniqueSet in interface AbstractBagDecorator

Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.