views:

217

answers:

1

Hey,

I'm tweaking an XStream output, and I get the following:

      <entry>
        <string>ahh</string>
        <java-class>java.lang.Integer</java-class>
      </entry>

So I try to create an alias for java.lang.Integer.class... Doesn't work. I made aliases for many other classes and it works just fine. I also tried to alias int.class; no luck.

What's the trick?

Thanks!

+1  A: 

It is apparently Integer.class

http://code.google.com/p/jpoco/source/browse/trunk/jpoco/src/main/jpoco/internal/xstream/XStreamFactory.java?r=300

xstream.alias("totalResults", Integer.class); 
             xstream.alias("startIndex", Integer.class); 
             xstream.alias("itemsPerPage", Integer.class); 
             xstream.alias("age", Integer.class); 
Woot4Moo
If .alias(String, Class) really does what I think it does and what it says it does ( http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/XStream.html#alias(java.lang.String,%20java.lang.Class) ), isn't this code realiasing pointlessly the same class to many names? And that's exaclty one thing I've tried; I'd be curious to see the output generated by this code.
M. Joanis
I dont know it wasnt my code, I was just using it as an example to potentially answer your question.
Woot4Moo
That's what I supposed, thank you anyway! I know XStream had "issues" in earlier releases where you had to alias int.class instead of Integer.class because of (un)boxing and things like that... I guess it might be a little something that is left to fix.
M. Joanis
I think that the call to alias will create an alias for the first variable of type Integer found, then the next alias the next variable of type Integer found etc...
Craig Angus