org.geotools.data
Class DataUtilities

java.lang.Object
  extended byorg.geotools.data.DataUtilities

public class DataUtilities
extends java.lang.Object

Utility functions for use when implementing working with data classes.

Author:
Jody Garnett, Refractions Research

Nested Class Summary
static class DataUtilities.AbstractFilterVisitor
          A quick and dirty FilterVisitor.
static class DataUtilities.Traversal
           
 
Constructor Summary
DataUtilities()
           
 
Method Summary
static java.lang.String[] attributeNames(FeatureType featureType)
           
static java.lang.String[] attributeNames(Filter filter)
           
static boolean attributesEqual(java.lang.Object att, java.lang.Object otherAtt)
           
static FeatureCollection collection(Feature[] features)
           
static int compare(FeatureType typeA, FeatureType typeB)
          Compare operation for FeatureType.
static FeatureType createSubType(FeatureType featureType, java.lang.String[] properties)
           
static FeatureType createSubType(FeatureType featureType, java.lang.String[] properties, org.geotools.cs.CoordinateSystem override)
           
static FeatureType createType(java.lang.String identification, java.lang.String typeSpec)
          Utility method for FeatureType construction.
static java.lang.Object defaultValue(AttributeType attributeType)
          Provides a defautlValue for attributeType.
static java.lang.Object[] defaultValues(FeatureType featureType)
           
static java.lang.Object[] defaultValues(FeatureType featureType, java.lang.Object[] values)
           
static boolean isMatch(AttributeType a, AttributeType b)
           
static Feature parse(FeatureType type, java.lang.String fid, java.lang.String[] text)
           
static FeatureReader reader(java.util.Collection collection)
           
static FeatureReader reader(Feature[] features)
          Creates a FeatureReader for testing.
static FeatureResults results(Feature[] featureArray)
           
static FeatureResults results(FeatureCollection collection)
           
static Feature reType(FeatureType featureType, Feature feature)
          Creates duplicate of feature adjusted to the provided featureType.
static FeatureSource source(Feature[] featureArray)
           
static FeatureSource source(FeatureCollection collection)
           
static java.lang.String spec(FeatureType featureType)
          Record typeSpec for the provided featureType
static Feature template(FeatureType featureType)
          Constructs an empty feature to use as a Template for new content.
static Feature template(FeatureType featureType, java.lang.Object[] atts)
           
static Feature template(FeatureType featureType, java.lang.String featureID)
           
static Feature template(FeatureType featureType, java.lang.String featureID, java.lang.Object[] atts)
           
static void traverse(Filter filter, FilterVisitor visitor)
           
static void traverse(java.util.Set set, FilterVisitor visitor)
          Performs a depth first traversal on Filter.
static java.util.Set traverseDepth(Filter filter)
          Performs a depth first traversal of Filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataUtilities

public DataUtilities()
Method Detail

attributeNames

public static java.lang.String[] attributeNames(FeatureType featureType)

attributeNames

public static java.lang.String[] attributeNames(Filter filter)

traverse

public static void traverse(Filter filter,
                            FilterVisitor visitor)

traverse

public static void traverse(java.util.Set set,
                            FilterVisitor visitor)
Performs a depth first traversal on Filter.

Filters can contain Expressions and other Filters, this method will call visitor.visit( Filter ) and visitor.visit( Expression )

Parameters:
set - Set of Filter and Expression information
visitor - Vistor to traverse across set

traverseDepth

public static java.util.Set traverseDepth(Filter filter)
Performs a depth first traversal of Filter.

Parameters:
filter -
Returns:
Set of Filters in traversing filter

compare

public static int compare(FeatureType typeA,
                          FeatureType typeB)
Compare operation for FeatureType.

Results in:

Comparison is based on AttributeTypes, an IOException is thrown if the AttributeTypes are not compatiable.

Namespace is not considered in this opperations. You may still need to reType to get the correct namesapce, or reorder.

Parameters:
typeA - FeatureType beind compared
typeB - FeatureType being compared against
Returns:

isMatch

public static boolean isMatch(AttributeType a,
                              AttributeType b)

reType

public static Feature reType(FeatureType featureType,
                             Feature feature)
                      throws IllegalAttributeException
Creates duplicate of feature adjusted to the provided featureType.

Parameters:
featureType - FeatureType requested
feature - Origional Feature from DataStore
Returns:
An instance of featureType based on feature
Throws:
IllegalAttributeException - If opperation could not be performed

template

public static Feature template(FeatureType featureType)
                        throws IllegalAttributeException
Constructs an empty feature to use as a Template for new content.

We may move this functionality to FeatureType.create( null )?

Parameters:
featureType - Type of feature we wish to create
Returns:
A new Feature of type featureType
Throws:
IllegalAttributeException - if we could not create featureType instance with acceptable default values

template

public static Feature template(FeatureType featureType,
                               java.lang.String featureID)
                        throws IllegalAttributeException
Throws:
IllegalAttributeException

defaultValues

public static java.lang.Object[] defaultValues(FeatureType featureType)
                                        throws IllegalAttributeException
Throws:
IllegalAttributeException

template

public static Feature template(FeatureType featureType,
                               java.lang.Object[] atts)
                        throws IllegalAttributeException
Throws:
IllegalAttributeException

template

public static Feature template(FeatureType featureType,
                               java.lang.String featureID,
                               java.lang.Object[] atts)
                        throws IllegalAttributeException
Throws:
IllegalAttributeException

defaultValues

public static java.lang.Object[] defaultValues(FeatureType featureType,
                                               java.lang.Object[] values)
                                        throws IllegalAttributeException
Throws:
IllegalAttributeException

defaultValue

public static java.lang.Object defaultValue(AttributeType attributeType)
                                     throws IllegalAttributeException
Provides a defautlValue for attributeType.

Will return null if attributeType isNillable(), or attempt to use Reflection, or attributeType.parse( null )

Parameters:
attributeType -
Returns:
null for nillable attributeType, attempt at reflection
Throws:
IllegalAttributeException - If value cannot be constructed for attribtueType

reader

public static FeatureReader reader(Feature[] features)
                            throws java.io.IOException
Creates a FeatureReader for testing.

Parameters:
features - Array of features
Returns:
FeatureReader spaning provided feature array
Throws:
java.io.IOException - If provided features Are null or empty

source

public static FeatureSource source(Feature[] featureArray)
                            throws java.io.IOException
Throws:
java.io.IOException

source

public static FeatureSource source(FeatureCollection collection)
                            throws java.io.IOException
Throws:
java.io.IOException

results

public static FeatureResults results(Feature[] featureArray)
                              throws java.io.IOException
Throws:
java.io.IOException

results

public static FeatureResults results(FeatureCollection collection)
                              throws java.io.IOException
Throws:
java.io.IOException

reader

public static FeatureReader reader(java.util.Collection collection)
                            throws java.io.IOException
Throws:
java.io.IOException

collection

public static FeatureCollection collection(Feature[] features)

attributesEqual

public static boolean attributesEqual(java.lang.Object att,
                                      java.lang.Object otherAtt)

createSubType

public static FeatureType createSubType(FeatureType featureType,
                                        java.lang.String[] properties,
                                        org.geotools.cs.CoordinateSystem override)
                                 throws SchemaException
Throws:
SchemaException

createSubType

public static FeatureType createSubType(FeatureType featureType,
                                        java.lang.String[] properties)
                                 throws SchemaException
Throws:
SchemaException

createType

public static FeatureType createType(java.lang.String identification,
                                     java.lang.String typeSpec)
                              throws SchemaException
Utility method for FeatureType construction.

Will parse a String of the form: "name:Type,name2:Type2,..."

Where Type is defined by createAttribute.

You may indicate the default Geometry with an astrix.

Example:name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"

Parameters:
identification - identification of FeatureType: (namesapce).typeName
typeSpec - Specification for FeatureType
Returns:
Throws:
SchemaException

parse

public static Feature parse(FeatureType type,
                            java.lang.String fid,
                            java.lang.String[] text)
                     throws IllegalAttributeException
Throws:
IllegalAttributeException

spec

public static java.lang.String spec(FeatureType featureType)
Record typeSpec for the provided featureType



Copyright © 1996-2003 GeoTools. All Rights Reserved.