jaxb, how to get rid of unnecessary wrapping classes

84 Views Asked by At

I have a dtd file and i used jaxb to generate java classes.

<!ELEMENT Conf (Node+) >
<!ELEMENT Node EMPTY >
<!ATTLIST Node Key CDATA #REQUIRED
      Value CDATA #REQUIRED >

jaxb generated this. Conf class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "node"
})
@XmlRootElement(name = "Conf")
public class Conf {

    @XmlElement(name = "Node", required = true)
    protected List<Node> node;

Node class:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "Node")
public class Node {

    @XmlAttribute(name = "Key", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String key;
    @XmlAttribute(name = "Value", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String value;

For me is the Node class pointless and i'd like to have a map instead:

public class Conf {
    protected Map<String,String> map
}

I guess that im looking for XmlAdater, i've read javadocs but i still have problems to understand how it works.

0

There are 0 best solutions below