commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [Lang] Pair toString
Date Thu, 21 Apr 2011 19:04:35 GMT
Am 21.04.2011 08:24, schrieb Jörg Schaible:
> Hi Hen,
> Henri Yandell wrote:
>> On Wed, Apr 20, 2011 at 3:25 PM, Gary Gregory<>
>> wrote:
> [snip]
>> PairFormat class needed rather than relying on toString functionality :)
>> Could we implement Formattable?
> +1
> Something new learned today :)
> - Jörg
Yes, indeed, this is a good option. I did not know this interface either.

Just blue sky thinking: AOP could also be used to solve this problem. A 
library like AspectJ would allow you to intercept calls to toString() 
methods of specific or all classes. In the aspect you could generate 
your specialized format.

The aspect could even be implemented in a generic way. It could be 
configured with a list of toString handlers for the classes whose format 
is to be adapted. All toString() invocations are intercepted. If a 
suitable handler for the current class is found, it is called. Otherwise 
the aspect proceeds with the regular toString() method.

Or is this too weird?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message