Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

how to use enum in jaxb unmarshalling

Mon Aug 10, 2009 2:09 pm

How to use enum in JAXB un-marshalling

with jaxb,i get a class
Code:
@XmlType(name = "yes_no")
@
XmlEnum
public enum YesNo 
{

    @XmlEnumValue("yes")
    YES("yes"),
    @XmlEnumValue("no")
    NO("no");
    private final String value;

    YesNo(String v) {
        value = v;
    }

    public String value() {
        return value;
    }

    public static YesNo fromValue(String v) {
        for (YesNo c: YesNo.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }
        throw new IllegalArgumentException(v);
    }

}
 


in the class objectefactoy i have no method to create an instance of this class and i can't insatnciate this class



Re: how to use enum in jaxb unmarshalling

Tue Aug 11, 2009 11:35 am

Code:

String str = YesNo .YES.value();
System.out.println("The vaue of enum is "+str);


the output is :

Code:
The vaue of enum is yes


Post a reply
  Related Posts  to : how to use enum in jaxb unmarshalling
 Enum Declaration     -  
 Java enum example     -  
 extending enum in java     -  
 Define enum in java     -  
 Unmarshall From XML using JAXB     -  
 XML using JAXB API in java     -  
 Define Enum inside a class     -  
 update an xml file with jaxb     -  
 insert a namespace in a tag with jaxb     -  
 Passing Enum as Type Parameter to method     -  

Topic Tags

Java JAXB, Java XML