org.geotools.feature
Class FeatureTypes

java.lang.Object
  extended byorg.geotools.feature.FeatureTypes
Direct Known Subclasses:
FeatureTypeBuilder

public class FeatureTypes
extends java.lang.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 int ANY_LENGTH
          represent an unbounded field length
 
Constructor Summary
FeatureTypes()
           
 
Method Summary
static java.util.Set ancestors(FeatureType featureType)
           
static boolean equals(AttributeType[] attributesA, AttributeType[] attributesB)
           
static boolean equals(AttributeType a, AttributeType b)
           
static boolean equals(FeatureType typeA, FeatureType typeB)
          Exact equality based on typeNames, namespace, attributes and ancestors
static boolean equalsAncestors(FeatureType typeA, FeatureType typeB)
          This method depends on the correct implementation of FeatureType equals We may need to write an implementation that can detect cycles,
static boolean equalsId(FeatureType typeA, FeatureType typeB)
          Quick check of namespace and typename
static int getFieldLength(AttributeType type)
          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, java.net.URI namespace, java.lang.String typeName)
          A query of the the types ancestor information.
static FeatureType newFeatureType(AttributeType[] types, java.lang.String name)
          Create a new FeatureType with the given AttributeTypes.
static FeatureType newFeatureType(AttributeType[] types, java.lang.String name, java.net.URI ns)
          Create a new FeatureType with the given AttributeTypes.
static FeatureType newFeatureType(AttributeType[] types, java.lang.String name, java.net.URI ns, boolean isAbstract)
          Create a new FeatureType with the given AttributeTypes.
static FeatureType newFeatureType(AttributeType[] types, java.lang.String name, java.net.URI ns, boolean isAbstract, FeatureType[] superTypes)
          The most specific way to create a new FeatureType.
static FeatureType newFeatureType(AttributeType[] types, java.lang.String name, java.net.URI ns, boolean isAbstract, FeatureType[] superTypes, AttributeType defaultGeometry)
          The most specific way to create a new FeatureType.
static FeatureType newFeatureType(AttributeType[] types, java.lang.String name, java.net.URI ns, boolean isAbstract, FeatureType[] superTypes, GeometryAttributeType defaultGeometry)
          The most specific way to create a new FeatureType.
static Feature transform(Feature feature, FeatureType schema, org.opengis.referencing.operation.MathTransform transform)
          Applies transform to all geometry attribute.
static FeatureType transform(FeatureType schema, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANY_LENGTH

public static final int ANY_LENGTH
represent an unbounded field length

See Also:
Constant Field Values
Constructor Detail

FeatureTypes

public FeatureTypes()
Method Detail

getFieldLength

public static int getFieldLength(AttributeType type)
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.

Returns:
max length of field in characters, or ANY_LENGTH

transform

public static FeatureType transform(FeatureType schema,
                                    org.opengis.referencing.crs.CoordinateReferenceSystem crs)
                             throws SchemaException
Throws:
SchemaException

transform

public static Feature transform(Feature feature,
                                FeatureType schema,
                                org.opengis.referencing.operation.MathTransform transform)
                         throws org.opengis.spatialschema.geometry.MismatchedDimensionException,
                                org.opengis.referencing.operation.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:
org.opengis.referencing.operation.TransformException
org.opengis.spatialschema.geometry.MismatchedDimensionException
IllegalAttributeException

newFeatureType

public static FeatureType newFeatureType(AttributeType[] types,
                                         java.lang.String name,
                                         java.net.URI ns,
                                         boolean isAbstract,
                                         FeatureType[] superTypes)
                                  throws FactoryConfigurationError,
                                         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:
FactoryConfigurationError - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static FeatureType newFeatureType(AttributeType[] types,
                                         java.lang.String name,
                                         java.net.URI ns,
                                         boolean isAbstract,
                                         FeatureType[] superTypes,
                                         AttributeType defaultGeometry)
                                  throws FactoryConfigurationError,
                                         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:
FactoryConfigurationError - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static FeatureType newFeatureType(AttributeType[] types,
                                         java.lang.String name,
                                         java.net.URI ns,
                                         boolean isAbstract,
                                         FeatureType[] superTypes,
                                         GeometryAttributeType defaultGeometry)
                                  throws FactoryConfigurationError,
                                         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:
FactoryConfigurationError - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static FeatureType newFeatureType(AttributeType[] types,
                                         java.lang.String name,
                                         java.net.URI ns,
                                         boolean isAbstract)
                                  throws FactoryConfigurationError,
                                         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:
FactoryConfigurationError - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static FeatureType newFeatureType(AttributeType[] types,
                                         java.lang.String name,
                                         java.net.URI ns)
                                  throws FactoryConfigurationError,
                                         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:
FactoryConfigurationError - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

newFeatureType

public static FeatureType newFeatureType(AttributeType[] types,
                                         java.lang.String name)
                                  throws FactoryConfigurationError,
                                         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:
FactoryConfigurationError - If there are problems creating a factory.
SchemaException - If the AttributeTypes provided are invalid in some way.

isDecendedFrom

public static boolean isDecendedFrom(FeatureType featureType,
                                     java.net.URI namespace,
                                     java.lang.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(FeatureType typeA,
                             FeatureType typeB)
Exact equality based on typeNames, namespace, attributes and ancestors


equals

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

equalsAncestors

public static boolean equalsAncestors(FeatureType typeA,
                                      FeatureType 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 -
Returns:

ancestors

public static java.util.Set ancestors(FeatureType featureType)

equals

public static boolean equals(AttributeType a,
                             AttributeType b)

equalsId

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



Copyright © GeoTools. All Rights Reserved.