Hi all,

Is there any reason there are two different, but similar in functionality, 
methods on the Message API?

getContent( Class<T> clazz ) and get( Class<T> clazz ) both seem to do pretty 
much the same thing.  Just a bit confusing when I accidently use them 
interchangably.


I also noticed that setContent doesn't enforce the generic type properly.

    <T> void setContent(Class<T> format, Object content);
    <T> T getContent(Class<T> format);
Would allow class and object types to be incompatible and then a subsequent 
call to getContent() would ClassCastException.

e.g.

// compiles ok
setContent( XMLStreamReader.class, new Integer( 0 ) );

// fails at runtime despite generic "safety"
XMLStreamReader xmlStreamReader = getContent( XMLStreamReader.class );

The get/put pairing enforces this correctly.

Cheers.

Michael Quilleash
Morgan Stanley | Technology
20 Cabot Square | Canary Wharf | Floor 01
London, E14 4QW
Phone: +44 20 7677-4543
[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not 
intend to waive confidentiality or privilege. Use of this email is prohibited 
when received in error.

Reply via email to