simpleType using enumeration

Schema

    <simpleType name = "URLType">
        <restriction base = "NMTOKEN">
            <enumeration value = "mailto"/>
            <enumeration value = "http"/>
            <enumeration value = "https"/>
            <enumeration value = "ftp"/>
            <enumeration value = "fax"/>
            <enumeration value = "phone"/>
            <enumeration value = "other"/>
        </restriction>
    </simpleType>

URLType Bean

// Generated from examples.xsd
// On Wed Jun 09 11:15:21 EDT 2004
                                                                           
package examples;
                                                                           
public class URLType
 implements java.io.Serializable
{
    protected URLType(java.lang.String value) {
    |   _value = value;
    }
                                                                           
                                                                           
                                                                           
    public static final java.lang.String _mailto = "mailto";
    public static final URLType mailto = new URLType(_mailto);
                                                                           
    public static final java.lang.String _http = "http";
    public static final URLType http = new URLType(_http);
                                                                           
    public static final java.lang.String _https = "https";
    public static final URLType https = new URLType(_https);
                                                                           
    public static final java.lang.String _ftp = "ftp";
    public static final URLType ftp = new URLType(_ftp);
                                                                           
    public static final java.lang.String _fax = "fax";
    public static final URLType fax = new URLType(_fax);
                                                                           
    public static final java.lang.String _phone = "phone";
    public static final URLType phone = new URLType(_phone);
                                                                           
    public static final java.lang.String _other = "other";
    public static final URLType other = new URLType(_other);
                                                                           
    public static examples.URLType fromValue(java.lang.String value) {
    |   if (value == null) throw new java.lang.IllegalArgumentException("can not instantiate enumeration with null value");
    |   if (value.equals(_mailto)) return mailto;
    |   if (value.equals(_http)) return http;
    |   if (value.equals(_https)) return https;
    |   if (value.equals(_ftp)) return ftp;
    |   if (value.equals(_fax)) return fax;
    |   if (value.equals(_phone)) return phone;
    |   if (value.equals(_other)) return other;
    |   throw new java.lang.IllegalArgumentException(">"+value+"< not in enumeration");
    }
                                                                           
                                                                           
    public static examples.URLType fromString(java.lang.String value) {
    |   if (value == null) throw new java.lang.IllegalArgumentException("can not instantiate enumeration with null value");
    |   if (value.equals("mailto")) return mailto;
    |   if (value.equals("http")) return http;
    |   if (value.equals("https")) return https;
    |   if (value.equals("ftp")) return ftp;
    |   if (value.equals("fax")) return fax;
    |   if (value.equals("phone")) return phone;
    |   if (value.equals("other")) return other;
    |   throw new java.lang.IllegalArgumentException(">"+value+"< not in enumeration");
    }
                                                                           
                                                                           
                                                                           
                                                                           
    private java.lang.String _value;
                                                                           
    public java.lang.String getValue() {
    |   return _value;
    }
                                                                           
                                                                           
    public java.lang.String toString() { return _value.toString(); }
                                                                           
    public boolean equals(java.lang.Object obj) {
    |   if (obj == null) return false;
    |   if (!(examples.URLType.class.isAssignableFrom(obj.getClass()))) return false;
    |   examples.URLType object = (examples.URLType) obj;
    |   return object.getValue().equals(this.getValue());
    }
                                                                           
                                                                           
    public int hashCode() { return toString().hashCode(); }
                                                                           
}

URLType Marshaler

// Generated from examples.xsd
// On Wed Jun 09 11:15:21 EDT 2004
                                                                           
package examples;
                                                                           
public class URLTypeMarshaler
extends com.sssw.jbroker.web.xsd.mapping.AnySimpleTypeMarshaler
 implements com.sssw.jbroker.web.encoding.Marshaler
{
    public void serialize(com.sssw.jbroker.web.portable.OutputStream os, java.lang.Object object) throws java.io.IOException
    {
    |   examples.URLType obj = (examples.URLType) object;
    |   os.writeContent(obj.toString());
    }
                                                                           
    public java.lang.Object deserialize(com.sssw.jbroker.web.portable.InputStream is, java.lang.Class javaType) throws java.io.IOException
    {
    |   return examples.URLType.fromString(is.readContent());
    }
    public com.sssw.jbroker.web.encoding.Attribute[] getAttributes(java.lang.Object object)
    {
    |   javax.xml.namespace.QName qname = null;
    |   java.lang.String attVal = null;
    |   java.util.ArrayList attribs = new java.util.ArrayList();
    |   com.sssw.jbroker.web.encoding.Attribute[] attrs = null;
    |   com.sssw.jbroker.web.encoding.Attribute attr = null;
    |   return null;
    }
                                                                           
    public static void validate(java.lang.String val) {
    |   com.sssw.jbroker.web.xsd.mapping.AnySimpleTypeMarshaler.validate(val);
    }
                                                                           
                                                                           
                                                                           
    public java.lang.String getMechanismType() { return null; }
}


Copyright © 2003, 2004 Novell, Inc. All rights reserved. Copyright © 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.