Factory Param Utility Class --------------------------- Key: GEOT-3050 URL: http://jira.codehaus.org/browse/GEOT-3050 Project: GeoTools Issue Type: Improvement Components: data Affects Versions: 2.6.3 Reporter: Jody Garnett Assignee: Jody Garnett Priority: Minor
We return a description of factory parameters in terms of an Param[] (or its superclass Parameter[]). This is a bit of a pain since it is hard to find a param entry by key; or sort out what the different utility methods do. Often you end up writing the same for loops multiple times; or putting things in a Map<String,Param> just to make programming faster. The attached class was combined from a bunch of uDig utility code from handling parameters and operates as a wrapper around a Param[]. {code} class Params { Params(DataAccessFactory) lookup(Class<T>, String, Map<String, ?>) lookup(Class<T>, Map<String, ?>) getParam(String) getParam(Class<?>) } {code} An example use is: {code} Params params = new Params( factory ); String host = params.lookup( String.class, "host", connectionParams ) {code} The expected type is passed in; simply to cut down on casting; if "host" is not available in the factory params it will not be blindly returned. In a similar manner the host "sample" value of localhost will be returned if the connectionParams does not contain an "host" entry. This method builds on Param.handle( connectionParams ). Please note that the Param superclass Parameter has less helpful utility methods; it is my preference to move such things into this Params class rather then complicate the superclass. The approach of a wrapper was taken rather then adding methods to DataUtilities. Notes: - Params may not be the best name for the class - even the above code example has too many things named "param". Should use a plural form since we are wrapping a set of parameters. Ideas: Parameters, ConnectionParameters - Note this is not Andrea's long standing request for a Java Bean; however this class could become a formal DynamicProxy (if we pass the connection parameter values in) or produce a BeanInfo for working with one of the commons bean classes which present a java map as a bean. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel