Java Doc for FeatureCollection.java in  » GIS » GeoTools-2.4.1 » org » geotools » feature » 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 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.geotools.feature.FeatureCollection

All known Subclasses:   org.geotools.data.store.DataFeatureCollection,  org.geotools.feature.collection.SubFeatureCollection,  org.geotools.feature.MockFeatureCollection,  org.geotools.data.store.ReprojectingFeatureCollection,  org.geotools.feature.DefaultFeatureCollection,  org.geotools.data.store.MaxFeaturesFeatureCollection,  org.geotools.data.store.FilteringFeatureCollection,  org.geotools.feature.collection.AbstractFeatureCollection,  org.geotools.data.store.ReTypingFeatureCollection,  org.geotools.data.jdbc.collection.JDBCFeatureCollection,
FeatureCollection
public interface FeatureCollection extends ResourceCollection,Feature(Code)
Represents a collection of features.

Implementations (and client code) should adhere to the rules set forth by java.util.Collection. That is, some methods are optional to implement, and may throw an UnsupportedOperationException.

FeatureCollection house rules:

  • FeatureCollection.close( iterator ) must be called (see example below)
  • Features are not specifically ordered within the FeatureCollection (see FeatureList)
  • Two instances cannot exist with the same Feature ID (Feature contract)
  • (unsure) the same Instance can be in the collection more then once
In programmer speak a FeatureCollection is a "Bag" with an index based ID.

Life Cycle of Iterator

We have also adopted an additional constraint on the use of iterator. You must call FeatureCollection.close( iterator ) to allow FeatureCollection to clean up any operating system resources used to acces information.

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 );
 }
 

Handy Tip: Although many resource backed collections will choose to release resources at when the iterator has reached the end of its contents this is not something you should rely on.

Notes for FeatureCollection Implementors

Many users will be treating this as a straight forward Collection, there code will break often enough due to latency - try and close up resources for them when you can detect that an Iterator is not useful anymore.

Collections are used in two fashions, basically as you see them, and also as "range" for common opperations. You can see this with List.subCollection( Filter ). Existing RnD effort is going towards supporting this kind of use at the FeatureCollection level.


See Also:    java.util.Collection, org.geotools.Feature
author:
   Ian Turton, CCG
author:
   Rob Hranac, VFNY
author:
   Ian Schneider, USDA-ARS
author:
   Jody Garnett, Refractions Research, Inc.
version:
   $Id: FeatureCollection.java 28248 2007-12-04 17:47:43Z jgarnett $




Method Summary
 voidaccepts(FeatureVisitor visitor, ProgressListener progress)
     Will visit the contents of the feature collection.
 voidaddListener(CollectionListener listener)
     Adds a listener for collection events.
public  voidclose(FeatureIterator close)
     Clean up any resources assocaited with this iterator in a manner similar to JDO collections.
public  voidclose(Iterator close)
     Clean up after any resources assocaited with this itterator in a manner similar to JDO collections.
 FeatureIteratorfeatures()
     Obtain a FeatureIterator of the Features within this collection.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification.

 FeatureTypegetFeatureType()
     Gets a reference to the type of this feature collection.
 FeatureTypegetSchema()
     The schema for the child features of this collection.

There is a difference between getFeatureType() and getSchema()represents the LCD FeatureType that best represents the contents of this collection.

  • The degenerate case returns the "_Feature" FeatureType, where the onlything known is that the contents are Features.
  • For a collection backed by a shapefiles (or database tables) the FeatureType returned by getSchema() will complete describe each and every child in the collection.
  • For mixed content FeatureCollections you will need to check the FeatureType of each Feature as it is retrived from the collection

The method getSchema() is named for compatability with the geotools 2.0 API.

 voidremoveListener(CollectionListener listener)
     Removes a listener for collection events.
public  FeatureListsort(SortBy order)
    
public  FeatureCollectionsubCollection(Filter filter)
     FeatureCollection "view" indicated by provided filter.

The contents of the returned FeatureCollection are determined by applying the provider Filter to the entire contents of this FeatureCollection.




Method Detail
accepts
void accepts(FeatureVisitor visitor, ProgressListener progress) throws IOException(Code)
Will visit the contents of the feature collection.

Note: When performing aggregate calculations please consider using the Filter/Expression/Function API as it may be optimized.


Parameters:
  visitor -
throws:
  IOException -



addListener
void addListener(CollectionListener listener) throws NullPointerException(Code)
Adds a listener for collection events.

When this collection is backed by live data the event notification will follow the guidelines outlined by FeatureListner.


Parameters:
  listener - The listener to add
throws:
  NullPointerException - If the listener is null.



close
public void close(FeatureIterator close)(Code)
Clean up any resources assocaited with this iterator in a manner similar to JDO collections.

You must be sure to allow null values, this is because in a try/finally block client code may not be sure if they have actualy succeed in assign a value to an iterator they wish to ensure is closed. By permiting null as an api we prevent a null check in lots of finally statements.

Note: Because of FeatureReader using an interator internally, there is only one implementation of this method that makes any sense:


 public void close( FeatureIterator iterator) {
 if( iterator != null ) iterator.close();
 }
 




close
public void close(Iterator close)(Code)
Clean up after any resources assocaited with this itterator 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 -



features
FeatureIterator features()(Code)
Obtain a FeatureIterator of the Features within this collection.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

This is almost equivalent to:

  • a Type-Safe call to: getAttribute(getFeatureType().getAttributeType(0).getName()).iterator();.
  • A Java 5:Iterator<Feature>

Example (safe) use:

 FeatureIterator iterator=collection.features();
 try {
 while( iterator.hasNext()  ){
 Feature feature = iterator.next();
 System.out.println( feature.getID() );
 }
 }
 finally {
 collection.close( iterator );
 }
 

GML Note: The contents of this iterator are considered to be defined by featureMember tags (and/or the single allowed FeatureMembers tag). Please see getFeatureType for more details.

A FeatureIterator.



getFeatureType
FeatureType getFeatureType()(Code)
Gets a reference to the type of this feature collection.

There are several limitations on the use of FeatureType with respect to a FeatureCollection.

GML 3.x: all FeatureCollections decend from gml:AbstractFeatureCollectionType:

  • featureMember 0..* allows _Feature or xlink:ref
  • featureMembers 0..1 contents treated as _Feature
The contents defined in this manner is returned the collection iterator() method.

GML 3.x: gml:AbstractFeatureCollectionType decends from gml:BoundedFeatureType:

  • metaDataProperty 0..*
  • description 0..1
  • name 0..*
  • boundedBy 1..1 (required)
  • location 0..1
The value of the boundedBy attribute should be derived from the contents of the collection.

Implementation Notes

There is a difference between getFeatureType() and getSchema(), getSchema is named for historical reasons and reprensets the LCD FeatureType that best represents the contents of this collection.

  • The degenerate case returns the "_Feature" FeatureType, where the onlything known is that the contents are Features.
  • For a collection backed by a shapefiles (or database tables) the FeatureType returned by getSchema() will complete describe each and every child in the collection.
  • For mixed content FeatureCollections you will need to check the FeatureType of each Feature as it is retrived from the collection

A reference to this collections type



getSchema
FeatureType getSchema()(Code)
The schema for the child features of this collection.

There is a difference between getFeatureType() and getSchema()represents the LCD FeatureType that best represents the contents of this collection.

  • The degenerate case returns the "_Feature" FeatureType, where the onlything known is that the contents are Features.
  • For a collection backed by a shapefiles (or database tables) the FeatureType returned by getSchema() will complete describe each and every child in the collection.
  • For mixed content FeatureCollections you will need to check the FeatureType of each Feature as it is retrived from the collection

The method getSchema() is named for compatability with the geotools 2.0 API. In the Geotools 2.2 time frame we should be able to replace this method with a careful check of getFeatureType() and its attributes.

FeatureType describing the "common" schema to all child features of this collection



removeListener
void removeListener(CollectionListener listener) throws NullPointerException(Code)
Removes a listener for collection events.
Parameters:
  listener - The listener to remove
throws:
  NullPointerException - If the listener is null.



sort
public FeatureList sort(SortBy order)(Code)
collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo")
Parameters:
  order -



subCollection
public FeatureCollection subCollection(Filter filter)(Code)
FeatureCollection "view" indicated by provided filter.

The contents of the returned FeatureCollection are determined by applying the provider Filter to the entire contents of this FeatureCollection. The result is "live" and modifications will be shared.

This method is used cut down on the number of filter based methods required for a useful FeatureCollection construct. The FeatureCollections returned really should be considered as a temporary "view" used to control the range of a removeAll, or modify operation.

Example Use:


 collection.subCollection( filter ).clear();
 
The above recommended use is agreement with the Collections API precident of List.subList( start, end ).

The results of subCollection:

  • are to be considered unordered
  • may be an ordered FeatureList if requested when sortBy is indicated


See Also:   FeatureList
Parameters:
  filter - FeatureCollection identified as subset.



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