Stuart, I submitted a revised class for producing enumerations that will produce more user-friendly enumerations (no VALUE1 stuff) and is still compatible with the old code set. If you limit your enumerated list to items without spaces, then you can get an enumeration that is usable.
Best, Joe -----Original Message----- From: Stuart Barlow [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 10, 2003 6:43 AM To: [EMAIL PROTECTED] Subject: Re: Enumeration Question Apologies for continuing this old discussion but... I see from the discussion that WSDL2Java is able to convert simple enumerated types into Java static final values. However when I run Java2WSDL in the first step of creating my webservice the public final static fields do not get created in the WSDL. Is this the expected behaviour? If I want enumerated types available to my client do I need to manually edit the WSDL after running the Java2WSDL tool? Thanks, Stuart. McDaniel, Joe wrote: > OK -- I found the "magic!" Does not seem to be documented, but in one > of the tests for Axis I found this: > > <!-- The following test all of the valid enum basic types --> > <xsd:simpleType name="enumString"> > <xsd:restriction base="xsd:string"> > <xsd:enumeration value="Ho Ho Ho"/> <!-- Blanks should force > value<1..n> names --> > <xsd:enumeration value="He He He"/> > <xsd:enumeration value="Ha Ha Ha"/> > </xsd:restriction> > > Ergo, if one does not have any spaces in any of the enumerated values, > then it will automatically generate useful values. IMHO, one should > simply replace spaces with _ and generate HO_HO_HO instead of VALUE1. > > Joe > > -----Original Message----- > From: McDaniel, Joe > Sent: Thursday, November 20, 2003 10:05 AM > To: [EMAIL PROTECTED] > Subject: RE: Enumeration Question > > > Hi Albert, > > OK -- that makes a bit of sense although the type-safe "feature" then > means it is not compile-time "safe" since you cannot use the static > variables (unless you want to use the NotificationType._value1, ...). > What I see, in practice, is things like: > > > nhq.setNotificationType(org.jtc.wo.NotificationType.fromString("data > delivery")); > > instead of something that can be checked at compile time such as: > > > nhq.setNotificationType(org.jtc.wo.NotificationType.DATA_DELIVERY); > > If the names were such as what I show instead of the _value1 pattern, > then the enumerations would be much more useful at compile time. > > Best, > > Joe > > -----Original Message----- > From: Albert Lin [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 19, 2003 5:09 PM > To: [EMAIL PROTECTED] > Subject: Re: Enumeration Question > > > This is because wsdl2java generates "typesafe enums" for each > enumeration. Basically, rather than just creating a series of "static > final" constants, it creates objects for each enumeration, which has a > major advantage of preventing you from assigning an invalid value to an > enumeration. > > A good description of typesafe enums is here: > http://developer.java.sun.com/developer/Books/shiftintojava/page1.html > > -- Albert > > > On Wednesday, November 19, 2003, at 12:55 PM, McDaniel, Joe wrote: > > >>Enumerations using wsdl2java get created (in my opinion) brain-dead. >>Is there a reason for (or a work around) the way that wsdl2java >>creates the static final parameters with names like Color._value1, >>Color._value2, etc. rather than something that could be useful such as > > >>Color.RED, Color.BLUE, etc.? >> >>Best, >> >>Joe McDaniel >> >> > > >
