org.geotools.feature
Class FeatureTypes

Object
  extended by FeatureTypes

public class FeatureTypes
extends Object

Utility methods for working against the FeatureType interface.

Many methods from DataUtilities should be refractored here.

Responsibilities:

Since:
2.1.M3
Author:
Jody Garnett, Refractions Research

Field Summary
static SimpleFeatureType ABSTRACT_FEATURE_TYPE
          abstract base type for all feature types
static int ANY_LENGTH
          represent an unbounded field length
static URI DEFAULT_NAMESPACE
          the default namespace for feature types
static NameImpl DEFAULT_TYPENAME
          default feature collection name
static SimpleFeatureType EMPTY
          An feature type with no attributes
 
Constructor Summary
FeatureTypes()
           
 
Method Summary
static Set ancestors(SimpleFeatureType featureType)
           
static boolean equals(AttributeDescriptor[] attributesA, AttributeDescriptor[] attributesB)
           
static boolean equals(AttributeDescriptor a, AttributeDescriptor b)
           
static boolean equals(List attributesA, List attributesB)
           
static boolean equals(SimpleFeatureType typeA, SimpleFeatureType typeB)
          Exact equality based on typeNames, namespace, attributes and ancestors
static boolean equalsAncestors(SimpleFeatureType typeA, SimpleFeatureType typeB)
          This method depends on the correct implementation of FeatureType equals We may need to write an implementation that can detect cycles,
static boolean equalsExact(AttributeDescriptor[] attributesA, AttributeDescriptor[] attributesB)
           
static boolean equalsExact(AttributeDescriptor a, AttributeDescriptor b)
           
static boolean equalsExact(List attributesA, List attributesB)
           
static boolean equalsExact(SimpleFeatureType typeA, SimpleFeatureType typeB)
          Exact equality based on typeNames, namespace, attributes and ancestors, including the user maps contents
static boolean equalsId(SimpleFeatureType typeA, SimpleFeatureType typeB)
          Quick check of namespace and typename
static List<FeatureType> getAncestors(FeatureType featureType)
          Walks up the type hierarchy of the feature returning all super types of the specified feature type.
static int getFieldLength(PropertyDescriptor descriptor)
          This is a 'suitable replacement for extracting the expected field length of an attribute absed on its "facets" (ie Filter describing type restrictions); This code is copied from the ShapefileDataStore where it was written (probably by dzwiers).
static boolean isDecendedFrom(FeatureType featureType, FeatureType isParentType)
           
static boolean isDecendedFrom(FeatureType featureType, URI namespace, String typeName)
          A query of the the types ancestor information.
static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name)
          Create a new FeatureType with the given AttributeTypes.
static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns)
          Create a new FeatureType with the given AttributeTypes.
static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract)
          Create a new FeatureType with the given AttributeTypes.
static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes)
          The most specific way to create a new FeatureType.
static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes, AttributeDescriptor defaultGeometry)
          The most specific way to create a new FeatureType.
static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes, GeometryDescriptor defaultGeometry)
          The most specific way to create a new FeatureType.
static SimpleFeature transform(SimpleFeature feature, SimpleFeatureType schema, MathTransform transform)
          Applies transform to all geometry attribute.
static SimpleFeatureType transform(SimpleFeatureType schema, CoordinateReferenceSystem crs)
          Forces the specified CRS on all geometry attributes
static SimpleFeatureType transform(SimpleFeatureType schema, CoordinateReferenceSystem crs, boolean forceOnlyMissing)
          Forces the specified CRS on geometry attributes (all or some, depends on the parameters).
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE

public static final URI DEFAULT_NAMESPACE
the default namespace for feature types


ABSTRACT_FEATURE_TYPE

public static final SimpleFeatureType ABSTRACT_FEATURE_TYPE
abstract base type for all feature types


DEFAULT_TYPENAME

public static final NameImpl DEFAULT_TYPENAME
default feature collection name


ANY_LENGTH

public static final int ANY_LENGTH
represent an unbounded field length

See Also:
Constant Field Values

EMPTY

public static final SimpleFeatureType EMPTY
An feature type with no attributes

Constructor Detail

FeatureTypes

public FeatureTypes()
Method Detail

getFieldLength

public static int getFieldLength(PropertyDescriptor descriptor)
This is a 'suitable replacement for extracting the expected field length of an attribute absed on its "facets" (ie Filter describing type restrictions);

This code is copied from the ShapefileDataStore where it was written (probably by dzwiers). Cholmes is providing documentation.

Parameters:
type - the AttributeType
Returns:
an int indicating the max length of field in characters, or ANY_LENGTH

transform

public static SimpleFeatureType transform(SimpleFeatureType schema,
                                          CoordinateReferenceSystem crs)
                                   throws SchemaException
Forces the specified CRS on all geometry attributes

Parameters:
schema - the original schema
crs - the forced crs
Returns:
Throws:
SchemaException

transform

public static SimpleFeatureType transform(SimpleFeatureType schema,
                                          CoordinateReferenceSystem crs,
                                          boolean forceOnlyMissing)
                                   throws SchemaException
Forces the specified CRS on geometry attributes (all or some, depends on the parameters).

Parameters:
schema - the original schema
crs - the forced crs
forceOnlyMissing - if true, will force the specified crs only on the attributes that do miss one
Returns:
Throws:
SchemaException

transform

public static SimpleFeature transform(SimpleFeature feature,
                                      SimpleFeatureType schema,
                                      MathTransform transform)
                               throws MismatchedDimensionException,
                                      TransformException,
                                      IllegalAttributeException
Applies transform to all geometry attribute.

Parameters:
feature - Feature to be transformed
schema - Schema for target transformation - transform( schema, crs )
transform - MathTransform used to transform coordinates - reproject( crs, crs )
Returns:
transformed Feature of type schema
Throws:
TransformException
MismatchedDimensionException
IllegalAttributeException

newFeatureType

public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types,
                                               String name,
                                               URI ns,
                                               boolean isAbstract,
                                               SimpleFeatureType[] superTypes)
                                        throws FactoryRegistryException,
                                               SchemaException
The most specific way to create a new FeatureType.

Parameters:
types - The AttributeTypes to create the FeatureType with.
name - The typeName of the FeatureType. Required, may not be null.
ns - The namespace of the FeatureType. Optional, may be null.
isAbstract - True if this created type should be abstract.
superTypes - A Collection of types the FeatureType will inherit from. Currently, all types inherit from feature in the opengis namespace.
Returns:
A new FeatureType created from the given arguments.
Throws:
FactoryRegistryException - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types,
                                               String name,
                                               URI ns,
                                               boolean isAbstract,
                                               SimpleFeatureType[] superTypes,
                                               AttributeDescriptor defaultGeometry)
                                        throws FactoryRegistryException,
                                               SchemaException
The most specific way to create a new FeatureType.

Parameters:
types - The AttributeTypes to create the FeatureType with.
name - The typeName of the FeatureType. Required, may not be null.
ns - The namespace of the FeatureType. Optional, may be null.
isAbstract - True if this created type should be abstract.
superTypes - A Collection of types the FeatureType will inherit from. Currently, all types inherit from feature in the opengis namespace.
Returns:
A new FeatureType created from the given arguments.
Throws:
FactoryRegistryException - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types,
                                               String name,
                                               URI ns,
                                               boolean isAbstract,
                                               SimpleFeatureType[] superTypes,
                                               GeometryDescriptor defaultGeometry)
                                        throws FactoryRegistryException,
                                               SchemaException
The most specific way to create a new FeatureType.

Parameters:
types - The AttributeTypes to create the FeatureType with.
name - The typeName of the FeatureType. Required, may not be null.
ns - The namespace of the FeatureType. Optional, may be null.
isAbstract - True if this created type should be abstract.
superTypes - A Collection of types the FeatureType will inherit from. Currently, all types inherit from feature in the opengis namespace.
Returns:
A new FeatureType created from the given arguments.
Throws:
FactoryRegistryException - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types,
                                               String name,
                                               URI ns,
                                               boolean isAbstract)
                                        throws FactoryRegistryException,
                                               SchemaException
Create a new FeatureType with the given AttributeTypes. A short cut for calling newFeatureType(types,name,ns,isAbstract,null).

Parameters:
types - The AttributeTypes to create the FeatureType with.
name - The typeName of the FeatureType. Required, may not be null.
ns - The namespace of the FeatureType. Optional, may be null.
isAbstract - True if this created type should be abstract.
Returns:
A new FeatureType created from the given arguments.
Throws:
FactoryRegistryException - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types,
                                               String name,
                                               URI ns)
                                        throws FactoryRegistryException,
                                               SchemaException
Create a new FeatureType with the given AttributeTypes. A short cut for calling newFeatureType(types,name,ns,false,null).

Parameters:
types - The AttributeTypes to create the FeatureType with.
name - The typeName of the FeatureType. Required, may not be null.
ns - The namespace of the FeatureType. Optional, may be null.
Returns:
A new FeatureType created from the given arguments.
Throws:
FactoryRegistryException - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types,
                                               String name)
                                        throws FactoryRegistryException,
                                               SchemaException
Create a new FeatureType with the given AttributeTypes. A short cut for calling newFeatureType(types,name,null,false,null). Useful for test cases or datasources which may not allow a namespace.

Parameters:
types - The AttributeTypes to create the FeatureType with.
name - The typeName of the FeatureType. Required, may not be null.
Returns:
A new FeatureType created from the given arguments.
Throws:
FactoryRegistryException - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

getAncestors

public static List<FeatureType> getAncestors(FeatureType featureType)
Walks up the type hierarchy of the feature returning all super types of the specified feature type. The search terminates when a non-FeatureType or null is found. The original featureType is not included as an ancestor, only its strict ancestors.


isDecendedFrom

public static boolean isDecendedFrom(FeatureType featureType,
                                     URI namespace,
                                     String typeName)
A query of the the types ancestor information.

This utility method may be used as common implementation for FeatureType.isDecendedFrom( namespace, typeName ), however for specific uses, such as GML, an implementor may be able to provide a more efficient implemenation based on prior knolwege.

This is a proper check, if the provided FeatureType matches the given namespace and typename it is not considered to be decended from itself.

Parameters:
featureType - typeName with parentage in question
namespace - namespace to match against, or null for a "wildcard"
typeName - typename to match against, or null for a "wildcard"
Returns:
true if featureType is a decendent of the indicated namespace & typeName

isDecendedFrom

public static boolean isDecendedFrom(FeatureType featureType,
                                     FeatureType isParentType)

equals

public static boolean equals(SimpleFeatureType typeA,
                             SimpleFeatureType typeB)
Exact equality based on typeNames, namespace, attributes and ancestors


equalsExact

public static boolean equalsExact(SimpleFeatureType typeA,
                                  SimpleFeatureType typeB)
Exact equality based on typeNames, namespace, attributes and ancestors, including the user maps contents


equals

public static boolean equals(List attributesA,
                             List attributesB)

equalsExact

public static boolean equalsExact(List attributesA,
                                  List attributesB)

equals

public static boolean equals(AttributeDescriptor[] attributesA,
                             AttributeDescriptor[] attributesB)

equalsExact

public static boolean equalsExact(AttributeDescriptor[] attributesA,
                                  AttributeDescriptor[] attributesB)

equalsAncestors

public static boolean equalsAncestors(SimpleFeatureType typeA,
                                      SimpleFeatureType typeB)
This method depends on the correct implementation of FeatureType equals

We may need to write an implementation that can detect cycles,

Parameters:
typeA -
typeB -

ancestors

public static Set ancestors(SimpleFeatureType featureType)

equals

public static boolean equals(AttributeDescriptor a,
                             AttributeDescriptor b)

equalsExact

public static boolean equalsExact(AttributeDescriptor a,
                                  AttributeDescriptor b)

equalsId

public static boolean equalsId(SimpleFeatureType typeA,
                               SimpleFeatureType typeB)
Quick check of namespace and typename



Copyright © 1996-2014 Geotools. All Rights Reserved.