From: Jody G. <jod...@gm...> - 2014-04-29 16:44:47
|
It is more important that the expression implementations used for access do type conversion. Especially in this case the property name expression is expected to do type conversion. As for setAttribute being forgiving, this is an example of the old computer science rule of thumb: be strict it what you output, and forgiving in what you accept as input. You could submit a patch asking setAttributes to be forgiving. We have a fundamental tension between strongly typed feature model, and the relaxed "untyped" filter/expression model used for access. Jody Garnett On Wed, Apr 30, 2014 at 2:01 AM, Andrew Hulbert <ahu...@cc...> wrote: > Hi all, > > I noticed that in SimpleFeatureImpl the setAttribute() methods attempt > to convert an Object into the correct type based on the > AttributeDescriptor but the setAttributes() method takes an entire list > of values and does NOT do conversion. The ResultSetFeature > implementation does not attempt to convert types when setting but does > convert types when in the next() method. > > Example from SimpleFeatureImpl: > public void setAttribute(int index, Object value) throws > IndexOutOfBoundsException { > // first do conversion > Object converted = Converters.convert(value, > getFeatureType().getDescriptor(index).getType().getBinding()); > ... > } > > Question: If I am making my own simple feature implementation, is it > expected that I do type conversion in the setAttribute method? Is there > any history behind why there are two pathways (one which converts and > one that doesn't)? It seems that if the user wanted that they could use > the validating option (though its nice to do a conversion for them). > > Though I'd like to not do conversions, I wanted to check to see if there > was that expectation or convention. > > Thanks, > > Andrew Hulbert > > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > GeoTools-Devel mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-devel > |