Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Util.Collections
Class CollectionWrapper  view CollectionWrapper download CollectionWrapper.java

java.lang.Object
  extended byUtil.Collections.CollectionWrapper
All Implemented Interfaces:
java.util.Collection, java.lang.Iterable

public class CollectionWrapper
extends java.lang.Object
implements java.util.Collection

CollectionWrapper is a class that acts as a wrapper around another Collection, using it as its backing store. This class isn't meant for direct usage, but rather provides for an easy way for developers to quickly add extra independent behavior to their own specific Collections without having to reimplement all of AbstractCollection's interface

Version:
$Id: CollectionWrapper.java,v 1.1 2003/03/05 08:26:27 joewhaley Exp $

Field Summary
protected  java.util.Collection b
          Collection backing this.
 
Constructor Summary
CollectionWrapper(java.util.Collection c)
          Creates a CollectionWrapper.
 
Method Summary
 boolean add(java.lang.Object o)
          Add an element to this collection.
 boolean addAll(java.util.Collection c)
          Add the contents of a given collection to this collection.
 void clear()
          Clear the collection, such that a subsequent call to isEmpty() would return true.
 boolean contains(java.lang.Object o)
          Test whether this collection contains a given object as one of its elements.
 boolean containsAll(java.util.Collection c)
          Test whether this collection contains every element in a given collection.
 boolean equals(java.lang.Object o)
          Test whether this collection is equal to some object.
 int hashCode()
          Obtain a hash code for this collection.
 boolean isEmpty()
          Test whether this collection is empty, that is, if size() == 0.
 java.util.Iterator iterator()
          Obtain an Iterator over this collection.
 boolean remove(java.lang.Object o)
          Remove a single occurrence of an object from this collection.
 boolean removeAll(java.util.Collection c)
          Remove all elements of a given collection from this collection.
 boolean retainAll(java.util.Collection c)
          Remove all elements of this collection that are not contained in a given collection.
 int size()
          Get the number of elements in this collection.
 java.lang.Object[] toArray()
          Copy the current contents of this collection into an array.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Copy the current contents of this collection into an array.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

b

protected final java.util.Collection b
Collection backing this.

Constructor Detail

CollectionWrapper

public CollectionWrapper(java.util.Collection c)
Creates a CollectionWrapper.

Method Detail

add

public boolean add(java.lang.Object o)
Description copied from interface: java.util.Collection
Add an element to this collection.

Specified by:
add in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection c)
Description copied from interface: java.util.Collection
Add the contents of a given collection to this collection.

Specified by:
addAll in interface java.util.Collection

clear

public void clear()
Description copied from interface: java.util.Collection
Clear the collection, such that a subsequent call to isEmpty() would return true.

Specified by:
clear in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Description copied from interface: java.util.Collection
Test whether this collection contains a given object as one of its elements.

Specified by:
contains in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection c)
Description copied from interface: java.util.Collection
Test whether this collection contains every element in a given collection.

Specified by:
containsAll in interface java.util.Collection

isEmpty

public boolean isEmpty()
Description copied from interface: java.util.Collection
Test whether this collection is empty, that is, if size() == 0.

Specified by:
isEmpty in interface java.util.Collection

iterator

public java.util.Iterator iterator()
Description copied from interface: java.util.Collection
Obtain an Iterator over this collection.

Specified by:
iterator in interface java.util.Collection

remove

public boolean remove(java.lang.Object o)
Description copied from interface: java.util.Collection
Remove a single occurrence of an object from this collection. That is, remove an element e, if one exists, such that o == null ? e == null : o.equals(e).

Specified by:
remove in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection c)
Description copied from interface: java.util.Collection
Remove all elements of a given collection from this collection. That is, remove every element e such that c.contains(e).

Specified by:
removeAll in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Description copied from interface: java.util.Collection
Remove all elements of this collection that are not contained in a given collection. That is, remove every element e such that !c.contains(e).

Specified by:
retainAll in interface java.util.Collection

size

public int size()
Description copied from interface: java.util.Collection
Get the number of elements in this collection.

Specified by:
size in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Description copied from interface: java.util.Collection
Copy the current contents of this collection into an array.

Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Description copied from interface: java.util.Collection
Copy the current contents of this collection into an array. If the array passed as an argument has length less than the size of this collection, an array of the same run-time type as a, and length equal to the size of this collection, is allocated using Reflection. Otherwise, a itself is used. The elements of this collection are copied into it, and if there is space in the array, the following element is set to null. The resultant array is returned. Note: The fact that the following element is set to null is only useful if it is known that this collection does not contain any null elements.

Specified by:
toArray in interface java.util.Collection

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


equals

public boolean equals(java.lang.Object o)
Description copied from interface: java.util.Collection
Test whether this collection is equal to some object. The Collection interface does not explicitly require any behaviour from this method, and it may be left to the default implementation provided by Object. The Set and List interfaces do, however, require specific behaviour from this method.

If an implementation of Collection, which is not also an implementation of Set or List, should choose to implement this method, it should take care to obey the contract of the equals method of Object. In particular, care should be taken to return false when o is a Set or a List, in order to preserve the symmetry of the relation.

Specified by:
equals in interface java.util.Collection

hashCode

public int hashCode()
Description copied from interface: java.util.Collection
Obtain a hash code for this collection. The Collection interface does not explicitly require any behaviour from this method, and it may be left to the default implementation provided by Object. The Set and List interfaces do, however, require specific behaviour from this method.

If an implementation of Collection, which is not also an implementation of Set or List, should choose to implement this method, it should take care to obey the contract of the hashCode method of Object. Note that this method renders it impossible to correctly implement both Set and List, as the required implementations are mutually exclusive.

Specified by:
hashCode in interface java.util.Collection