| java.lang.Object org.geotools.data.DataUtilities
DataUtilities | public class DataUtilities (Code) | | Utility functions for use when implementing working with data classes.
TODO: Move FeatureType manipulation to feature package
author: Jody Garnett, Refractions Research |
Method Summary | |
public static String[] | attributeNames(FeatureType featureType) | public static String[] | attributeNames(Filter filter, FeatureType featureType) Traverses the filter and returns any encoutered property names. | public static String[] | attributeNames(Filter filter) Traverses the filter and returns any encoutered property names. | public static String[] | attributeNames(Expression expression, FeatureType featureType) Traverses the expression and returns any encoutered property names. | public static String[] | attributeNames(Expression expression) Traverses the expression and returns any encoutered property names. | public static boolean | attributesEqual(Object att, Object otherAtt) | public static Envelope | bounds(FeatureCollection collection) Manually calculates the bounds of a feature collection. | public static FeatureCollection | collection(Feature[] features) Copies the provided features into a FeatureCollection. | public static FeatureCollection | collection(Feature feature) Copies the provided features into a FeatureCollection. | public static FeatureCollection | collection(FeatureReader reader) Copies the provided reader into a FeatureCollection, reader will be closed. | public static FeatureCollection | collection(FeatureIterator reader) Copies the provided reader into a FeatureCollection, reader will be closed. | public static int | compare(FeatureType typeA, FeatureType typeB) Compare operation for FeatureType.
Results in:
-
1: if typeA is a sub type/reorder/renamespace of typeB
-
0: if typeA and typeB are the same type
-
-1: if typeA is not subtype of typeB
Comparison is based on AttributeTypes, an IOException is thrown if the
AttributeTypes are not compatiable.
Namespace is not considered in this opperations. | static AttributeType | createAttribute(String typeSpec) Returns AttributeType based on String specification (based on UML). | public static FeatureType | createSubType(FeatureType featureType, String[] properties, CoordinateReferenceSystem override) | public static FeatureType | createSubType(FeatureType featureType, String[] properties, CoordinateReferenceSystem override, String typeName, URI namespace) | public static FeatureType | createSubType(FeatureType featureType, String[] properties) | public static FeatureType | createType(String identification, String typeSpec) Utility method for FeatureType construction. | public static Object | defaultValue(AttributeType attributeType) Provides a defautlValue for attributeType. | public static Object | defaultValue(Class type) Returns a non-null default value for the class that is passed in. | public static Object[] | defaultValues(FeatureType featureType) | public static Object[] | defaultValues(FeatureType featureType, Object[] values) | public static boolean | isMatch(AttributeType a, AttributeType b) | public static Query | mixQueries(Query firstQuery, Query secondQuery, String handle) Takes two
Query objects and produce a new one by mixing the
restrictions of both of them.
The policy to mix the queries components is the following:
-
typeName: type names MUST match (not checked if some or both queries
equals to
Query.ALL )
-
handle: you must provide one since no sensible choice can be done
between the handles of both queries
-
maxFeatures: the lower of the two maxFeatures values will be used (most
restrictive)
-
attributeNames: the attributes of both queries will be joined in a
single set of attributes.
| public static Feature | parse(FeatureType type, String fid, String[] text) | public static Feature | reType(FeatureType featureType, Feature feature) Creates duplicate of feature adjusted to the provided featureType. | public static FeatureReader | reader(Feature[] features) Creates a FeatureReader for testing. | public static FeatureReader | reader(Collection collection) | public static FeatureCollection | results(Feature[] featureArray) | public static FeatureCollection | results(FeatureCollection collection) Returns collection if non empty. | public static FeatureSource | source(Feature[] featureArray) | public static FeatureSource | source(FeatureCollection collection) | public static String | spec(FeatureType featureType) | public static Feature | template(FeatureType featureType) Constructs an empty feature to use as a Template for new content. | public static Feature | template(FeatureType featureType, String featureID) | public static Feature | template(FeatureType featureType, Object[] atts) | public static Feature | template(FeatureType featureType, String featureID, Object[] atts) | public static void | traverse(Filter filter, FilterVisitor visitor) | public static void | traverse(Expression expression, FilterVisitor visitor) | public static void | traverse(Set set, FilterVisitor visitor) Performs a depth first traversal on Filter. | public static Set | traverseDepth(Filter filter) Performs a depth first traversal of Filter. | public static Set | traverseDepth(Expression expression) Performs a depth first traversal of Filter. | static Class | type(String typeName) | static String | typeMap(Class type) | public static File | urlToFile(URL url) Takes a URL and converts it to a File. |
ff | static FilterFactory ff(Code) | | |
attributeNames | public static String[] attributeNames(FeatureType featureType)(Code) | | DOCUMENT ME!
Parameters: featureType - DOCUMENT ME! DOCUMENT ME! |
attributeNames | public static String[] attributeNames(Filter filter, FeatureType featureType)(Code) | | Traverses the filter and returns any encoutered property names.
The feautre type is supplied as contexts used to lookup expressions in cases where the
attributeName does not match the actual name of the type.
|
attributeNames | public static String[] attributeNames(Expression expression, FeatureType featureType)(Code) | | Traverses the expression and returns any encoutered property names.
The feautre type is supplied as contexts used to lookup expressions in cases where the
attributeName does not match the actual name of the type.
|
attributesEqual | public static boolean attributesEqual(Object att, Object otherAtt)(Code) | | DOCUMENT ME!
Parameters: att - DOCUMENT ME! Parameters: otherAtt - DOCUMENT ME! DOCUMENT ME! |
bounds | public static Envelope bounds(FeatureCollection collection)(Code) | | Manually calculates the bounds of a feature collection.
Parameters: collection - |
collection | public static FeatureCollection collection(Feature[] features)(Code) | | Copies the provided features into a FeatureCollection.
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(array));
Parameters: features - Array of features FeatureCollection |
collection | public static FeatureCollection collection(Feature feature)(Code) | | Copies the provided features into a FeatureCollection.
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(feature));
Parameters: features - Array of features FeatureCollection |
collection | public static FeatureCollection collection(FeatureReader reader) throws IOException(Code) | | Copies the provided reader into a FeatureCollection, reader will be closed.
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(reader));
Parameters: features - Array of features FeatureCollection |
collection | public static FeatureCollection collection(FeatureIterator reader) throws IOException(Code) | | Copies the provided reader into a FeatureCollection, reader will be closed.
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(reader));
Parameters: features - Array of features FeatureCollection |
compare | public static int compare(FeatureType typeA, FeatureType typeB)(Code) | | Compare operation for FeatureType.
Results in:
-
1: if typeA is a sub type/reorder/renamespace of typeB
-
0: if typeA and typeB are the same type
-
-1: if typeA is not subtype of typeB
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 Parameters: typeB - FeatureType being compared against |
createAttribute | static AttributeType createAttribute(String typeSpec) throws SchemaException(Code) | | Returns AttributeType based on String specification (based on UML).
Will parse a String of the form: "name:Type:hint"
Where Type is:
-
0,Interger,int: represents Interger
-
0.0, Double, double: represents Double
-
"",String,string: represents String
-
Geometry: represents Geometry
-
full.class.path: represents java type
Where hint is "hint1;hint2;...;hintN", in which "hintN" is one
of:
Parameters: typeSpec - throws: SchemaException - If typeSpect could not be interpreted |
createSubType | public static FeatureType createSubType(FeatureType featureType, String[] properties, CoordinateReferenceSystem override) throws SchemaException(Code) | | Create a derived FeatureType
Parameters: featureType - Parameters: properties - - if null, every property of the feature type in input will be used Parameters: override - throws: SchemaException - |
createType | public static FeatureType createType(String identification, String typeSpec) throws SchemaException(Code) | | 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 Parameters: typeSpec - Specification for FeatureType throws: SchemaException - |
defaultValue | public static Object defaultValue(AttributeType attributeType) throws IllegalAttributeException(Code) | | Provides a defautlValue for attributeType.
Will return null if attributeType isNillable(), or attempt to use
Reflection, or attributeType.parse( null )
Parameters: attributeType - null for nillable attributeType, attempt at reflection throws: IllegalAttributeException - If value cannot be constructed forattribtueType |
defaultValue | public static Object defaultValue(Class type)(Code) | | Returns a non-null default value for the class that is passed in. This is a helper class an can't create a
default class for any type but it does support:
- String
- Object - will return empty string
- Number
- Character
- JTS Geometries
Parameters: type - |
mixQueries | public static Query mixQueries(Query firstQuery, Query secondQuery, String handle)(Code) | | Takes two
Query objects and produce a new one by mixing the
restrictions of both of them.
The policy to mix the queries components is the following:
-
typeName: type names MUST match (not checked if some or both queries
equals to
Query.ALL )
-
handle: you must provide one since no sensible choice can be done
between the handles of both queries
-
maxFeatures: the lower of the two maxFeatures values will be used (most
restrictive)
-
attributeNames: the attributes of both queries will be joined in a
single set of attributes. IMPORTANT: only explicitly
requested attributes will be joint, so, if the method
retrieveAllProperties() of some of the queries returns
true it does not means that all the properties will be
joined. You must create the query with the names of the properties you
want to load.
-
filter: the filtets of both queries are or'ed
Parameters: firstQuery - Query against this DataStore Parameters: secondQuery - DOCUMENT ME! Parameters: handle - DOCUMENT ME! Query restricted to the limits of definitionQuery throws: NullPointerException - if some of the queries is null throws: IllegalArgumentException - if the type names of both queries donot match |
spec | public static String spec(FeatureType featureType)(Code) | | Record typeSpec for the provided featureType
Parameters: featureType - DOCUMENT ME! DOCUMENT ME! |
template | public static Feature template(FeatureType featureType) throws IllegalAttributeException(Code) | | 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 A new Feature of type featureType throws: IllegalAttributeException - if we could not create featureTypeinstance with acceptable default values |
traverse | public static void traverse(Filter filter, FilterVisitor visitor)(Code) | | Parameters: filter - DOCUMENT ME! Parameters: visitor - DOCUMENT ME! |
traverse | public static void traverse(Expression expression, FilterVisitor visitor)(Code) | | Parameters: expression - DOCUMENT ME! Parameters: visitor - DOCUMENT ME! |
traverse | public static void traverse(Set set, FilterVisitor visitor)(Code) | | 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 Parameters: visitor - Vistor to traverse across set |
traverseDepth | public static Set traverseDepth(Filter filter)(Code) | | Performs a depth first traversal of Filter.
Parameters: filter - Set of Filters in traversing filter |
traverseDepth | public static Set traverseDepth(Expression expression)(Code) | | Performs a depth first traversal of Filter.
Parameters: expression - Set of Filters in traversing filter |
urlToFile | public static File urlToFile(URL url)(Code) | | Takes a URL and converts it to a File. The attempts to deal with
Windows UNC format specific problems, specifically files located
on network shares and different drives.
If the URL.getAuthority() returns null or is empty, then only the
url's path property is used to construct the file. Otherwise, the
authority is prefixed before the path.
It is assumed that url.getProtocol returns "file".
Authority is the drive or network share the file is located on.
Such as "C:", "E:", "\\fooServer"
Parameters: url - a URL object that uses protocol "file" a File that corresponds to the URL's location |
|
|