|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.feature.FeatureTypeImpl
This is a sample implementation of the FeatureType API.
The suffix implementation is used to indicat this is a direct, straight forward implementation of the associated interface.
This serves as, my reference implementation, if you have any questions please contact me (jgarnett@refractions.net) or jump on the geotools-devel email list. There is a good chance my understanding is wrong, I expect and want feedback on this implementation.
I especially am interested in:
Constructor Summary | |
protected |
FeatureTypeImpl(java.net.URI namespace,
java.lang.String typeName,
boolean isAbstract,
AttributeType[] attributeTypes,
GeometryAttributeType defaultGeometry,
FeatureType[] ancestors)
No direct construction is "Allowed", please use a FeatureTypeBuilder as per design. |
Method Summary | |
Feature |
create(java.lang.Object[] attributes)
Scheduled for removal in Geotools 2.2, please use FeatureFactory. |
Feature |
create(java.lang.Object[] attributes,
java.lang.String featureID)
Scheduled for removal in Geotools 2.2, please use FeatureFactory. |
Feature |
duplicate(Feature feature)
Create a duplicate of the provided feature, must delegate to an appropriate FeatureFactory create method. |
boolean |
equals(java.lang.Object arg0)
FeatureType check based on namespace, typeName, attributes and ancestors. |
int |
find(AttributeType type)
Find the position of a given AttributeType. |
int |
find(java.lang.String attName)
Find the position of an AttributeType which matches the given String. |
FeatureType[] |
getAncestors()
Obtain an array of this FeatureType's direct ancestors. |
int |
getAttributeCount()
This produces the number of distinct featuretypes avaialble via this schema. |
AttributeType |
getAttributeType(int position)
Gets the schema attributeType at the specified index. |
AttributeType |
getAttributeType(java.lang.String xPath)
Gets the attributeType at this xPath, if the specified attributeType does not exist then null is returned.
|
AttributeType[] |
getAttributeTypes()
AttributeTypes for this FeatureType, all attributes defined by this FeatureType and its super types define schema for feature instances. |
GeometryAttributeType |
getDefaultGeometry()
Gets the default geometry AttributeType. |
java.net.URI |
getNamespace()
Gets the global schema namespace. |
java.lang.String |
getTypeName()
Gets the type name for this schema. |
boolean |
hasAttributeType(java.lang.String xPath)
This is only used twice in the whole geotools code base, and one of those is for a test, so we're removing it from the interface. |
boolean |
isAbstract()
Is this FeatureType an abstract type? |
boolean |
isDescendedFrom(FeatureType type)
This method is implemented by a straight reference to FeatureTypes isDecendedFrom( typeA, typeB ). |
boolean |
isDescendedFrom(java.net.URI namespace,
java.lang.String typeName)
This method is implemented by a straight reference to FeatureTypes isDecendedFrom( type, namespace, typename ). |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.geotools.feature.FeatureType |
hashCode |
Constructor Detail |
protected FeatureTypeImpl(java.net.URI namespace, java.lang.String typeName, boolean isAbstract, AttributeType[] attributeTypes, GeometryAttributeType defaultGeometry, FeatureType[] ancestors)
This interface is *not* marked as final, however every last field is bolted down as private final. Any subclass is stuck using the API, this is negotiable - things are locked down so you have to email me (jgarnett@refractions.net), cause I suspect if you need to change something we should have an API discussion and consider broader changes. (Consider this a volunteer recuritment practice).
Responsibilities:
Method Detail |
public boolean equals(java.lang.Object arg0)
FeatureType
Conceptually FeatureType equality is supped to indicate an exact match based AttributeType and Ancestors. The geotools models includes additional information of namespace and typename.
As far as the geotools data model is concerned any FeatureType implementation should be able to be subsituted for another. (An actually application may provided an implementation that provdes tracking of metadata such as creation history, or support for additional interfaces).
Required implementation:
A sample implementation is provided in FeatureTypes.equals( FeatureType, FeatureType ).
Questions:
Q: You may wonder why namespace and typeName are not enought?
A: Geotools often returns a "limitied" schema in response to a query where only a subset
of the attributes are requested.
Q: Doesn't that still indicate the same schema?
A: Yes it kind of should, a GML application (such as GeoServer) has to actually follow the
application schema and include attributes required by the schema (but not request by the query).
This library is more lax in its treatment, and expects you to uses isDecendedFrom as required.
equals
in interface FeatureType
public java.net.URI getNamespace()
FeatureType
This is often used to record the schema prefix (not the URI) required when writing out this Feature using GML. The supporting application will need to be able to start the GMLWriter off with the correct URI information so everything makes sense.
The Registry interface provided by the data module provides an example of how to store associate FeatureType and namespace information. Please note that you may not have duplicate typeNames in the same Namespace.
getNamespace
in interface FeatureType
public java.lang.String getTypeName()
FeatureType
In GML this must be the element name of the Feature.
getTypeName
in interface FeatureType
public boolean isDescendedFrom(java.net.URI namespace, java.lang.String typeName)
Please consider this a query of this FeatureType's ancestors. For specific modules like GML they may want to do a bit more magic here, not especially encouraged but the API allows for it.
isDescendedFrom
in interface FeatureType
namespace
- The namespace URI to use.typeName
- The typeName.
FeatureType.isDescendedFrom(java.net.URI, java.lang.String)
public boolean isDescendedFrom(FeatureType type)
isDescendedFrom
in interface FeatureType
type
- The type to compare to.
FeatureType.isDescendedFrom(org.geotools.feature.FeatureType)
public boolean isAbstract()
FeatureType
When true is returned instances of this Feature cannot be created, instead a child FeatureType must use this FeatureType as its ancestor.
isAbstract
in interface FeatureType
public FeatureType[] getAncestors()
FeatureType
Example Code:
public FeatureType getAncestors()}
return new FeatureType[]{ getSuper(), };
}
getAncestors
in interface FeatureType
public GeometryAttributeType getDefaultGeometry()
FeatureType
If the FeatureType has more one geometry it is up to the implementor to determine which geometry is the default. If working with multiple geometries it is best to get the attributeTypes and iterate through them, checking for instances of GeometryAttribtueType.
This should just be used a convenience method when it is known that the features do not have multiple geometries.
getDefaultGeometry
in interface FeatureType
public int getAttributeCount()
getAttributeCount
in interface FeatureType
FeatureType.getAttributeCount()
public AttributeType getAttributeType(java.lang.String xPath)
FeatureType
null
is returned.
Question: it is unclear how this interacts with the complete schema defined by this FeatureType and its ancestors (in which a given xpath may refer to several AttributeTypes as restrictions are applied.
Perhaps this method should be restricted to a FlatFeatureType? Or should have the option of returning an array of matching AttributeType in order of inheiritence?
getAttributeType
in interface FeatureType
xPath
- XPath pointer to attribute type.
public int find(AttributeType type)
FeatureType
Match is based on attribute type name, the resulting index may be used with getAttributeType( index ).
find
in interface FeatureType
type
- The type to search for.
public int find(java.lang.String attName)
FeatureType
This index may be used with getAttributeType( index ), the search space is the entire schema defined by this FeatureType and its ancestors.
find
in interface FeatureType
attName
- the name to look for
public AttributeType getAttributeType(int position)
FeatureType
The index is specified with respect to the entire Schema (as defined by this FeatureType and it's ancestors).
getAttributeType
in interface FeatureType
public AttributeType[] getAttributeTypes()
FeatureType
The provided array of AttributeTypes should be considered as adding to (or overriding) the the AttribtueTypes defined by this FeatureTypes ancestors.
Note Well: Client code should not consider the index provided by the find( attName ) method as a valid index into the returned array.
getAttributeTypes
in interface FeatureType
public boolean hasAttributeType(java.lang.String xPath)
FeatureType
Question: the comment says we are removing this, but it is not depricated? And how the heck can the number of occurances out of a boolean.
hasAttributeType
in interface FeatureType
xPath
- XPath pointer to attribute type.
public Feature duplicate(Feature feature) throws IllegalAttributeException
FeatureType
The implementation is assumed to make use of AttributeType duplicate as required for a deep copy.
duplicate
in interface FeatureType
feature
-
IllegalAttributeException
public Feature create(java.lang.Object[] attributes) throws IllegalAttributeException
FeatureType
Creates a new feature, with a generated unique featureID. This is less than ideal, as a FeatureID should be persistant over time, generally created by a datasource. This method is more for testing that doesn't need featureID.
create
in interface FeatureType
attributes
- the array of attribute values
IllegalAttributeException
- if the FeatureType does not validate the attributes.public Feature create(java.lang.Object[] attributes, java.lang.String featureID) throws IllegalAttributeException
FeatureType
Creates a new feature, with the proper featureID.
create
in interface FeatureType
attributes
- the array of attribute values.featureID
- the feature ID.
IllegalAttributeException
- if the FeatureType does not validate the attributes.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |