ConstantExpression returns null when evaluated with a context -------------------------------------------------------------
Key: GEOT-2875 URL: http://jira.codehaus.org/browse/GEOT-2875 Project: GeoTools Issue Type: Bug Components: core main Affects Versions: 2.6.0 Reporter: Andrea Aime Assignee: Jody Garnett Priority: Critical Fix For: 2.6.1 ConstantExpression is used in a number of places as a replacement for Literal. However ConstantExpression breaks the contract of evaluate(object, context) in that it can only return its value if the context is of the same type as the value, otherwise it returns null: {code} public <T> T evaluate(Object object, Class<T> context) { if(value == null || value.getClass().equals(context)) return context.cast( value ); else return null; } {code} Compare this with LiteralImpl, that uses Converters: {code} public Object evaluate(Object feature, Class context) { return Converters.convert(literal, context); } {code} At first reaction I'd say that ConstantExpression should use Converters, but unfortunately it lives in api, where Converters is not available. It cannot be moved to main either, since ConstantExperssion is used in a number of places in api itself. Very bad situation I'd say, not sure how to get out of it. Certainly we cannot recode all the code that relies on evaluate(xxx, context) to make a special case for ConstantExpression. Maybe we can move Converters back to gt-api? The api module would starting looking less like an api thought... Suggestion? Bright ideas? -- 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 ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel