org.geotools.feature
Class DefaultFeatureType

Object
  extended by PropertyTypeImpl
      extended by AttributeTypeImpl
          extended by ComplexTypeImpl
              extended by FeatureTypeImpl
                  extended by SimpleFeatureTypeImpl
                      extended by DefaultFeatureType
All Implemented Interfaces:
SimpleFeatureType, AttributeType, ComplexType, FeatureType, PropertyType
Direct Known Subclasses:
SimpleFeatureType

public class DefaultFeatureType
extends SimpleFeatureTypeImpl
implements FeatureType

A basic implementation of FeatureType.

Author:
Ian Schneider
Module:

Field Summary
static FeatureType EMPTY
          An feature type with no attributes
 
Fields inherited from class AttributeTypeImpl
identified
 
Fields inherited from class PropertyTypeImpl
binding, description, isAbstract, name, restrictions, superType, userData
 
Constructor Summary
DefaultFeatureType(Name name, Collection types, Collection superTypes, GeometryAttributeType defaultGeom)
          Constructs a new DefaultFeatureType.
DefaultFeatureType(Name name, List schema, GeometryDescriptor defaultGeometry, boolean isAbstract, List restrictions, AttributeType superType, InternationalString description)
           
DefaultFeatureType(String typeName, String namespace, Collection types, Collection superTypes, GeometryAttributeType defaultGeom)
           
DefaultFeatureType(String typeName, URI namespace, Collection types, Collection superTypes, GeometryAttributeType defaultGeom)
           
 
Method Summary
 Feature create(Object[] attributes)
          Creates a new feature, with a generated unique featureID.
 Feature create(Object[] attributes, String featureID)
          Creates a new feature, with the proper featureID, using this FeatureType.
 Feature duplicate(Feature original)
           
 boolean equals(Object other)
          Override of equals.
 int find(AttributeType type)
          Find the position of a given AttributeType.
 int find(String attName)
          Find the position of an AttributeType which matches the given String.
 FeatureType[] getAncestors()
          Obtain an array of this FeatureTypes ancestors.
 int getAttributeCount()
          Returns the number of attributes at the first 'level' of the schema.
 AttributeType getAttributeType(int position)
          Gets the attributeType at the specified index.
 AttributeType getAttributeType(String xPath)
          Gets the attributeType at this xPath, if the specified attributeType does not exist then null is returned.
 AttributeType[] getAttributeTypes()
           
 GeometryAttributeType getGeometryDescriptor()
          Gets the primary geometry AttributeType.
 URI getNamespace()
          Gets the global schema namespace.
 String getTypeName()
          Gets the type name for this schema.
 boolean hasAttributeType(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.
 int hashCode()
          Override of hashcode.
 boolean isAbstract()
          Is this FeatureType an abstract type?
 boolean isDescendedFrom(FeatureType type)
          A convenience method for calling
FeatureType f1; FeatureType f2; f1.isDescendedFrom(f2.getNamespace(),f2.getName());
 boolean isDescendedFrom(URI nsURI, String typeName1)
          Test to determine whether this FeatureType is descended from the given FeatureType.
 
Methods inherited from class SimpleFeatureTypeImpl
getAttributeDescriptors, getDescriptor, getDescriptor, getDescriptor, getType, getType, getType, getTypes, indexOf, indexOf
 
Methods inherited from class FeatureTypeImpl
getCoordinateReferenceSystem
 
Methods inherited from class ComplexTypeImpl
getBinding, getDescriptors, isInline, toString
 
Methods inherited from class AttributeTypeImpl
createDefaultValue, getSuper, isIdentified, parse
 
Methods inherited from class PropertyTypeImpl
getDescription, getName, getRestrictions, getUserData
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SimpleFeatureType
getAttributeDescriptors, getDescriptor, getDescriptor, getDescriptor, getType, getType, getType, getTypes, indexOf, indexOf
 
Methods inherited from interface FeatureType
getCoordinateReferenceSystem, isIdentified
 
Methods inherited from interface ComplexType
getBinding, getDescriptors, isInline
 
Methods inherited from interface AttributeType
getSuper
 
Methods inherited from interface PropertyType
getDescription, getName, getRestrictions, getUserData
 

Field Detail

EMPTY

public static final FeatureType EMPTY
An feature type with no attributes

Constructor Detail

DefaultFeatureType

public DefaultFeatureType(String typeName,
                          String namespace,
                          Collection types,
                          Collection superTypes,
                          GeometryAttributeType defaultGeom)
                   throws SchemaException,
                          NullPointerException
Throws:
SchemaException
NullPointerException

DefaultFeatureType

public DefaultFeatureType(String typeName,
                          URI namespace,
                          Collection types,
                          Collection superTypes,
                          GeometryAttributeType defaultGeom)
                   throws NullPointerException
Throws:
NullPointerException

DefaultFeatureType

public DefaultFeatureType(Name name,
                          Collection types,
                          Collection superTypes,
                          GeometryAttributeType defaultGeom)
                   throws NullPointerException
Constructs a new DefaultFeatureType.

Attributes from the superTypes will be copied to the list of attributes for this feature type.

Parameters:
typeName - The name to give this FeatureType.
namespace - The namespace of the new FeatureType.
types - The attributeTypes to use for validation.
superTypes - The ancestors of this FeatureType.
defaultGeom - The attributeType to set as the defaultGeometry.
Throws:
SchemaException - For problems making the FeatureType.
NullPointerException - If typeName is null.

DefaultFeatureType

public DefaultFeatureType(Name name,
                          List schema,
                          GeometryDescriptor defaultGeometry,
                          boolean isAbstract,
                          List restrictions,
                          AttributeType superType,
                          InternationalString description)
Method Detail

create

public Feature create(Object[] attributes)
               throws IllegalAttributeException
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.

Parameters:
attributes - the array of attribute values
Returns:
The created feature with this as its feature type.
Throws:
IllegalAttributeException - if this FeatureType does not validate the attributes.

create

public Feature create(Object[] attributes,
                      String featureID)
               throws IllegalAttributeException
Creates a new feature, with the proper featureID, using this FeatureType.

Parameters:
attributes - the array of attribute values.
featureID - the feature ID.
Returns:
the created feature.
Throws:
IllegalAttributeException - if this FeatureType does not validate the attributes.

duplicate

public Feature duplicate(Feature original)
                  throws IllegalAttributeException
Throws:
IllegalAttributeException

getGeometryDescriptor

public GeometryAttributeType getGeometryDescriptor()
Gets the primary geometry AttributeType. 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 isGeometry on each. This should just be used a convenience method when it is known that the features are flat.

Specified by:
getGeometryDescriptor in interface FeatureType
Overrides:
getGeometryDescriptor in class FeatureTypeImpl
Returns:
The attribute type of the default geometry, which will contain the position.

getAttributeType

public AttributeType getAttributeType(String xPath)
Gets the attributeType at this xPath, if the specified attributeType does not exist then null is returned.

Parameters:
xPath - XPath pointer to attribute type.
Returns:
True if attribute exists.

find

public int find(AttributeType type)
Find the position of a given AttributeType.

Parameters:
type - The type to search for.
Returns:
-1 if not found, a zero-based index if found.

find

public int find(String attName)
Find the position of an AttributeType which matches the given String.

Parameters:
attName - the name to look for
Returns:
-1 if not found, zero-based index otherwise

getAttributeType

public AttributeType getAttributeType(int position)
Gets the attributeType at the specified index.

Parameters:
position - the position of the attribute to check.
Returns:
The attribute type at the specified position.

getAttributeTypes

public AttributeType[] getAttributeTypes()

getNamespace

public URI getNamespace()
Gets the global schema namespace.

Returns:
Namespace of schema.

getTypeName

public String getTypeName()
Gets the type name for this schema.

Specified by:
getTypeName in interface SimpleFeatureType
Overrides:
getTypeName in class SimpleFeatureTypeImpl
Returns:
Namespace of schema.

hasAttributeType

public boolean hasAttributeType(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. If getAttributeType does not have the AttributeType it will just return null. Gets the number of occurrences of this attribute.

Parameters:
xPath - XPath pointer to attribute type.
Returns:
Number of occurrences.

getAttributeCount

public int getAttributeCount()
Returns the number of attributes at the first 'level' of the schema.

Specified by:
getAttributeCount in interface SimpleFeatureType
Overrides:
getAttributeCount in class SimpleFeatureTypeImpl
Returns:
the total number of first level attributes.

hashCode

public int hashCode()
Description copied from class: AttributeTypeImpl
Override of hashcode.

Specified by:
hashCode in interface PropertyType
Overrides:
hashCode in class FeatureTypeImpl

equals

public boolean equals(Object other)
Description copied from class: AttributeTypeImpl
Override of equals.

Specified by:
equals in interface PropertyType
Overrides:
equals in class FeatureTypeImpl
Parameters:
other - the object to be tested for equality.
Returns:
whether other is equal to this attribute Type.

getAncestors

public FeatureType[] getAncestors()
Obtain an array of this FeatureTypes ancestors. Implementors should return a non-null array (may be of length 0).

Returns:
An array of ancestors.

isAbstract

public boolean isAbstract()
Is this FeatureType an abstract type?

Specified by:
isAbstract in interface PropertyType
Overrides:
isAbstract in class PropertyTypeImpl
Returns:
true if abstract, false otherwise.

isDescendedFrom

public boolean isDescendedFrom(FeatureType type)
A convenience method for calling
FeatureType f1; FeatureType f2; f1.isDescendedFrom(f2.getNamespace(),f2.getName());

Parameters:
type - The type to compare to.
Returns:
true if descendant, false otherwise.

isDescendedFrom

public boolean isDescendedFrom(URI nsURI,
                               String typeName1)
Test to determine whether this FeatureType is descended from the given FeatureType. Think of this relationship likes the "extends" relationship in java.

Parameters:
nsURI - The namespace URI to use.
typeName1 - The typeName.
Returns:
true if descendant, false otherwise.
TODO:
HACK: if nsURI is null only typeName is tested.


Copyright © 1996-2009 Geotools. All Rights Reserved.