commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GMail - Ugo Gagliardelli <ugo.gagliarde...@gmail.com>
Subject [configuration] PropertyConverter.to method fails
Date Fri, 16 Mar 2012 17:42:33 GMT
I'm experiencing a problem while reading an ini file.
My class is mapping ini section values to comfortable values such as 
Integer, InetAddress and so on, when I retrieve a value as a String I 
get a ConversionException. This is tha stack trace:


My code act as:
             DataConfiguration  db = new 
DataConfiguration(getConfig().getSection(sectionName));
where getConfig returns a HierarchicalINIConfiguration object

             Object value =  db.get(keyType, keyName));

where keyType is a Class<?> object and keyName is a String object

When keyType is java.lang.String I have the problem.
Inside PropertyConverter.to(Class<?> cls, Object value, Object[] params) 
there is a long if/else that if argument cls is java.langString doesn't 
match any condition and throws a ConversionException.

Is this figure correct?

Maybe at the very beginning of the to method should be:

if (cls == value.getClass()) return value;
Thank you for the attention

Ugo Gagliardelli

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message