On Nov 26, 2007, at 2:33 AM, Jerome Louvel wrote:
Your suggestion regarding the map of ConverterService is
interesting. However, how would you handle the reverse conversion
(from Representation to Object) ?
Also using a map. For both conversion directions, you allow for the
possibility of subclasses, e.g.:
public class ConverterServiceMap extends ConverterService {
// ...
public Object toObject( Representation rep ) {
for ( Class c = rep.getClass(); c != Object.class;
c = c.getSuperclass() ) {
final ConverterService cs = m_toObjMap.get( c );
if ( cs != null )
return cs.toObject( rep );
}
return super.toObject( rep );
}
}
Sometimes the list of available variants is closely related to the
processing resource, so it may be that the Resource subclass is the
best place to handle such conversions.
Sometimes, yes. But other times, you could have several resources/
services that all share a common format so it would be nice to write
the conversion in a single place.
My vote for now is to keep ConverterService deprecated in 1.1
instead of refactoring it.
:-(
- Paul