complexType using choice and group

Schema

    <complexType name="Struct5">
        <choice>
            <group ref="PriceGroup"/>
            <element name="USPrice" type="xsd:float"/>
            <element name="UKPrice" type="xsd:double"/>
            <element name="INDPrice" type="xsd:int"/>
            <element name="ENGPrice" type="xsd:string"/>
        </choice>
    </complexType>
                                                                           
    <group name="PriceGroup">
        <sequence>
            <element name="price" type="xsd:double"/>
            <element name="currency" type="xsd:string"/>
        </sequence>
    </group>

Struct5 Bean

// Generated from examples.xsd
// On Wed Jun 09 11:15:21 EDT 2004
                                                                           
package examples;
                                                                           
public class Struct5
    implements java.io.Serializable
{
    private int _choice = -1;
                                                                           
    public int getChoice() { return _choice; }
                                                                           
    private java.lang.Object _value;
                                                                           
    public final static int group0 = 0;
                                                                           
    public examples.PriceGroupGroup getGroup0() {
    |   return (examples.PriceGroupGroup)_value;
    }
                                                                           
    public void setGroup0(examples.PriceGroupGroup group0Val) {
    |   _choice = 0;
    |   _value = group0Val;
    }
                                                                           
    public final static int USPrice = 1;
                                                                           
    public java.lang.Float getUSPrice() {
    |   return (java.lang.Float)_value;
    }
                                                                           
    public void setUSPrice(java.lang.Float USPriceVal) {
    |   _choice = 1;
    |   _value = USPriceVal;
    }
                                                                           
    public final static int UKPrice = 2;
                                                                           
    public java.lang.Double getUKPrice() {
    |   return (java.lang.Double)_value;
    }
                                                                           
    public void setUKPrice(java.lang.Double UKPriceVal) {
    |   _choice = 2;
    |   _value = UKPriceVal;
    }
                                                                           
    public final static int INDPrice = 3;
                                                                           
    public java.lang.Integer getINDPrice() {
    |   return (java.lang.Integer)_value;
    }
                                                                           
    public void setINDPrice(java.lang.Integer INDPriceVal) {
    |   _choice = 3;
    |   _value = INDPriceVal;
    }
                                                                           
    public final static int ENGPrice = 4;
                                                                           
    public java.lang.String getENGPrice() {
    |   return (java.lang.String)_value;
    }
                                                                           
    public void setENGPrice(java.lang.String ENGPriceVal) {
    |   _choice = 4;
    |   _value = ENGPriceVal;
    }
                                                                           
    public java.lang.String toString()
    {
    |   java.lang.StringBuffer buffer = new java.lang.StringBuffer();
    |   buffer.append("examples.Struct5={");
    |   buffer.append(""+_value);
    |   return new java.lang.String(buffer);
    }
                                                                           
    public boolean equals(java.lang.Object object) {
    |   if (!(object instanceof examples.Struct5)) return false;
    |   examples.Struct5 obj = (examples.Struct5) object;
    |                                                                      
    |   if (this._value == null) return (obj._value == null);
    |    return this._value.equals(obj._value);
    }
                                                                           
    public int hashCode() { return toString().hashCode(); }
                                                                           
}

Struct5 Marshaler

// Generated from examples.xsd
// On Wed Jun 09 11:15:21 EDT 2004
                                                                           
package examples;
                                                                           
public class Struct5Marshaler
 implements com.sssw.jbroker.web.encoding.Marshaler
{
    // attributes
    // elements
    private static final javax.xml.namespace.QName _USPRICE = new javax.xml.namespace.QName("http://www.structs.com", "USPrice");
    private static final javax.xml.namespace.QName _UKPRICE = new javax.xml.namespace.QName("http://www.structs.com", "UKPrice");
    private static final javax.xml.namespace.QName _INDPRICE = new javax.xml.namespace.QName("http://www.structs.com", "INDPrice");
    private static final javax.xml.namespace.QName _ENGPRICE = new javax.xml.namespace.QName("http://www.structs.com", "ENGPrice");
                                                                           
    public void serialize(com.sssw.jbroker.web.portable.OutputStream os, java.lang.Object object) throws java.io.IOException
    {
    |   examples.Struct5 obj = (examples.Struct5) object;
    |   int choiceSwitch = obj.getChoice();
    |   if (choiceSwitch == obj.group0) {
    |   |   examples.PriceGroupGroupMarshaler.serialize(os, obj.getGroup0());
    |   }
    |   else if (choiceSwitch == obj.USPrice) {
    |   |   os.writeObject(obj.getUSPrice(), "", _USPRICE.getLocalPart()
    |       , "http://www.w3.org/2001/XMLSchema", "float");}
    |   else if (choiceSwitch == obj.UKPrice) {
    |   |   os.writeObject(obj.getUKPrice(), "", _UKPRICE.getLocalPart()
    |       , "http://www.w3.org/2001/XMLSchema", "double");}
    |   else if (choiceSwitch == obj.INDPrice) {
    |   |   os.writeObject(obj.getINDPrice(), "", _INDPRICE.getLocalPart()
    |       , "http://www.w3.org/2001/XMLSchema", "int");}
    |   else if (choiceSwitch == obj.ENGPrice) {
    |   |   os.writeObject(obj.getENGPrice(), "", _ENGPRICE.getLocalPart()
    |       , "http://www.w3.org/2001/XMLSchema", "string");}
    }
                                                                           
    public java.lang.Object deserialize(com.sssw.jbroker.web.portable.InputStream is, java.lang.Class javaType) throws java.io.IOException
    {
    |   if (!examples.Struct5.class.isAssignableFrom(javaType))
    |       throw new
    |           com.sssw.jbroker.web.ServiceException("can not deserialize " + javaType.getName());
    |                                                                      
    |   examples.Struct5 obj = null;
    |   try {
    |   |   obj = (examples.Struct5) javaType.newInstance();
    |   } catch(Throwable e) {
    |   |   throw new com.sssw.jbroker.web.ServiceException("error instantiating " + javaType.getName());
    |   }
    |   is.setObject(null, obj);
    |   // read elements
    |   com.sssw.jbroker.web.QName  qname  = null;
    |   java.lang.String fName  = null;
    |                                                                      
    |   qname = is.peek();
    |   if (qname != null) {
    |   |   fName = qname.getLocalPart();
    |   |   examples.PriceGroupGroup group0 = null;
    |   |   group0 = examples.PriceGroupGroupMarshaler.deserialize(is);
    |   |                                                                  
    |   |   if (group0 != null) {
    |   |   |   obj.setGroup0(group0);
    |   |   |   return obj;
    |   |   }
    |   |                                                                  
    |   |   java.lang.Float USPrice = null;
    |   |                                                                  
    |   |   if (fName.equals(_USPRICE.getLocalPart())) {
    |   |   |   USPrice = (java.lang.Float)is.readObject(java.lang.Float.class, "", _USPRICE.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "float");
    |   |   }
    |   |                                                                  
    |   |                                                                  
    |   |   if (USPrice != null) {
    |   |   |   obj.setUSPrice(USPrice);
    |   |   |   return obj;
    |   |   }
    |   |                                                                  
    |   |   java.lang.Double UKPrice = null;
    |   |                                                                  
    |   |   if (fName.equals(_UKPRICE.getLocalPart())) {
    |   |   |   UKPrice = (java.lang.Double)is.readObject(java.lang.Double.class, "", _UKPRICE.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "double");
    |   |   }
    |   |                                                                  
    |   |                                                                  
    |   |   if (UKPrice != null) {
    |   |   |   obj.setUKPrice(UKPrice);
    |   |   |   return obj;
    |   |   }
    |   |                                                                  
    |   |   java.lang.Integer INDPrice = null;
    |   |                                                                  
    |   |   if (fName.equals(_INDPRICE.getLocalPart())) {
    |   |   |   INDPrice = (java.lang.Integer)is.readObject(java.lang.Integer.class, "", _INDPRICE.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "int");
    |   |   }
    |   |                                                                  
    |   |                                                                  
    |   |   if (INDPrice != null) {
    |   |   |   obj.setINDPrice(INDPrice);
    |   |   |   return obj;
    |   |   }
    |   |                                                                  
    |   |   java.lang.String ENGPrice = null;
    |   |                                                                  
    |   |   if (fName.equals(_ENGPRICE.getLocalPart())) {
    |   |   |   ENGPrice = (java.lang.String)is.readObject(java.lang.String.class, "", _ENGPRICE.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "string");
    |   |   }
    |   |                                                                  
    |   |                                                                  
    |   |   if (ENGPrice != null) {
    |   |   |   obj.setENGPrice(ENGPrice);
    |   |   |   return obj;
    |   |   }
    |   |                                                                  
    |   }
    |                                                                      
    |                                                                      
    |                                                                      
    |   return obj;
    }
    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;
    |   examples.Struct5 obj = (examples.Struct5) object;
    |   return null;
    }
                                                                           
    private void deserializeAttributes(examples.Struct5 obj, java.util.Map attributes)
    throws java.io.IOException
    {
    |   // set attributes
    |   java.lang.String attr = null;
    }
                                                                           
    private java.util.Map readAttributes(org.xml.sax.Attributes attributes) {
    |   java.util.Map attrs = new java.util.HashMap();
    |   return attrs;
    }
                                                                           
                                                                           
    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.