Java Doc for Feature.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.Feature

Feature
public interface Feature (Code)

Represents a feature of arbitrary complexity.

This interface answers the question: How do we store feature attributes? (The answer to the more useful question, How do we access feature attribute, is contained in the Expression class.

Warning: We are revising the Feature Model to be more complete in the next round of GeoTools. If you do any data access in your classes please try and make use of Expression to access your information, if you do this you will not be affected by the change (beyond a few search and replace operations).

The most generic approach would be to pass all feature attributes as objects and use Java variable and method references to access them. However, this is also the most useless approach because it establishes no unified methods for getting attribute information (since it is totally Object dependent), without elaborate reflection/introspection, which is inconvenient to use. Unlike its FeatureType counterpart, this interface does not attempt to serve as a typing framework. Rather, multiple implementations of this interface should generally be for performance reasons.

This interface serves two important purposes. Most obviously, it gives users of features a unified, consistent framework for accessing and manipulating feature data. Perhaps more importantly, the FeatureType and Feature interfaces also work together to give implementers a framework for constraining and enforcing constraints (respectively) on allowed feature types. As such, this interface is as general as possible in terms of the types of objects to which it provides access. Keep in mind that creating new features is relatively difficult and should only be done to optimize performance for highly constrained schema types. For the vast majority of schemas, the generic feature implementation will work fine.

Notes for Feature Clients:
Clients should always use feature accessor methods (getAttribute and setAttribute) to modify the state of internal attribute objects. It is possible that some feature implementations will allow object state changes by clients outside of the class, but this is strongly discouraged. In general, feature implementations will make defensive copies of objects passed to clients and it is therefore not guaranteed that client state changes that take place outside of the feature will be reflected in the internal state of the feature object! For this reason, clients should always use the set methods to change feature attribute object states!

Notes for Feature Implementers:
It is the responsibility of the implementing class to ensure that the Feature attributes stay synchronized with its FeatureType definition. Features should never get out of synch with their declared schemas and should never alter their schemas! There are four conventions of which implementers of this interface must be aware in order to successfully manage a Feature:

  1. FeatureType Reference
    Features must always hold a single (immutable: see FeatureType) schema reference and this reference should not be altered after a feature has been created. To ensure this, is is strongly recommended that features take a valid reference to an existing immutable schema in its constructor and declare that reference final.
  2. Default Geometry
    Each feature must have a default geometry, but this primary geometry may be null. This means that a feature may contain no geometries, but it must always have a method for accessing a geometry object (even if it is null). It also means that a feature with multiple geometries must pick one as its default geometry. Note that the designation of the default geometry is stored as part of the FeatureType and is therefore immmutable.
  3. Attributes
    All features contain zero or more attributes, which can have one or more occurrences inside the feature. Attributes may be any valid Java object. If attributes are instances of Feature, they are handled specially by the Feature methods, in that their attributes may be accessed directly by their containing feature. All other object variables and methods must be accessed through the objects themselves. It is up to implementers of Feature to make sure that each attribute value conforms to its internal schema. A feature should never reach a state where its attributes (or sub-attributes) do not conform to their FeatureType definitions. There are three ways to implement this. The first is to simply make features immutable; however, given the ubiquity and required flexibility of features, this is likely not possible. The second (and second easiest), is to make all feature attributes immutable. For most cases, this is probably the best way to handle this issue. The third way, is to never give out a reference that would allow a client to change an attribute object's class (most obviously, an array reference). Generally speaking, features should attempt to minimize external object references by attempting to clone incoming attributes before adding them and outgoing attributes before sending them. For features with non-cloneable attributes, of course, this is not possible, so this is left to the discretion of the implementor.
  4. Constructors
    Constructors should take arguments with enough information to create a valid representation of the feature. They should also always include a valid schema that can be used to check the proposed attributes. This is necessary to ensure that the feature is always in a valid state, relative to its schema.
  5. hashCode() and equals(Object other)
    Determining equality and equivalence for Feature instances is of utmost importance. This must be done in a constistent manner, as many other areas of geotools will rely on these relations. See java.lang.Object for details.

author:
   James Macgill, CCG
author:
   Rob Hranac, TOPP
author:
   Ian Schneider, USDA-ARS
author:
   dzwiers
version:
   $Id: Feature.java 27002 2007-09-17 03:01:53Z jdeolive $
See Also:   org.geotools.feature.FeatureType
See Also:   org.geotools.feature.DefaultFeature

Inner Class :final static class NULL implements Comparable



Method Summary
 ObjectgetAttribute(String xPath)
     Gets an attribute for this feature at the location specified by xPath. Due to the complex nature of xpath, a List of all valid values will be returned when an attribute is requested.
 ObjectgetAttribute(int index)
     Gets an attribute by the given zero-based index.
 Object[]getAttributes(Object[] attributes)
     Copy all the attributes of this Feature into the given array.
 ReferencedEnvelopegetBounds()
     Get the total bounds of this feature which is calculated by doing a union of the bounds of each geometry this feature is associated with.
 GeometrygetDefaultGeometry()
     Gets the default geometry for this feature.
 FeatureTypegetFeatureType()
     Gets a reference to the schema for this feature.
 StringgetID()
     Gets the unique feature ID for this feature.
 intgetNumberOfAttributes()
     Get the number of attributes this feature has.
 voidsetAttribute(int position, Object val)
     Sets an attribute by the given zero-based index.
 voidsetAttribute(String xPath, Object attribute)
     Sets a single attribute for this feature, passed as a complex object.
 voidsetDefaultGeometry(Geometry geometry)
     Sets the default geometry for this feature.



Method Detail
getAttribute
Object getAttribute(String xPath)(Code)
Gets an attribute for this feature at the location specified by xPath. Due to the complex nature of xpath, a List of all valid values will be returned when an attribute is requested. These values can range from complete Feature Collections to single primative attribute values. When a particular instance of the Attribute is requested, then the Object will be returned. Simply put, in the general case we are assuming the existance of multiplicity, so specify which instance you want or you get them all. Example of getting a list: ./road returns the List of road attribute instances Example of getting an Object: ./road[0] returns the first road
Parameters:
  xPath - XPath representation of attribute location. A List of copies of the requested attribute, null if therequested xpath is not found, or NULL_ATTRIBUTE.



getAttribute
Object getAttribute(int index)(Code)
Gets an attribute by the given zero-based index. This index is based on the values within the Feature as opposed to the AttributeType declaration. To get the values for the 5th attributeType, use the schema to determine the xPath and class the getAttribute(xPath) method.
Parameters:
  index - The requested index. Must be 0 <= idx <getNumberOfAttributes(). A copy of the requested attribute, or NULL_ATTRIBUTE.
See Also:   Feature.getAttribute(String)



getAttributes
Object[] getAttributes(Object[] attributes)(Code)
Copy all the attributes of this Feature into the given array. If the argument array is null, a new one will be created. Gets all attributes from this feature, returned as a complex object array. This array comes with no metadata, so to interpret this collection the caller class should ask for the schema as well. This array may have multiple entries for each AttributeType depending on the AttributeType's multiplicity.
Parameters:
  attributes - An array to copy attributes into. May be null. The array passed in, or a new one if null.



getBounds
ReferencedEnvelope getBounds()(Code)
Get the total bounds of this feature which is calculated by doing a union of the bounds of each geometry this feature is associated with.

This method will return an empty Envelope if the feature contains no geometry information.

An Envelope containing the total bounds of this Feature.



getDefaultGeometry
Geometry getDefaultGeometry()(Code)
Gets the default geometry for this feature.

This method will return null if no DefaultGeometry has been defined by the schema.

Default geometry for this feature, or null



getFeatureType
FeatureType getFeatureType()(Code)
Gets a reference to the schema for this feature. A reference to this feature's schema.



getID
String getID()(Code)
Gets the unique feature ID for this feature. Unique identifier for this feature.



getNumberOfAttributes
int getNumberOfAttributes()(Code)
Get the number of attributes this feature has. This is NOT simply a convenience method for calling getFeatureType().getNumberOfAttributes(). This is the same as calling getAttributes(null).length. This represents the number of actual attribute values in the feature, and may differ from the number of AttributeTypes defined in the FeatureType based on the multiplicity of the AttributeTypes. The total number of attributes this Feature contains.



setAttribute
void setAttribute(int position, Object val) throws IllegalAttributeException, ArrayIndexOutOfBoundsException(Code)
Sets an attribute by the given zero-based index. This index is based on the values within the Feature as opposed to the AttributeType declaration. To get the values for the 5th attributeType, use the schema to determine the xPath and class the setAttribute(xPath,val) method.
Parameters:
  position - The requested index. Must be 0 <= idx <getNumberOfAttributes()
Parameters:
  val - An object representing the attribute being set
throws:
  IllegalAttributeException - if the passed in val does not validateagainst the AttributeType at that position.
throws:
  ArrayIndexOutOfBoundsException - if an invalid position is given
See Also:   Feature.setAttribute(StringObject)



setAttribute
void setAttribute(String xPath, Object attribute) throws IllegalAttributeException(Code)
Sets a single attribute for this feature, passed as a complex object. If the attribute does not exist or the object does not conform to the internal schema, an exception is thrown. Checking this is, of course, left to the feature to do internally. Well behaved features should always fully check the passed attributes against thire schema before adding them. NOTE: The xPath may contain instance information about multiplicity, for example: ./road[3] which is the third road attribute in this feature.
Parameters:
  xPath - XPath representation of attribute location.
Parameters:
  attribute - Feature attribute to set.
throws:
  IllegalAttributeException - If the attribute is illegal for thepath specified.



setDefaultGeometry
void setDefaultGeometry(Geometry geometry) throws IllegalAttributeException(Code)
Sets the default geometry for this feature.
Parameters:
  geometry - The geometry to set.
throws:
  IllegalAttributeException - If the AttributeType is not ageometry, or is invalid for some other reason.



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