|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectDataUtilities
public class DataUtilities
Utility functions for use when implementing working with data classes.
TODO: Move FeatureType manipulation to feature package
modules/library/main (gt-main.jar)
Constructor Summary | |
---|---|
DataUtilities()
|
Method Summary | |
---|---|
static String[] |
attributeNames(Expression expression)
Deprecated. use #attributeNames(Expression, FeatureType) / |
static String[] |
attributeNames(Expression expression,
SimpleFeatureType featureType)
Traverses the expression and returns any encoutered property names. |
static String[] |
attributeNames(Filter filter)
Deprecated. use #attributeNames(Filter, FeatureType) / |
static String[] |
attributeNames(Filter filter,
SimpleFeatureType featureType)
Traverses the filter and returns any encoutered property names. |
static String[] |
attributeNames(SimpleFeatureType featureType)
DOCUMENT ME! |
static boolean |
attributesEqual(Object att,
Object otherAtt)
DOCUMENT ME! |
static Envelope |
bounds(FeatureCollection<? extends FeatureType,? extends Feature> collection)
Manually calculates the bounds of a feature collection. |
static URL |
changeUrlExt(URL url,
String postfix)
Changes the ending (e.g. ".sld") of a URL |
static DefaultFeatureCollection |
collection(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
Copies the provided features into a FeatureCollection. |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection(FeatureIterator<SimpleFeature> reader)
Copies the provided reader into a FeatureCollection, reader will be closed. |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
Copies the provided reader into a FeatureCollection, reader will be closed. |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection(List<SimpleFeature> list)
Copies the provided features into a FeatureCollection. |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection(SimpleFeature feature)
Copies the provided features into a FeatureCollection. |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection(SimpleFeature[] features)
Copies the provided features into a FeatureCollection. |
static int |
compare(SimpleFeatureType typeA,
SimpleFeatureType typeB)
Compare operation for FeatureType. |
static SimpleFeatureType |
createSubType(SimpleFeatureType featureType,
String[] properties)
DOCUMENT ME! |
static SimpleFeatureType |
createSubType(SimpleFeatureType featureType,
String[] properties,
CoordinateReferenceSystem override)
Create a derived FeatureType |
static SimpleFeatureType |
createSubType(SimpleFeatureType featureType,
String[] properties,
CoordinateReferenceSystem override,
String typeName,
URI namespace)
|
static SimpleFeatureType |
createType(String identification,
String typeSpec)
Utility method for FeatureType construction. |
static SimpleFeatureType |
createType(String namespace,
String typeName,
String typeSpec)
Utility method for FeatureType construction. |
static Object |
defaultValue(AttributeDescriptor attributeType)
Provides a defautlValue for attributeType. |
static Object |
defaultValue(Class type)
Returns a non-null default value for the class that is passed in. |
static Object[] |
defaultValues(SimpleFeatureType featureType)
DOCUMENT ME! |
static Object[] |
defaultValues(SimpleFeatureType featureType,
Object[] values)
DOCUMENT ME! |
static Object |
duplicate(Object src)
|
static URL |
extendURL(URL base,
String extension)
Extends an URL . |
static Set<String> |
fidSet(FeatureCollection<?,?> featureCollection)
Copies the feature ids from each and every feature into a set. |
static URL |
fileToURL(File file)
A replacement for File.toURI().toURL(). |
static URL |
getParentUrl(URL url)
The function is supposed to be equivalent to File .getParent(). |
static boolean |
isMatch(AttributeDescriptor a,
AttributeDescriptor b)
DOCUMENT ME! |
static List<SimpleFeature> |
list(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
Copies the provided fetaures into a List. |
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. |
static SimpleFeature |
parse(SimpleFeatureType type,
String fid,
String[] text)
DOCUMENT ME! |
static FeatureReader<SimpleFeatureType,SimpleFeature> |
reader(Collection<SimpleFeature> collection)
Adapt a collection to a reader for use with FeatureStore.setFeatures( reader ). |
static FeatureReader<SimpleFeatureType,SimpleFeature> |
reader(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
Adapt a collection to a reader for use with FeatureStore.setFeatures( reader ). |
static FeatureReader<SimpleFeatureType,SimpleFeature> |
reader(SimpleFeature[] features)
Creates a FeatureReader |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
results(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
Returns collection if non empty. |
static FeatureCollection<SimpleFeatureType,SimpleFeature> |
results(SimpleFeature[] featureArray)
|
static SimpleFeature |
reType(SimpleFeatureType featureType,
SimpleFeature feature)
Creates duplicate of feature adjusted to the provided featureType. |
static FeatureSource<SimpleFeatureType,SimpleFeature> |
source(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
DOCUMENT ME! |
static FeatureSource<SimpleFeatureType,SimpleFeature> |
source(SimpleFeature[] featureArray)
DOCUMENT ME! |
static String |
spec(FeatureType featureType)
A "quick" String representation of a FeatureType. |
static SimpleFeature |
template(SimpleFeatureType featureType)
Constructs an empty feature to use as a Template for new content. |
static SimpleFeature |
template(SimpleFeatureType featureType,
Object[] atts)
DOCUMENT ME! |
static SimpleFeature |
template(SimpleFeatureType featureType,
String featureID)
DOCUMENT ME! |
static SimpleFeature |
template(SimpleFeatureType featureType,
String featureID,
Object[] atts)
DOCUMENT ME! |
static File |
urlToFile(URL url)
Takes a URL and converts it to a File. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataUtilities()
Method Detail |
---|
public static String[] attributeNames(SimpleFeatureType featureType)
featureType
- DOCUMENT ME!
public static URL fileToURL(File file)
The handling of file.toURL() is broken; the handling of file.toURI().toURL() is known to be broken on a few platforms like mac. We have the urlToFile( URL ) method that is able to untangle both these problems and we use it in the geotools library.
However occasionally we need to pick up a file and hand it to a third party library like EMF; this method performs a couple of sanity checks which we can use to prepare a good URL reference to a file in these situtations.
file
-
public static File urlToFile(URL url)
url
- a URL object that uses protocol "file"
public static String[] attributeNames(Filter filter, SimpleFeatureType featureType)
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.
public static String[] attributeNames(Filter filter)
#attributeNames(Filter, FeatureType)
/
public static String[] attributeNames(Expression expression, SimpleFeatureType featureType)
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.
public static String[] attributeNames(Expression expression)
#attributeNames(Expression, FeatureType)
/
public static int compare(SimpleFeatureType typeA, SimpleFeatureType typeB)
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.
typeA
- FeatureType beind comparedtypeB
- FeatureType being compared againstpublic static boolean isMatch(AttributeDescriptor a, AttributeDescriptor b)
a
- DOCUMENT ME!b
- DOCUMENT ME!
public static SimpleFeature reType(SimpleFeatureType featureType, SimpleFeature feature) throws IllegalAttributeException
featureType
- FeatureType requestedfeature
- Origional Feature from DataStore
IllegalAttributeException
- If opperation could not be performedpublic static Object duplicate(Object src)
public static SimpleFeature template(SimpleFeatureType featureType) throws IllegalAttributeException
We may move this functionality to FeatureType.create( null )?
featureType
- Type of feature we wish to create
IllegalAttributeException
- if we could not create featureType
instance with acceptable default valuespublic static SimpleFeature template(SimpleFeatureType featureType, String featureID) throws IllegalAttributeException
featureType
- DOCUMENT ME!featureID
- DOCUMENT ME!
IllegalAttributeException
- DOCUMENT ME!public static Object[] defaultValues(SimpleFeatureType featureType) throws IllegalAttributeException
featureType
- DOCUMENT ME!
IllegalAttributeException
- DOCUMENT ME!public static SimpleFeature template(SimpleFeatureType featureType, Object[] atts) throws IllegalAttributeException
featureType
- DOCUMENT ME!atts
- DOCUMENT ME!
IllegalAttributeException
- DOCUMENT ME!public static SimpleFeature template(SimpleFeatureType featureType, String featureID, Object[] atts) throws IllegalAttributeException
featureType
- DOCUMENT ME!featureID
- DOCUMENT ME!atts
- DOCUMENT ME!
IllegalAttributeException
- DOCUMENT ME!public static Object[] defaultValues(SimpleFeatureType featureType, Object[] values) throws IllegalAttributeException
featureType
- DOCUMENT ME!values
- DOCUMENT ME!
IllegalAttributeException
- DOCUMENT ME!
ArrayIndexOutOfBoundsException
- DOCUMENT ME!public static Object defaultValue(AttributeDescriptor attributeType) throws IllegalAttributeException
Will return null if attributeType isNillable(), or attempt to use Reflection, or attributeType.parse( null )
attributeType
-
IllegalAttributeException
- If value cannot be constructed for
attribtueTypepublic static Object defaultValue(Class type)
type
-
public static FeatureReader<SimpleFeatureType,SimpleFeature> reader(SimpleFeature[] features) throws IOException
features
- Array of features
IOException
- If provided features Are null or empty
NoSuchElementException
- DOCUMENT ME!public static FeatureSource<SimpleFeatureType,SimpleFeature> source(SimpleFeature[] featureArray)
featureArray
- DOCUMENT ME!
IOException
- DOCUMENT ME!
RuntimeException
- DOCUMENT ME!public static FeatureSource<SimpleFeatureType,SimpleFeature> source(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
collection
- DOCUMENT ME!
NullPointerException
- DOCUMENT ME!
RuntimeException
- DOCUMENT ME!public static FeatureCollection<SimpleFeatureType,SimpleFeature> results(SimpleFeature[] featureArray)
public static FeatureCollection<SimpleFeatureType,SimpleFeature> results(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
collection
-
IOException
- Raised if collection was emptypublic static FeatureReader<SimpleFeatureType,SimpleFeature> reader(Collection<SimpleFeature> collection) throws IOException
collection
- Collection of SimpleFeature
IOException
- IOException if there is any problem reading the content.public static FeatureReader<SimpleFeatureType,SimpleFeature> reader(FeatureCollection<SimpleFeatureType,SimpleFeature> collection) throws IOException
collection
- Collection of SimpleFeature
IOException
- IOException if there is any problem reading the content.public static FeatureCollection<SimpleFeatureType,SimpleFeature> collection(SimpleFeature[] features)
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(array));
features
- Array of features
public static DefaultFeatureCollection collection(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
Often used when gathering a FeatureCollection
FeatureCollection
public static List<SimpleFeature> list(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
featureCollection
-
public static Set<String> fidSet(FeatureCollection<?,?> featureCollection)
This method can be slurp an in memory record of the contents of a
featureCollection
-
public static FeatureCollection<SimpleFeatureType,SimpleFeature> collection(List<SimpleFeature> list)
Often used when gathering a FeatureCollection
list
- features to add to a new FeatureCollection
public static FeatureCollection<SimpleFeatureType,SimpleFeature> collection(SimpleFeature feature)
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(feature));
feature
- a feature to add to a new collection
public static FeatureCollection<SimpleFeatureType,SimpleFeature> collection(FeatureReader<SimpleFeatureType,SimpleFeature> reader) throws IOException
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(reader));
IOException
public static FeatureCollection<SimpleFeatureType,SimpleFeature> collection(FeatureIterator<SimpleFeature> reader) throws IOException
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(reader));
IOException
public static boolean attributesEqual(Object att, Object otherAtt)
att
- DOCUMENT ME!otherAtt
- DOCUMENT ME!
public static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties, CoordinateReferenceSystem override) throws SchemaException
featureType
- properties
- - if null, every property of the feature type in input will be usedoverride
-
SchemaException
public static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties, CoordinateReferenceSystem override, String typeName, URI namespace) throws SchemaException
SchemaException
public static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties) throws SchemaException
featureType
- DOCUMENT ME!properties
- DOCUMENT ME!
SchemaException
- DOCUMENT ME!public static SimpleFeatureType createType(String identification, String typeSpec) throws SchemaException
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". You may also indicate the srid (used to look up a EPSG code).
Examples:
name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"
id:String,polygonProperty:Polygon:srid=32615
identification
- identification of FeatureType:
(namesapce).typeNametypeSpec
- Specification for FeatureType
SchemaException
public static SimpleFeatureType createType(String namespace, String typeName, String typeSpec) throws SchemaException
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". You may also indicate the srid (used to look up a EPSG code).
Examples:
name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"
id:String,polygonProperty:Polygon:srid=32615
identification
- identification of FeatureType:
(namesapce).typeNametypeSpec
- Specification for FeatureType
SchemaException
public static SimpleFeature parse(SimpleFeatureType type, String fid, String[] text) throws IllegalAttributeException
type
- DOCUMENT ME!fid
- DOCUMENT ME!text
- DOCUMENT ME!
IllegalAttributeException
- DOCUMENT ME!public static String spec(FeatureType featureType)
This string representation may be used with createType( name, spec ).
featureType
- FeatureType to represent
public static Query mixQueries(Query firstQuery, Query secondQuery, String handle)
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:
Query.ALL
)
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.
firstQuery
- Query against this DataStoresecondQuery
- DOCUMENT ME!handle
- DOCUMENT ME!
NullPointerException
- if some of the queries is null
IllegalArgumentException
- if the type names of both queries do
not matchpublic static Envelope bounds(FeatureCollection<? extends FeatureType,? extends Feature> collection)
collection
-
public static URL changeUrlExt(URL url, String postfix) throws IllegalArgumentException
URL
url
- URL
like file:/sds/a.bmp
or
http://www.some.org/foo/bar.shp
postfix
- New file extension for the URL
without .
URL
with new extension.
{@link
- MalformedURLException} if the new URL
can not be
created.
IllegalArgumentException
public static URL getParentUrl(URL url) throws MalformedURLException
File
.getParent().
The URL
is converted to a String, truncated to the last / and
then recreated as a new URL.
{@link
- MalformedURLException} if the parent URL
can not
be created.
MalformedURLException
public static URL extendURL(URL base, String extension) throws MalformedURLException
URL
.
base
- Has to be a URL
pointing to a directory. If it doesn't
end with a /
it will be added automatically.extension
- The part that will be added to the URL
MalformedURLException
- if the new URL
can not be created.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |