Hi!
I am currently writing a wrapper; to "convert" java beans to features, throw
the SimpleFeature interface...
But there are choices to do, and i would be happy to have your suggestions !
The idea is this :
In an application, we have a model (MVC pattern for instance), described by
some classes observing the bean norme.
We manage this model trow the wrapper, which allow us to consider this model
as features for the geotools.
The SimpleFeatureWrapper is built like this :
public class SimpleFeatureWrapper implements SimpleFeature{
/** The bean to wrap. */
Object bean = null;
/** The list of bean properties. */
Map<String,Object> props = null;
public SimpleFeatureWrapper(Object bean) throws
IllegalAccessException,
InvocationTargetException,
NoSuchMethodException{
this.bean = bean;
props = PropertyUtils.describe(this.bean);
/* Here, we remove the property "class", given for all
* beans, describing the class of bean. (not needed as an attribute
?)
*/
for(Iterator<String> it = props.keySet().iterator(); it.hasNext();){
String key = it.next();
if(key.compareTo("class") == 0)
it.remove();
}
}
}
Problems appear when implementing functions of SimpleFeature, and especially
methods of Property, Attribute, ComplexAttribute and Feature.
My questions are :
- What is exactly the interface Name (getAttribute(Name name),
setAttribute(Name
name)...). Is there an implementation of this ? How can i do a link
between the "Name", and the String describing my property in the Map ?
- What can I return in the getDefaultGeometry() ? A very simple idea
is to scan the Map, trying to find an object instance of Geometry, and
return the first found... any other idea ?
- What can I return in the getFeatureType() ? An idea is to create
dynamically a SimpleFeatureType from the bean, after getting its properties.
Is it really a good idea ? I am not sure. Another way could be forcing
the user to create a SimpleFeatureType for its bean, and pass it throw the
construcor. Any other idea ?
- Is there a way to create a BoundingBox ? I could not find any
information about how to do it ?
- setAttributes(List or Object[]). It s too bad this methods can't
throw any exception... We could test each elements of list or tab, compare
their type with properties type in the Map and throw an exception is the
instanceof is false ! Actually, I can't see how to do this without
exception...
That's all for the moment !
I am waiting for all your ideas...
Thanks
Thomas
PS : I dont know if you are interested to integrate this in the geotools ?
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel