Java Doc for AbstractResourceCollection.java in  » GIS » GeoTools-2.4.1 » org » geotools » feature » iso » collection » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.feature.iso.collection 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.AbstractCollection
      org.geotools.feature.iso.collection.AbstractResourceCollection

All known Subclasses:   org.geotools.feature.iso.collection.AbstractResourceList,  org.geotools.feature.iso.collection.AbstractSimpleFeatureCollection,  org.geotools.feature.iso.collection.SubFeatureCollection,  org.geotools.feature.iso.collection.AbstractFeatureCollection,
AbstractResourceCollection
abstract public class AbstractResourceCollection extends AbstractCollection implements ResourceCollection(Code)
Collection supporting close( Iterator ).

This implementation is a port of java.util.Collection with support for the use of close( Iterator ). This will allow subclasses that make use of resources during iterator() to be uses safely.

Subclasses are reminded that they should construct their Iterator to return system resources once content has been exhuasted. While this class is safe, and we remind users, not all libraries that accept collections can be hacked.

How to Collectionify Resource Access

We need to do the same things as for use of AbstractCollection - namely:

  • Read-Only: provide implementations for size and openIterator ( w/ hasNext() and next().) and finally closeIteartor( iterator )

  • Modifiable collection Do all of the above and supply add( Object ) let that Iterator do remove()
And of course subclass, we are after all feelign abstract today :-)

Why not play with iterator()? Because we are keeping track of them for later purge()...


author:
   Jody Garnett, Refractions Research, Inc.


Field Summary
final protected  Setopen
    

Constructor Summary
protected  AbstractResourceCollection()
    

Method Summary
public  booleanadd(Object o)
     Implement to support modification.
Parameters:
  o - element whose presence in this collection is to be ensured.
public  booleanaddAll(Collection c)
     Adds all of the elements in the specified collection to this collection (optional operation).
Parameters:
  c - collection whose elements are to be added to this collection.
public  voidclear()
     Removes all of the elements from this collection (optional operation).
final public  voidclose(Iterator close)
     Clean up after any resources assocaited with this iteartor in a manner similar to JDO collections.
abstract protected  voidcloseIterator(Iterator close)
     Please override to cleanup after your own iterators, and any used resources.
public  booleancontains(Object o)
     Returns true if this collection contains the specified element. .

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
Parameters:
  o - object to be checked for containment in this collection.

public  booleancontainsAll(Collection c)
     Returns true if this collection contains all of the elements in the specified collection.
public  booleanisEmpty()
    
final public  Iteratoriterator()
     Please implement!

Note: If you return a ResourceIterator, the default implemntation of close( Iterator ) will know what to do.

abstract protected  IteratoropenIterator()
     Open a resource based Iterator, we will call close( iterator ).
public  voidpurge()
     Close any outstanding resources released by this resources.
public  booleanremove(Object o)
     Removes a single instance of the specified element from this collection, if it is present (optional operation).
public  booleanremoveAll(Collection c)
     Removes from this collection all of its elements that are contained in the specified collection (optional operation).
public  booleanretainAll(Collection c)
     Retains only the elements in this collection that are contained in the specified collection (optional operation).
Parameters:
  c - elements to be retained in this collection.
abstract public  intsize()
     Returns the number of elements in this collection.
public  Object[]toArray()
     Array of all the elements.
public  Object[]toArray(Object[] a)
    
public  StringtoString()
     Returns a string representation of this collection.

Field Detail
open
final protected Set open(Code)
Set of open resource iterators




Constructor Detail
AbstractResourceCollection
protected AbstractResourceCollection()(Code)




Method Detail
add
public boolean add(Object o)(Code)
Implement to support modification.
Parameters:
  o - element whose presence in this collection is to be ensured. true if the collection changed as a result of the call.
throws:
  UnsupportedOperationException - if the add method is notsupported by this collection.
throws:
  NullPointerException - if this collection does not permitnull elements, and the specified element isnull.
throws:
  ClassCastException - if the class of the specified elementprevents it from being added to this collection.
throws:
  IllegalArgumentException - if some aspect of this elementprevents it from being added to this collection.



addAll
public boolean addAll(Collection c)(Code)
Adds all of the elements in the specified collection to this collection (optional operation).
Parameters:
  c - collection whose elements are to be added to this collection. true if this collection changed as a result of thecall.
throws:
  UnsupportedOperationException - if this collection does notsupport the addAll method.
throws:
  NullPointerException - if the specified collection is null.
See Also:   AbstractResourceCollection.add(Object)



clear
public void clear()(Code)
Removes all of the elements from this collection (optional operation).
throws:
  UnsupportedOperationException - if the clear method isnot supported by this collection.



close
final public void close(Iterator close)(Code)
Clean up after any resources assocaited with this iteartor in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
 for( Iterator i=collection.iterator(); i.hasNext();){
 Feature feature = (Feature) i.hasNext();
 System.out.println( feature.getID() );
 }
 }
 finally {
 collection.close( iterator );
 }
 


Parameters:
  close -



closeIterator
abstract protected void closeIterator(Iterator close) throws IOException(Code)
Please override to cleanup after your own iterators, and any used resources.

As an example if the iterator was working off a File then the inputstream should be closed.

Subclass must call super.close( close ) to allow the list of open iterators to be adjusted.


Parameters:
  close - Iterator, will not be null



contains
public boolean contains(Object o)(Code)
Returns true if this collection contains the specified element. .

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
Parameters:
  o - object to be checked for containment in this collection. true if this collection contains the specified element.




containsAll
public boolean containsAll(Collection c)(Code)
Returns true if this collection contains all of the elements in the specified collection.


Parameters:
  c - collection to be checked for containment in this collection. true if this collection contains all of the elementsin the specified collection.
throws:
  NullPointerException - if the specified collection is null.
See Also:   AbstractResourceCollection.contains(Object)




isEmpty
public boolean isEmpty()(Code)
true if this collection contains no elements.



iterator
final public Iterator iterator()(Code)
Please implement!

Note: If you return a ResourceIterator, the default implemntation of close( Iterator ) will know what to do.




openIterator
abstract protected Iterator openIterator() throws IOException(Code)
Open a resource based Iterator, we will call close( iterator ).

Please subclass to provide your own iterator for the the ResourceCollection, note iterator() is implemented to call open() and track the results in for later purge().
Parameters:
  close - Iterator based on resource use




purge
public void purge()(Code)
Close any outstanding resources released by this resources.

This method should be used with great caution, it is however available to allow the use of the ResourceCollection with algorthims that are unaware of the need to close iterators after use.

Example of using a normal Collections utility method:


 Collections.sort( collection );
 collection.purge(); 
 



remove
public boolean remove(Object o)(Code)
Removes a single instance of the specified element from this collection, if it is present (optional operation).
Parameters:
  o - element to be removed from this collection, if present. true if the collection contained the specifiedelement.
throws:
  UnsupportedOperationException - if the remove method isnot supported by this collection.



removeAll
public boolean removeAll(Collection c)(Code)
Removes from this collection all of its elements that are contained in the specified collection (optional operation).


Parameters:
  c - elements to be removed from this collection. true if this collection changed as a result of thecall.
throws:
  UnsupportedOperationException - if the removeAll methodis not supported by this collection.
throws:
  NullPointerException - if the specified collection is null.
See Also:   AbstractResourceCollection.remove(Object)
See Also:   AbstractResourceCollection.contains(Object)




retainAll
public boolean retainAll(Collection c)(Code)
Retains only the elements in this collection that are contained in the specified collection (optional operation).
Parameters:
  c - elements to be retained in this collection. true if this collection changed as a result of thecall.
throws:
  UnsupportedOperationException - if the retainAll methodis not supported by this Collection.
throws:
  NullPointerException - if the specified collection is null.
See Also:   AbstractResourceCollection.remove(Object)
See Also:   AbstractResourceCollection.contains(Object)



size
abstract public int size()(Code)
Returns the number of elements in this collection. Number of items, or Interger.MAX_VALUE



toArray
public Object[] toArray()(Code)
Array of all the elements. an array containing all of the elements in this collection.



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



toString
public String toString()(Code)
Returns a string representation of this collection. a string representation of this collection.



Methods inherited from java.util.AbstractCollection
public boolean add(E e)(Code)(Java Doc)
public boolean addAll(Collection<? extends E> c)(Code)(Java Doc)
public void clear()(Code)(Java Doc)
public boolean contains(Object o)(Code)(Java Doc)
public boolean containsAll(Collection c)(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
abstract public Iterator<E> iterator()(Code)(Java Doc)
public boolean remove(Object o)(Code)(Java Doc)
public boolean removeAll(Collection c)(Code)(Java Doc)
public boolean retainAll(Collection c)(Code)(Java Doc)
abstract public int size()(Code)(Java Doc)
public Object[] toArray()(Code)(Java Doc)
public T[] toArray(T[] a)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

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.