Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 10:46 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 4 posts ] 
Author Question
 Question subject: how to use enum in jaxb unmarshalling
PostPosted: Mon Aug 10, 2009 2:09 pm 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time

hI

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


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to use enum in jaxb unmarshalling
PostPosted: Tue Aug 11, 2009 11:35 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 56 time
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

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to use enum in jaxb unmarshalling
PostPosted: Tue Aug 11, 2009 12:52 pm 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time
THANKS


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: how to use enum in jaxb unmarshalling
PostPosted: Tue Aug 11, 2009 12:53 pm 
Offline
Newbie
User avatar

Joined: Wed Jul 15, 2009 8:39 am
Posts: 21
Has thanked: 0 time
Have thanks: 0 time
:yahoo: :sohappy: :yahoo:


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 4 posts ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Unmarshall From XML using JAXB  Jaxb  msi_333  1
 Define Enum inside a class  Java examples  msi_333  0
 Java enum example  Java examples  msi_333  1
 problem with binding a choice model with jaxb  Java  totomimi  7
 adding an xmlns attribute xith jaxb  Java  totomimi  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team