Skip to main content

How to use a TreeMap in JAXB?

3 replies [Last post]
yvilke
Offline
Joined: 2005-07-25
Points: 0

Hello,

Does anyone knows how a TreeMap can be used in JAXB?
Is it possible to use a TreeMap in an XML schema?

Thanks in advance

Yvilke

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

Yes. Try something like
[code]
public class Foo {
public Map m1 = new TreeMap(CUSTOM_COMPARATOR);
public TreeMap m2 = new TreeMap(CUSTOM_COMPARATOR);
}
[/code]

yvilke
Offline
Joined: 2005-07-25
Points: 0

Hello,

I want to generate my Java Objects with the help off XJC.
So I make first an XML Schema, but I don't know how to make a TreeMap. Do you know how I can do that?

Thanks

Yvilke

kohsuke
Offline
Joined: 2003-06-09
Points: 0

XJC will never generate a class that uses TreeMap. It's not very easy for a tool to infer that the generated object model should be using Map.