complexType derivation by extension

1 schema

    <complexType name="Struct3">
        <complexContent>
            <extension base="structs:Struct1">
                <sequence>
                    <element name="date1" type="xsd:date" default="01-01-01"/>
                    <element name="date2" type="xsd:date" fixed="02-02-02"/>
                </sequence>
            </extension>
        </complexContent>
        <attribute name="att1" type="xsd:date"/>
        <anyAttribute/>
    </complexType>

2 Struct3 Bean

// Generated from complex.xsd
// On Mon Dec 08 11:11:33 EST 2003
                                                                           
package complex;
                                                                           
public class Struct3
    extends complex.Struct1
    implements java.io.Serializable
{
    public Struct3() {}
                                                                           
    public Struct3(com.sssw.jbroker.web.xsd.Date att1Val, java.lang.Integer elem1Val, java.lang.String elem2Val, com.sssw.jbroker.web.xsd.Date date1Val) {
    |   setAtt1(att1Val);
    |   setElem1(elem1Val);
    |   setElem2(elem2Val);
    |   setDate1(date1Val);
        }
    public static final com.sssw.jbroker.web.xsd.Date _date2_fixed = get_date2_fixed();
    private static com.sssw.jbroker.web.xsd.Date get_date2_fixed() {
    |   try {
    |   |   return new com.sssw.jbroker.web.xsd.Date("02-02-02");
    |   } catch(Exception e) { throw new RuntimeException(e.getMessage()); }
    }
                                                                           
    public com.sssw.jbroker.web.xsd.Date getDate2() {
    |   return _date2_fixed;
    }
                                                                           
    public void setDate2(com.sssw.jbroker.web.xsd.Date date2Val) {
    |   throw new IllegalArgumentException("Fixed value can not be set!");
    }
                                                                           
    private com.sssw.jbroker.web.xsd.Date _att1;
                                                                           
    public com.sssw.jbroker.web.xsd.Date getAtt1() {
    |   return _att1;
    }
                                                                           
    public void setAtt1(com.sssw.jbroker.web.xsd.Date att1Val) {
    |   _att1 = att1Val;
    }
                                                                           
    private com.sssw.jbroker.web.encoding.Attribute[] _otherAttributes;
                                                                           
    public com.sssw.jbroker.web.encoding.Attribute[] getOtherAttributes() {
    |   return _otherAttributes;
    }
                                                                           
    public void setOtherAttributes(com.sssw.jbroker.web.encoding.Attribute[] otherAttributesVal) {
    |   _otherAttributes = otherAttributesVal;
    }
                                                                           
    private com.sssw.jbroker.web.xsd.Date _date1 = new com.sssw.jbroker.web.xsd.Date("01-01-01");
                                                                           
    public com.sssw.jbroker.web.xsd.Date getDate1() {
    |   return _date1;
    }
                                                                           
    public void setDate1(com.sssw.jbroker.web.xsd.Date date1Val) {
    |   if (date1Val == null) throw new IllegalArgumentException("value can not be null for date1");
    |   _date1 = date1Val;
    }
                                                                           
    public java.lang.String toString() {
    |   java.lang.StringBuffer buffer = new java.lang.StringBuffer();
    |   buffer.append("complex.Struct3={");
    |   buffer.append("_att1="+_att1);
    |   buffer.append(",");
    |   buffer.append("_date1="+_date1);
    |   buffer.append(",");
    |   buffer.append("_date2_fixed="+_date2_fixed);
    |   buffer.append(super.toString());
    |   buffer.append("}");
    |   return buffer.toString();
    }
                                                                           
    public boolean equals(java.lang.Object object) {
    |   if (object == null) return false;
    |   if (!(complex.Struct3.class.isAssignableFrom(object.getClass()))) return false;
    |   complex.Struct3 obj = (complex.Struct3) object;
    |                                                                      
    |   if (_att1 == null) {
    |   |   if (obj._att1 != null) return false;
    |   } else if (!_att1.equals(obj._att1)) return false;
    |                                                                      
    |                                                                      
    |   if (_date1 == null) {
    |   |   if (obj._date1 != null) return false;
    |   } else if (!_date1.equals(obj._date1)) return false;
    |                                                                      
    |                                                                      
    |   return super.equals(obj);
    }
                                                                           
    public int hashCode() { return toString().hashCode(); }
                                                                           
}

3 Struct3 Marshaler

// Generated from complex.xsd
// On Mon Dec 08 11:11:33 EST 2003
                                                                           
package complex;
                                                                           
public class Struct3Marshaler
extends complex.Struct1Marshaler
 implements com.sssw.jbroker.web.encoding.Marshaler
{
    // attributes
    private static final javax.xml.namespace.QName _ATT1 = new javax.xml.namespace.QName("http://www.structs.com", "att1");
                                                                           
                                                                           
    // elements
    private static final javax.xml.namespace.QName _DATE1 = new javax.xml.namespace.QName("http://www.structs.com", "date1");
    private static final javax.xml.namespace.QName _DATE2 = new javax.xml.namespace.QName("http://www.structs.com", "date2");
                                                                           
    public void serialize(com.sssw.jbroker.web.portable.OutputStream os, java.lang.Object object) throws java.io.IOException
    {
    |   super.serialize(os, object);
    |   complex.Struct3 obj = (complex.Struct3) object;
    |                                                                      
    |   // date1
    |   if (obj.getDate1() == null) throw new IllegalArgumentException("value can not be null for date1");
    |   os.writeObject(obj.getDate1(), "", _DATE1.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "date");
    |                                                                      
    |                                                                      
    |   // date2
    |   if (obj.getDate2() == null) throw new IllegalArgumentException("value can not be null for date2");
    |   os.writeObject(obj.getDate2(), "", _DATE2.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "date");
    |                                                                      
    }
                                                                           
    public java.lang.Object deserialize(com.sssw.jbroker.web.portable.InputStream is, java.lang.Class javaType) throws java.io.IOException
    {
    |   if (!complex.Struct3.class.isAssignableFrom(javaType))
    |       throw new
    |           com.sssw.jbroker.web.ServiceException("can not deserialize " + javaType.getName());
    |                                                                      
    |   // get attributes
    |   java.util.Map attributes = readAttributes(is.getAttributes());
    |   complex.Struct3 obj = null;
    |   obj = (complex.Struct3) super.deserialize(is, javaType);
    |   deserializeAttributes(obj, attributes);
    |   // read elements
    |   com.sssw.jbroker.web.QName  qname  = null;
    |   java.lang.String fName  = null;
    |   qname = is.peek();
    |   com.sssw.jbroker.web.xsd.Date date1 = null;
    |   date1 = (com.sssw.jbroker.web.xsd.Date)is.readObject(com.sssw.jbroker.web.xsd.Date.class, "", _DATE1.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "date");
    |                                                                      
    |   obj.setDate1(date1);
    |                                                                      
    |   qname = is.peek();
    |   com.sssw.jbroker.web.xsd.Date date2 = null;
    |   com.sssw.jbroker.web.xsd.Date date2_fixed = (com.sssw.jbroker.web.xsd.Date)is.readObject(com.sssw.jbroker.web.xsd.Date.class, "", _DATE2.getLocalPart(), "http://www.w3.org/2001/XMLSchema", "date");
    |   if (!obj.getDate2().equals(date2_fixed))
    |       throw new IllegalArgumentException("fixed value not correct: "+date2_fixed);
    |                                                                      
    |                                                                      
    |   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;
    |   complex.Struct3 obj = (complex.Struct3) object;
    |                                                                      
    |   com.sssw.jbroker.web.encoding.Attribute[] sattrs = super.getAttributes(object);
    |   if (sattrs != null) {
    |   |   for (int i=0; i < sattrs.length; i++) {
    |   |   |   attribs.add(sattrs[i]);
    |   |   }
    |   }
    |                                                                      
    |   if (obj.getAtt1() != null) {
    |   |   qname = new javax.xml.namespace.QName("", "att1");
    |   |   attVal = java.lang.String.valueOf(obj.getAtt1());
    |   |   attr = new com.sssw.jbroker.web.encoding.Attribute(qname, attVal);
    |   |   attribs.add(attr);
    |   }
    |   attrs = obj.getOtherAttributes();
    |   if (attrs != null) {
    |   |   for(int i =0; i < attrs.length; i++) 
    |   |       attribs.add(attrs[i]);
    |   }
    |                                                                      
    |   attrs = new com.sssw.jbroker.web.encoding.Attribute[attribs.size()];
    |   attribs.toArray(attrs);
    |   return attrs;
    }
                                                                           
    private void deserializeAttributes(complex.Struct3 obj, java.util.Map attributes)
    throws java.io.IOException
    {
    |   // set attributes
    |   java.lang.String attr = null;
    |                                                                      
    |   attr = (java.lang.String) attributes.get(_ATT1);
    |   if (attr != null) {
    |   |   attributes.remove(_ATT1);
    |   |   obj.setAtt1(new com.sssw.jbroker.web.xsd.Date(attr));
    |   }
    |   deserializeAnyAttributes(obj, attributes);
    }
                                                                           
    private void deserializeAnyAttributes(complex.Struct3 obj, java.util.Map attributes)
    throws java.io.IOException
    {
    |   javax.xml.namespace.QName attName = null;
    |   javax.xml.namespace.QName attVal = null;
    |   com.sssw.jbroker.web.encoding.Attribute[] attrs = null;
    |   com.sssw.jbroker.web.encoding.Attribute attr = null;
    |                                                                      
    |   attrs = new com.sssw.jbroker.web.encoding.Attribute[attributes.size()];
    |   java.util.Set attSet = attributes.entrySet();
    |   java.util.Iterator it = attSet.iterator();
    |   int i =0;
    |   while(it.hasNext()) {
    |   |   java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
    |   |   attName = (javax.xml.namespace.QName)entry.getKey();
    |   |   attVal = new javax.xml.namespace.QName((java.lang.String)entry.getValue());
    |   |   attr = new com.sssw.jbroker.web.encoding.Attribute(attName, attVal);
    |   |   attrs[i] = attr;
    |   |   i++;
    |   }
    |   obj.setOtherAttributes(attrs);
    }
                                                                           
    private java.util.Map readAttributes(org.xml.sax.Attributes attributes) {
    |   java.util.Map attrs = new java.util.HashMap();
    |   int len = attributes.getLength();
    |   for (int i=0; i < len; i++) {
    |   |   java.lang.String uri = attributes.getURI(i);
    |   |   java.lang.String ln = attributes.getLocalName(i);
    |   |   javax.xml.namespace.QName attName = new javax.xml.namespace.QName(uri, ln);
    |   |   java.lang.String attVal = attributes.getValue(i);
    |   |   if (ln.equalsIgnoreCase("type"))
    |   |       if (uri.equalsIgnoreCase("http://www.w3.org/2001/XMLSchema-instance"))
    |   |           continue;
    |   |   attrs.put(attName, attVal);
    |   }
    |   return attrs;
    }
                                                                           
    public java.lang.String getMechanismType() { return null; }
}
Copyright © 2000-2003, Novell, Inc. All rights reserved.