Java Doc for AbstractCollection.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.AbstractCollection

AbstractCollection
abstract public class AbstractCollection implements Collection<E>(Code)
This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.

To implement an unmodifiable collection, the programmer needs only to extend this class and provide implementations for the iterator and size methods. (The iterator returned by the iterator method must implement hasNext and next.)

To implement a modifiable collection, the programmer must additionally override this class's add method (which otherwise throws an UnsupportedOperationException), and the iterator returned by the iterator method must additionally implement its remove method.

The programmer should generally provide a void (no argument) and Collection constructor, as per the recommendation in the Collection interface specification.

The documentation for each non-abstract method in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation.

This class is a member of the Java Collections Framework.
author:
   Josh Bloch
author:
   Neal Gafter
version:
   1.44, 05/05/07
See Also:   Collection
since:
   1.2




Constructor Summary
protected  AbstractCollection()
     Sole constructor.

Method Summary
public  booleanadd(E e)
    

This implementation always throws an UnsupportedOperationException.

public  booleanaddAll(Collection<? extends E> c)
    

This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.

public  voidclear()
    

This implementation iterates over this collection, removing each element using the Iterator.remove operation.

public  booleancontains(Object o)
    

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.

public  booleancontainsAll(Collection c)
    

This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection.

public  booleanisEmpty()
    

This implementation returns size() == 0.

abstract public  Iterator<E>iterator()
     Returns an iterator over the elements contained in this collection.
public  booleanremove(Object o)
    

This implementation iterates over the collection looking for the specified element.

public  booleanremoveAll(Collection c)
    

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection.

public  booleanretainAll(Collection c)
    

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection.

abstract public  intsize()
    
public  Object[]toArray()
    

This implementation returns an array containing all the elements returned by this collection's iterator, in the same order, stored in consecutive elements of the array, starting with index 0 . The length of the returned array is equal to the number of elements returned by the iterator, even if the size of this collection changes during iteration, as might happen if the collection permits concurrent modification during iteration.

public  T[]toArray(T[] a)
    

This implementation returns an array containing all the elements returned by this collection's iterator in the same order, stored in consecutive elements of the array, starting with index 0 . If the number of elements returned by the iterator is too large to fit into the specified array, then the elements are returned in a newly allocated array with length equal to the number of elements returned by the iterator, even if the size of this collection changes during iteration, as might happen if the collection permits concurrent modification during iteration.

public  StringtoString()
     Returns a string representation of this collection.


Constructor Detail
AbstractCollection
protected AbstractCollection()(Code)
Sole constructor. (For invocation by subclass constructors, typically implicit.)




Method Detail
add
public boolean add(E e)(Code)

This implementation always throws an UnsupportedOperationException.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
throws:
  IllegalArgumentException -
throws:
  IllegalStateException -




addAll
public boolean addAll(Collection<? extends E> c)(Code)

This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.

Note that this implementation will throw an UnsupportedOperationException unless add is overridden (assuming the specified collection is non-empty).
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
throws:
  IllegalArgumentException -
throws:
  IllegalStateException -
See Also:   AbstractCollection.add(Object)




clear
public void clear()(Code)

This implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.
throws:
  UnsupportedOperationException -




contains
public boolean contains(Object o)(Code)

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
throws:
  ClassCastException -
throws:
  NullPointerException -




containsAll
public boolean containsAll(Collection c)(Code)

This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.
throws:
  ClassCastException -
throws:
  NullPointerException -
See Also:   AbstractCollection.contains(Object)




isEmpty
public boolean isEmpty()(Code)

This implementation returns size() == 0.




iterator
abstract public Iterator<E> iterator()(Code)
Returns an iterator over the elements contained in this collection. an iterator over the elements contained in this collection



remove
public boolean remove(Object o)(Code)

This implementation iterates over the collection looking for the specified element. If it finds the element, it removes the element from the collection using the iterator's remove method.

Note that this implementation throws an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection contains the specified object.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -




removeAll
public boolean removeAll(Collection c)(Code)

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
See Also:   AbstractCollection.remove(Object)
See Also:   AbstractCollection.contains(Object)




retainAll
public boolean retainAll(Collection c)(Code)

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
throws:
  UnsupportedOperationException -
throws:
  ClassCastException -
throws:
  NullPointerException -
See Also:   AbstractCollection.remove(Object)
See Also:   AbstractCollection.contains(Object)




size
abstract public int size()(Code)



toArray
public Object[] toArray()(Code)

This implementation returns an array containing all the elements returned by this collection's iterator, in the same order, stored in consecutive elements of the array, starting with index 0 . The length of the returned array is equal to the number of elements returned by the iterator, even if the size of this collection changes during iteration, as might happen if the collection permits concurrent modification during iteration. The size method is called only as an optimization hint; the correct result is returned even if the iterator returns a different number of elements.

This method is equivalent to:

 
 List list = new ArrayList(size());  for (E e : this)  list.add(e);  return list.toArray();  



toArray
public T[] toArray(T[] a)(Code)

This implementation returns an array containing all the elements returned by this collection's iterator in the same order, stored in consecutive elements of the array, starting with index 0 . If the number of elements returned by the iterator is too large to fit into the specified array, then the elements are returned in a newly allocated array with length equal to the number of elements returned by the iterator, even if the size of this collection changes during iteration, as might happen if the collection permits concurrent modification during iteration. The size method is called only as an optimization hint; the correct result is returned even if the iterator returns a different number of elements.

This method is equivalent to:

 
 List list = new ArrayList(size());  for (E e : this)  list.add(e);  return list.toArray(a);  

throws:
  ArrayStoreException -
throws:
  NullPointerException -



toString
public String toString()(Code)
Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object) . a string representation of this collection



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.