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.

TODO: Move FeatureType manipulation to feature package

Author:
Jody Garnett, Refractions Research

Nested Class Summary
static class DataUtilities.AbstractFilterVisitor
          A quick and dirty FilterVisitor.
static class DataUtilities.Traversal
          DOCUMENT ME!
 
Constructor Summary
DataUtilities()
           
 
Method Summary
static java.lang.String[] attributeNames(Expression expression)
          DOCUMENT ME!
static java.lang.String[] attributeNames(FeatureType featureType)
          DOCUMENT ME!
static java.lang.String[] attributeNames(Filter filter)
          DOCUMENT ME!
static boolean attributesEqual(java.lang.Object att, java.lang.Object otherAtt)
          DOCUMENT ME!
static FeatureCollection collection(Feature[] features)
          DOCUMENT ME!
static int compare(FeatureType typeA, FeatureType typeB)
          Compare operation for FeatureType.
static FeatureType createSubType(FeatureType featureType, java.lang.String[] properties)
          DOCUMENT ME!
static FeatureType createSubType(FeatureType featureType, java.lang.String[] properties, org.opengis.referencing.crs.CoordinateReferenceSystem override)
          Create a derived FeatureType
static FeatureType createSubType(FeatureType featureType, java.lang.String[] properties, org.opengis.referencing.crs.CoordinateReferenceSystem override, java.lang.String typeName, java.net.URI namespace)
           
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)
          DOCUMENT ME!
static java.lang.Object[] defaultValues(FeatureType featureType, java.lang.Object[] values)
          DOCUMENT ME!
static boolean isMatch(AttributeType a, AttributeType b)
          DOCUMENT ME!
static Query mixQueries(Query firstQuery, Query secondQuery, java.lang.String handle)
          Takes two Queryobjects and produce a new one by mixing the restrictions of both of them.
static Feature parse(FeatureType type, java.lang.String fid, java.lang.String[] text)
          DOCUMENT ME!
static FeatureReader reader(java.util.Collection collection)
          DOCUMENT ME!
static FeatureReader reader(Feature[] features)
          Creates a FeatureReader for testing.
static FeatureResults results(Feature[] featureArray)
           
static FeatureResults results(FeatureCollection collection)
          DOCUMENT ME!
static Feature reType(FeatureType featureType, Feature feature)
          Creates duplicate of feature adjusted to the provided featureType.
static FeatureSource source(Feature[] featureArray)
          DOCUMENT ME!
static FeatureSource source(FeatureCollection collection)
          DOCUMENT ME!
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)
          DOCUMENT ME!
static Feature template(FeatureType featureType, java.lang.String featureID)
          DOCUMENT ME!
static Feature template(FeatureType featureType, java.lang.String featureID, java.lang.Object[] atts)
          DOCUMENT ME!
static void traverse(Expression expression, FilterVisitor visitor)
           
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(Expression expression)
          Performs a depth first traversal of 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)
DOCUMENT ME!

Parameters:
featureType - DOCUMENT ME!
Returns:
DOCUMENT ME!

attributeNames

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

Parameters:
filter - DOCUMENT ME!
Returns:
DOCUMENT ME!

attributeNames

public static java.lang.String[] attributeNames(Expression expression)
DOCUMENT ME!

Returns:
DOCUMENT ME!

traverse

public static void traverse(Filter filter,
                            FilterVisitor visitor)
Parameters:
filter - DOCUMENT ME!
visitor - DOCUMENT ME!

traverse

public static void traverse(Expression expression,
                            FilterVisitor visitor)
Parameters:
visitor - DOCUMENT ME!

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

traverseDepth

public static java.util.Set traverseDepth(Expression expression)
Performs a depth first traversal of 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)
DOCUMENT ME!

Parameters:
a - DOCUMENT ME!
b - DOCUMENT ME!
Returns:
DOCUMENT ME!

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
DOCUMENT ME!

Parameters:
featureType - DOCUMENT ME!
featureID - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalAttributeException - DOCUMENT ME!

defaultValues

public static java.lang.Object[] defaultValues(FeatureType featureType)
                                        throws IllegalAttributeException
DOCUMENT ME!

Parameters:
featureType - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalAttributeException - DOCUMENT ME!

template

public static Feature template(FeatureType featureType,
                               java.lang.Object[] atts)
                        throws IllegalAttributeException
DOCUMENT ME!

Parameters:
featureType - DOCUMENT ME!
atts - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalAttributeException - DOCUMENT ME!

template

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

Parameters:
featureType - DOCUMENT ME!
featureID - DOCUMENT ME!
atts - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalAttributeException - DOCUMENT ME!

defaultValues

public static java.lang.Object[] defaultValues(FeatureType featureType,
                                               java.lang.Object[] values)
                                        throws IllegalAttributeException
DOCUMENT ME!

Parameters:
featureType - DOCUMENT ME!
values - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalAttributeException - DOCUMENT ME!
java.lang.ArrayIndexOutOfBoundsException - DOCUMENT ME!

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
java.util.NoSuchElementException - DOCUMENT ME!

source

public static FeatureSource source(Feature[] featureArray)
DOCUMENT ME!

Parameters:
featureArray - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.RuntimeException - DOCUMENT ME!

source

public static FeatureSource source(FeatureCollection collection)
DOCUMENT ME!

Parameters:
collection - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.NullPointerException - DOCUMENT ME!
java.lang.RuntimeException - DOCUMENT ME!

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
DOCUMENT ME!

Parameters:
collection - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

reader

public static FeatureReader reader(java.util.Collection collection)
                            throws java.io.IOException
DOCUMENT ME!

Parameters:
collection - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

collection

public static FeatureCollection collection(Feature[] features)
DOCUMENT ME!

Parameters:
features - DOCUMENT ME!
Returns:
DOCUMENT ME!

attributesEqual

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

Parameters:
att - DOCUMENT ME!
otherAtt - DOCUMENT ME!
Returns:
DOCUMENT ME!

createSubType

public static FeatureType createSubType(FeatureType featureType,
                                        java.lang.String[] properties,
                                        org.opengis.referencing.crs.CoordinateReferenceSystem override)
                                 throws SchemaException
Create a derived FeatureType

Parameters:
featureType -
properties - - if null, every property of the feature type in input will be used
override -
Returns:
Throws:
SchemaException

createSubType

public static FeatureType createSubType(FeatureType featureType,
                                        java.lang.String[] properties,
                                        org.opengis.referencing.crs.CoordinateReferenceSystem override,
                                        java.lang.String typeName,
                                        java.net.URI namespace)
                                 throws SchemaException
Throws:
SchemaException

createSubType

public static FeatureType createSubType(FeatureType featureType,
                                        java.lang.String[] properties)
                                 throws SchemaException
DOCUMENT ME!

Parameters:
featureType - DOCUMENT ME!
properties - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
SchemaException - DOCUMENT ME!

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: "*geom:Geometry".

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
DOCUMENT ME!

Parameters:
type - DOCUMENT ME!
fid - DOCUMENT ME!
text - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IllegalAttributeException - DOCUMENT ME!

spec

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

Parameters:
featureType - DOCUMENT ME!
Returns:
DOCUMENT ME!

mixQueries

public static Query mixQueries(Query firstQuery,
                               Query secondQuery,
                               java.lang.String handle)
Takes two Queryobjects and produce a new one by mixing the restrictions of both of them.

The policy to mix the queries components is the following:

Parameters:
firstQuery - Query against this DataStore
secondQuery - DOCUMENT ME!
handle - DOCUMENT ME!
Returns:
Query restricted to the limits of definitionQuery
Throws:
java.lang.NullPointerException - if some of the queries is null
java.lang.IllegalArgumentException - if the type names of both queries do not match


Copyright © GeoTools. All Rights Reserved.