[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jaxme-dev
Subject:    cvs commit: ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg ComplexTypeSG.java GroupSG.java
From:       jochen () apache ! org
Date:       2005-03-14 2:16:09
Message-ID: 20050314021609.30763.qmail () minotaur ! apache ! org
[Download RAW message or body]

jochen      2005/03/13 18:16:09

  Modified:    src/jaxme/org/apache/ws/jaxme/generator/sg/impl
                        JAXBGroupSG.java JAXBObjectSG.java
                        JAXBComplexTypeSG.java JAXBSchemaSG.java
               src/jaxme/org/apache/ws/jaxme/generator/sg
                        ComplexTypeSG.java GroupSG.java
  Added:       src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg
                        SimpleContentBeanSG.java BeanSG.java
                        GroupBeanSG.java BeanSGImpl.java
                        EmptyElementBeanSG.java
               src/jaxme/org/apache/ws/jaxme/generator/sg/impl
                        ChoiceBeanSG.java SequenceBeanSG.java
                        AllBeanSG.java
  Log:
  Moved the bean generation stuff to separate classes. This wil simplify mixed \
content, or POJO support.  
  Revision  Changes    Path
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/SimpleContentBeanSG.java
  
  Index: SimpleContentBeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl.ccsg;
  
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.js.JavaSource;
  import org.xml.sax.SAXException;
  
  /** Implementation of {@link BeanSG} for elements with simple content.
   */
  public class SimpleContentBeanSG extends EmptyElementBeanSG {
  	/** Creates a new instance generating properties for the
  	 * given type into the Java class <code>pJs</code>.
  	 */
  	public SimpleContentBeanSG(ComplexTypeSG pType, JavaSource pJs) {
  		super(pType, pJs);
  	}
  
  	public void generate() throws SAXException {
  		super.generate();
  		ctSG.getSimpleContentSG().getPropertySG().generate(getJavaSource());
  	}
  }
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/BeanSG.java  
  Index: BeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl.ccsg;
  
  import org.xml.sax.SAXException;
  
  
  /** Interface of a source generator creating the bean
   * interfaces and classes.
   */
  public interface BeanSG {
  	/** Creates the various bean properties.
  	 */
  	public void generate() throws SAXException;
  }
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/GroupBeanSG.java  
  Index: GroupBeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl.ccsg;
  
  import org.apache.ws.jaxme.generator.sg.ComplexContentSG;
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.generator.sg.GroupSG;
  import org.apache.ws.jaxme.generator.sg.ObjectSG;
  import org.apache.ws.jaxme.generator.sg.ParticleSG;
  import org.apache.ws.jaxme.generator.sg.TypeSG;
  import org.apache.ws.jaxme.generator.sg.impl.AllBeanSG;
  import org.apache.ws.jaxme.generator.sg.impl.ChoiceBeanSG;
  import org.apache.ws.jaxme.generator.sg.impl.SequenceBeanSG;
  import org.apache.ws.jaxme.js.JavaSource;
  import org.xml.sax.SAXException;
  
  
  /** Base implementation of {@link BeanSG} for elements
   * with complex content.
   */
  public abstract class GroupBeanSG extends BeanSGImpl {
  	protected final ComplexContentSG ccSG;
  	protected final GroupSG group;
  	protected final ParticleSG[] particles;
  
  	protected GroupBeanSG(ComplexTypeSG pType, JavaSource pJs) throws SAXException {
  		super(pType, pJs);
  		ccSG = pType.getComplexContentSG();
  		group = ccSG.getGroupSG();
  		particles = group.getParticles();
  	}
  
  	protected GroupBeanSG(ComplexTypeSG pType, GroupSG pGroup, JavaSource pJs)
  			throws SAXException {
  		super(pType, pJs);
  		ccSG = null;
  		group = pGroup;
  		particles = group.getParticles();
  	}
  
  	private GroupBeanSG newBeanSG(GroupSG pGroup) throws SAXException {
  		if (pGroup.isSequence()) {
  			return new SequenceBeanSG(ctSG, pGroup, null);
  		} else if (pGroup.isChoice()) {
  			return new ChoiceBeanSG(ctSG, pGroup, null);
  		} else if (pGroup.isAll()) {
  			return new AllBeanSG(ctSG, pGroup, null);
  		} else {
  			throw new IllegalStateException("Invalid group type");
  		}
  	}
  
  	private void generateSubclasses(JavaSource pJs) throws SAXException {
  		for (int i = 0;  i < particles.length;  i++) {
  			ParticleSG particle = particles[i];
  			if (particle.isElement()) {
  				ObjectSG elementSG = particle.getObjectSG();
  				TypeSG typeSG = elementSG.getTypeSG();
  				if (!typeSG.isGlobalType()  &&  !typeSG.isGlobalClass()  &&  \
typeSG.isComplex()) {  ComplexTypeSG complexTypeSG = typeSG.getComplexTypeSG();
  					if (pJs.isInterface()) {
  						complexTypeSG.getXMLInterface(pJs);
  					} else {
  						complexTypeSG.getXMLImplementation(pJs);
  					}
  		        }
  			} else if (particle.isGroup()) {
  				GroupBeanSG beanSG = newBeanSG(particle.getGroupSG());
  				beanSG.generateSubclasses(pJs);
  			} else if (particle.isWildcard()) {
  				throw new IllegalStateException("TODO: Add support for wildcards");
  			} else {
  				throw new IllegalStateException("Unknown particle type: Neither of element, \
group, or wildcard");  }
  		}
  	}
  
  	public void generate() throws SAXException {
  		super.generate();
  		JavaSource js = getJavaSource();
  		generateSubclasses(js);
  		ctSG.getComplexContentSG().generateProperties(js);
  	}
  }
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/BeanSGImpl.java  
  Index: BeanSGImpl.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl.ccsg;
  
  import org.apache.ws.jaxme.generator.sg.AttributeSG;
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.js.JavaSource;
  import org.xml.sax.SAXException;
  
  
  /** Base implementation of {@link BeanSG}, for derivation
   * of subclasses.
   */
  public abstract class BeanSGImpl implements BeanSG {
  	protected final ComplexTypeSG ctSG;
  	private final JavaSource js;
  
  	protected BeanSGImpl(ComplexTypeSG pType, JavaSource pJs) {
  		js = pJs;
  		ctSG = pType;
  	}
  
  	/** Returns the class being generated.
  	 */
  	public JavaSource getJavaSource() { return js; }
  
  	public void generate() throws SAXException {
  		JavaSource js = getJavaSource();
  		AttributeSG[] myAttributes = ctSG.getAttributes();
  		for (int i = 0;  i < myAttributes.length;  i++) {
  			myAttributes[i].getPropertySG().generate(js);
  		}
  	}
  }
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/EmptyElementBeanSG.java \
  Index: EmptyElementBeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl.ccsg;
  
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.js.JavaSource;
  
  
  /** Implementation of {@link BeanSG} for empty elements.
   */
  public class EmptyElementBeanSG extends BeanSGImpl {
  	/** Creates a new instance generating properties for the
  	 * given type into the Java class <code>pJs</code>.
  	 */
  	public EmptyElementBeanSG(ComplexTypeSG pType, JavaSource pJs) {
  		super(pType, pJs);
  	}
  }
  
  
  
  1.20      +67 -136   \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBGroupSG.java  
  Index: JAXBGroupSG.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBGroupSG.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JAXBGroupSG.java	10 Mar 2005 10:14:08 -0000	1.19
  +++ JAXBGroupSG.java	14 Mar 2005 02:16:09 -0000	1.20
  @@ -15,20 +15,13 @@
    */
   package org.apache.ws.jaxme.generator.sg.impl;
   
  -import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
   import org.apache.ws.jaxme.generator.sg.Context;
   import org.apache.ws.jaxme.generator.sg.GroupSG;
   import org.apache.ws.jaxme.generator.sg.GroupSGChain;
  -import org.apache.ws.jaxme.generator.sg.ObjectSG;
   import org.apache.ws.jaxme.generator.sg.ParticleSG;
   import org.apache.ws.jaxme.generator.sg.ParticleSGChain;
  -import org.apache.ws.jaxme.generator.sg.PropertySG;
   import org.apache.ws.jaxme.generator.sg.SGFactory;
   import org.apache.ws.jaxme.generator.sg.SchemaSG;
  -import org.apache.ws.jaxme.generator.sg.TypeSG;
  -import org.apache.ws.jaxme.js.JavaSource;
  -import org.apache.ws.jaxme.logging.Logger;
  -import org.apache.ws.jaxme.logging.LoggerAccess;
   import org.apache.ws.jaxme.xs.XSGroup;
   import org.apache.ws.jaxme.xs.XSParticle;
   import org.apache.ws.jaxme.xs.xml.XsQName;
  @@ -40,133 +33,71 @@
    * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
    */
   public class JAXBGroupSG extends JAXBSGItem implements GroupSGChain {
  -  private static final Logger log = LoggerAccess.getLogger(JAXBGroupSG.class);
  -  private ParticleSG[] particles;
  -  private final boolean isGlobal, isAll, isSequence, isChoice;
  -  private final Context classContext;
  -  private final XsQName qName;
  -
  -  /** <p>Creates a new, global group.</p>
  -   */
  -  protected JAXBGroupSG(SGFactory pFactory, SchemaSG pSchema, XSGroup pGroup) \
                throws SAXException {
  -    super(pFactory, pSchema, pGroup);
  -    isGlobal = true;
  -    qName = pGroup.getName();
  -    isAll = pGroup.isAll();
  -    isSequence = pGroup.isSequence();
  -    isChoice = pGroup.isChoice();
  -    classContext = new GlobalContext(pGroup.getName(), pGroup, null, "Group", \
                pSchema);
  -  }
  -
  -  /** <p>Creates a new, local group.</p>
  -   */
  -  protected JAXBGroupSG(SGFactory pFactory, SchemaSG pSchema, XSGroup pGroup, \
                Context pContext)
  -      throws SAXException {
  -    super(pFactory, pSchema, pGroup);
  -    isGlobal = pGroup.isGlobal();
  -    qName = isGlobal ? pGroup.getName() : null;
  -    isAll = pGroup.isAll();
  -    isSequence = pGroup.isSequence();
  -    isChoice = pGroup.isChoice();
  -    classContext = pContext;
  -  }
  -
  -  public Object newParticleSG(GroupSG pController, XSParticle pParticle) throws \
                SAXException {
  -    return new JAXBParticleSG(pController, pParticle, classContext);
  -  }
  -
  -  public Context getClassContext(GroupSG pController) { return classContext; }
  -
  -  public SGFactory getFactory(GroupSG pController) { return getFactory(); }
  -  public SchemaSG getSchema(GroupSG pController) { return getSchema(); }
  -  public Locator getLocator(GroupSG pController) { return getLocator(); }
  -  public ParticleSG[] getParticles(GroupSG pController) throws SAXException {
  -    if (particles == null) {
  -        XSParticle[] xsParticles = ((XSGroup) getXSObject()).getParticles();
  -        particles = new ParticleSG[xsParticles.length];
  -        for (int i = 0;  i < xsParticles.length;  i++) {
  -          ParticleSGChain chain = (ParticleSGChain) \
                pController.newParticleSG(xsParticles[i]);
  -          ParticleSG particle = new ParticleSGImpl(chain);
  -          particle.init();
  -          particles[i] = particle;
  -        }
  -    }
  -    return particles;
  -  }
  -
  -  public void init(GroupSG pController) throws SAXException {
  -  }
  -
  -  public boolean isAll(GroupSG pController) { return isAll; }
  -  public boolean isGlobal(GroupSG pController) { return isGlobal; }
  -  public boolean isChoice(GroupSG pController) { return isChoice; }
  -  public boolean isSequence(GroupSG pController) { return isSequence; }
  -
  -  public void generateXMLInterfaceSubclasses(GroupSG pController, JavaSource \
                pSource) throws SAXException {
  -    final String mName = "generateSubClasses(JavaSource)";
  -    log.finest(mName, "->", pSource.getQName());
  -    ParticleSG[] myParticles = pController.getParticles();
  -    for (int i = 0;  i < particles.length;  i++) {
  -      ParticleSG particle = myParticles[i];
  -      if (particle.isElement()) {
  -        ObjectSG elementSG = particle.getObjectSG();
  -        TypeSG typeSG = elementSG.getTypeSG();
  -        if (!typeSG.isGlobalType()  &&  !typeSG.isGlobalClass()  &&  \
                typeSG.isComplex()) {
  -            ComplexTypeSG complexTypeSG = typeSG.getComplexTypeSG();
  -            complexTypeSG.getXMLInterface(pSource);
  -        }
  -      } else if (particle.isGroup()) {
  -      	GroupSG groupSG = particle.getGroupSG();
  -      	groupSG.generateXMLInterfaceSubclasses(pSource);
  -      } else if (particle.isWildcard()) {
  -        // Do nothing
  -      } else {
  -        throw new IllegalStateException("Unknown particle type: Neither of \
                element, group, or wildcard");
  -      }
  -    }
  -    log.finest(mName, "<-");
  -  }
  -
  -  public void generateXMLImplementationSubclasses(GroupSG pController, JavaSource \
                pSource) throws SAXException {
  -    final String mName = "generateSubClasses(JavaSource,JavaQName)";
  -    log.finest(mName, "->", new Object[]{pSource.getQName()});
  -    ParticleSG[] myParticles = pController.getParticles();
  -    for (int i = 0;  i < particles.length;  i++) {
  -      ParticleSG particle = myParticles[i];
  -      if (particle.isElement()) {
  -        ObjectSG elementSG = particle.getObjectSG();
  -        TypeSG typeSG = elementSG.getTypeSG();
  -        if (!typeSG.isGlobalType()  &&  !typeSG.isGlobalClass()  &&  \
                typeSG.isComplex()) {
  -          ComplexTypeSG complexTypeSG = typeSG.getComplexTypeSG();
  -          complexTypeSG.getXMLImplementation(pSource);
  -        }
  -      } else if (particle.isGroup()) {
  -      	GroupSG groupSG = particle.getGroupSG();
  -      	groupSG.generateXMLImplementationSubclasses(pSource);
  -      } else if (particle.isWildcard()) {
  -          // Do nothing
  -      } else {
  -        throw new IllegalStateException("Unknown particle type: Neither of \
                element, group, or wildcard");
  -      }
  -    }
  -    log.finest(mName, "<-");
  -  }
  -
  -  private String getXMLSerializersFieldName(PropertySG pChild) throws SAXException \
                {
  -    return "__ser_" + pChild.getXMLFieldName();
  -  }
  -
  -
  -  public void generate(GroupSG pController) throws SAXException {
  -    final String mName = "generate";
  -    log.finest(mName, "->", pController.isGlobal() ? \
                pController.getClassContext().toString() : "Local group");
  -    log.finest(mName, "<-");
  -  }
  -
  -    public XsQName getName(GroupSG pController) {
  -    	if (qName == null) {
  -    		throw new IllegalStateException("Attempt to obtain a local groups name.");
  -        }
  -        return qName;
  -    }
  +	private ParticleSG[] particles;
  +	private final boolean isGlobal, isAll, isSequence, isChoice;
  +	private final Context classContext;
  +	private final XsQName qName;
  +	
  +	/** <p>Creates a new, global group.</p>
  +	 */
  +	protected JAXBGroupSG(SGFactory pFactory, SchemaSG pSchema, XSGroup pGroup) \
throws SAXException {  +		super(pFactory, pSchema, pGroup);
  +		isGlobal = true;
  +		qName = pGroup.getName();
  +		isAll = pGroup.isAll();
  +		isSequence = pGroup.isSequence();
  +		isChoice = pGroup.isChoice();
  +		classContext = new GlobalContext(pGroup.getName(), pGroup, null, "Group", \
pSchema);  +	}
  +	
  +	/** <p>Creates a new, local group.</p>
  +	 */
  +	protected JAXBGroupSG(SGFactory pFactory, SchemaSG pSchema, XSGroup pGroup, \
Context pContext)  +	throws SAXException {
  +		super(pFactory, pSchema, pGroup);
  +		isGlobal = pGroup.isGlobal();
  +		qName = isGlobal ? pGroup.getName() : null;
  +		isAll = pGroup.isAll();
  +		isSequence = pGroup.isSequence();
  +		isChoice = pGroup.isChoice();
  +		classContext = pContext;
  +	}
  +	
  +	public Object newParticleSG(GroupSG pController, XSParticle pParticle) throws \
SAXException {  +		return new JAXBParticleSG(pController, pParticle, classContext);
  +	}
  +	
  +	public Context getClassContext(GroupSG pController) { return classContext; }
  +	
  +	public SGFactory getFactory(GroupSG pController) { return getFactory(); }
  +	public SchemaSG getSchema(GroupSG pController) { return getSchema(); }
  +	public Locator getLocator(GroupSG pController) { return getLocator(); }
  +	public ParticleSG[] getParticles(GroupSG pController) throws SAXException {
  +		if (particles == null) {
  +			XSParticle[] xsParticles = ((XSGroup) getXSObject()).getParticles();
  +			particles = new ParticleSG[xsParticles.length];
  +			for (int i = 0;  i < xsParticles.length;  i++) {
  +				ParticleSGChain chain = (ParticleSGChain) \
pController.newParticleSG(xsParticles[i]);  +				ParticleSG particle = new \
ParticleSGImpl(chain);  +				particle.init();
  +				particles[i] = particle;
  +			}
  +		}
  +		return particles;
  +	}
  +	
  +	public void init(GroupSG pController) throws SAXException {
  +	}
  +	
  +	public boolean isAll(GroupSG pController) { return isAll; }
  +	public boolean isGlobal(GroupSG pController) { return isGlobal; }
  +	public boolean isChoice(GroupSG pController) { return isChoice; }
  +	public boolean isSequence(GroupSG pController) { return isSequence; }
  +	
  +	public XsQName getName(GroupSG pController) {
  +		if (qName == null) {
  +			throw new IllegalStateException("Attempt to obtain a local groups name.");
  +		}
  +		return qName;
  +	}
   }
  
  
  
  1.11      +0 -6      \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBObjectSG.java  
  Index: JAXBObjectSG.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBObjectSG.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JAXBObjectSG.java	10 Mar 2005 10:14:07 -0000	1.10
  +++ JAXBObjectSG.java	14 Mar 2005 02:16:09 -0000	1.11
  @@ -199,9 +199,6 @@
       ComplexTypeSG complexTypeSG = myTypeSG.getComplexTypeSG();
       if (myTypeSG.isGlobalClass()) {
         js.addExtends(complexTypeSG.getClassContext().getXMLInterfaceName());
  -      // No need to generate the types XML interface; this is done by the schema
  -    } else {
  -      complexTypeSG.generateXMLInterfaceMethods(js);
       }
       log.finest(mName, "<-", xmlInterfaceName);
       return js;
  @@ -226,9 +223,6 @@
       ComplexTypeSG complexTypeSG = myTypeSG.getComplexTypeSG();
       if (myTypeSG.isGlobalClass()) {
         js.addExtends(complexTypeSG.getClassContext().getXMLImplementationName());
  -      // No need to generate the types XML implementation; this is done by the \
                schema.
  -    } else {
  -      complexTypeSG.generateXMLImplementationMethods(js);
       }
   
       JavaField myName = js.newJavaField("__qName", QName.class, \
JavaSource.PRIVATE);  
  
  
  1.17      +39 -68    \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBComplexTypeSG.java  
  Index: JAXBComplexTypeSG.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBComplexTypeSG.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JAXBComplexTypeSG.java	10 Mar 2005 10:14:07 -0000	1.16
  +++ JAXBComplexTypeSG.java	14 Mar 2005 02:16:09 -0000	1.17
  @@ -34,14 +34,17 @@
   import org.apache.ws.jaxme.generator.sg.TypeSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.AllHandlerSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.AllDriverSG;
  +import org.apache.ws.jaxme.generator.sg.impl.ccsg.BeanSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.ChoiceHandlerSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.ChoiceDriverSG;
  +import org.apache.ws.jaxme.generator.sg.impl.ccsg.EmptyElementBeanSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.EmptyElementHandlerSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.EmptyElementDriverSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.HandlerSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.SequenceHandlerSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.SequenceDriverSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.DriverSG;
  +import org.apache.ws.jaxme.generator.sg.impl.ccsg.SimpleContentBeanSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.SimpleContentHandlerSG;
   import org.apache.ws.jaxme.generator.sg.impl.ccsg.SimpleContentDriverSG;
   import org.apache.ws.jaxme.impl.JMSAXDriver;
  @@ -176,20 +179,6 @@
   	public Context getClassContext(ComplexTypeSG pController) { return classContext; \
}  public Locator getLocator(ComplexTypeSG pController) { return xsType.getLocator(); \
}  
  -	
  -	private void generateProperties(ComplexTypeSG pController, JavaSource pSource) \
                throws SAXException {
  -		AttributeSG[] myAttributes = pController.getAttributes();
  -		for (int i = 0;  i < myAttributes.length;  i++) {
  -			myAttributes[i].getPropertySG().generate(pSource);
  -		}
  -
  -		if (pController.hasSimpleContent()) {
  -			pController.getSimpleContentSG().getPropertySG().generate(pSource);
  -		} else {
  -            pController.getComplexContentSG().generateProperties(pSource);
  -		}    
  -	}
  -	
   	public JavaSource getXMLInterface(ComplexTypeSG pController) throws SAXException \
{  final String mName = "getXMLInterface";
   		log.finest(mName, "->");
  @@ -197,32 +186,50 @@
   		JavaSourceFactory jsf = \
pController.getTypeSG().getSchema().getJavaSourceFactory();  JavaSource js = \
jsf.newJavaSource(qName, JavaSource.PUBLIC);  js.setType(JavaSource.INTERFACE);
  +		createXMLBean(pController, js);
  +		log.finest(mName, "<-", js.getQName());
  +		return js;
  +	}
   
  -		generateProperties(pController, js);
  -		if (!pController.hasSimpleContent()) {
  -			GroupSG groupSG = pController.getComplexContentSG().getGroupSG();
  -			if (groupSG != null) { // Check required, in case the element doesn't have any \
                childs
  -				groupSG.generateXMLInterfaceSubclasses(js);
  +	private void createXMLBean(ComplexTypeSG pController, JavaSource pJs)
  +			throws SAXException {
  +		BeanSG beanSG = newBeanSG(pController, pJs);
  +		if (!pJs.isInterface()) {
  +			SerializableSG.makeSerializable(pController.getTypeSG().getSchema(), pJs);
  +		}
  +		beanSG.generate();
  +	}
  +
  +	private BeanSG newBeanSG(ComplexTypeSG pController, JavaSource pJs)
  +			throws SAXException {
  +		if (pController.hasSimpleContent()) {
  +			return new SimpleContentBeanSG(pController, pJs);
  +		} else {
  +			ComplexContentSG ccSG = pController.getComplexContentSG();
  +			if (ccSG.isEmpty()) {
  +				return new EmptyElementBeanSG(pController, pJs);
  +			} else {
  +				GroupSG group = ccSG.getGroupSG();
  +				if (group.isAll()) {
  +					return new AllBeanSG(pController, pJs);
  +				} else if (group.isChoice()) {
  +					return new ChoiceBeanSG(pController, pJs);
  +				} else if (group.isSequence()) {
  +					return new SequenceBeanSG(pController, pJs);
  +				} else {
  +					throw new IllegalStateException("Invalid particle type");
  +				}
   			}
   		}
  -		log.finest(mName, "<-", js.getQName());
  -		return js;
   	}
  -	
  +
   	public JavaSource getXMLInterface(ComplexTypeSG pController, JavaSource pSource) \
throws SAXException {  final String mName = "getXMLInterface(JavaSource)";
   		log.finest(mName, "->", pSource.getQName());
   		JavaQName qName = pController.getClassContext().getXMLInterfaceName();
   		JavaSource js = pSource.newJavaInnerClass(qName.getClassName(), \
JavaSource.PUBLIC);  js.setType(JavaSource.INTERFACE);
  -		
  -		generateProperties(pController, js);
  -		if (!pController.hasSimpleContent()) {
  -			GroupSG groupSG = pController.getComplexContentSG().getGroupSG();
  -			if (groupSG != null) { // Check required, in case the element doesn't have any \
                childs
  -				groupSG.generateXMLInterfaceSubclasses(js);
  -			}
  -		}
  +		createXMLBean(pController, js);
   		log.finest(mName, "<-", js.getQName());
   		return js;
   	}
  @@ -233,15 +240,7 @@
   		JavaSourceFactory jsf = \
                pController.getTypeSG().getSchema().getJavaSourceFactory();
   		JavaSource js = \
jsf.newJavaSource(pController.getClassContext().getXMLImplementationName(), \
                JavaSource.PUBLIC);
   		js.addImplements(pController.getClassContext().getXMLInterfaceName());
  -		SerializableSG.makeSerializable(pController.getTypeSG().getSchema(), js);
  -
  -		generateProperties(pController, js);
  -		if (!pController.hasSimpleContent()) {
  -			GroupSG groupSG = pController.getComplexContentSG().getGroupSG();
  -			if (groupSG != null) { // Check required, in case the element doesn't have any \
                childs
  -				groupSG.generateXMLImplementationSubclasses(js);
  -			}
  -		}
  +		createXMLBean(pController, js);
   		log.finest(mName, "<-", js.getQName());
   		return js;
   	}
  @@ -252,15 +251,7 @@
   		JavaSource js = \
pSource.newJavaInnerClass(pController.getClassContext().getXMLImplementationName().getInnerClassName(), \
JavaSource.PUBLIC);  js.setStatic(true);
   		js.addImplements(pController.getClassContext().getXMLInterfaceName());
  -		SerializableSG.makeSerializable(pController.getTypeSG().getSchema(), js);
  -		
  -		generateProperties(pController, js);
  -		if (!pController.hasSimpleContent()) {
  -			GroupSG groupSG = pController.getComplexContentSG().getGroupSG();
  -			if (groupSG != null) { // Check required, in case the element doesn't have any \
                childs
  -				groupSG.generateXMLImplementationSubclasses(js);
  -			}
  -		}
  +		createXMLBean(pController, js);
   		log.finest(mName, "<-", js.getQName());
   		return js;
   	}
  @@ -401,26 +392,6 @@
   		}
   		return complexContentSG;
   	}
  -	
  -	public void generateXMLInterfaceMethods(ComplexTypeSG pController, JavaSource \
                pSource) throws SAXException {
  -		generateProperties(pController, pSource);
  -		if (pController.hasSimpleContent()) {
  -			pController.getSimpleContentSG().getPropertySG().generate(pSource);
  -		} else {
  -			GroupSG groupSG = pController.getComplexContentSG().getGroupSG();
  -			groupSG.generateXMLInterfaceSubclasses(pSource);
  -		}
  -	}
  -	
  -	public void generateXMLImplementationMethods(ComplexTypeSG pController, \
                JavaSource pSource) throws SAXException {
  -		generateProperties(pController, pSource);
  -		if (pController.hasSimpleContent()) {
  -			pController.getSimpleContentSG().getPropertySG().generate(pSource);
  -		} else {
  -			GroupSG groupSG = pController.getComplexContentSG().getGroupSG();
  -			groupSG.generateXMLImplementationSubclasses(pSource);
  -		}
  -	}
   
   	public Object newComplexContentTypeSG(ComplexTypeSG pController) throws \
SAXException {  return new JAXBComplexContentTypeSG(pController, xsType);
  
  
  
  1.14      +0 -4      \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java  
  Index: JAXBSchemaSG.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBSchemaSG.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JAXBSchemaSG.java	10 Mar 2005 10:14:08 -0000	1.13
  +++ JAXBSchemaSG.java	14 Mar 2005 02:16:09 -0000	1.14
  @@ -215,10 +215,6 @@
     }
   
     public void generate(SchemaSG pController) throws SAXException {
  -    GroupSG[] groups = pController.getGroups();
  -    for (int i = 0;  i < groups.length;  i++) {
  -      groups[i].generate();
  -    }
       TypeSG[] types = pController.getTypes();
       for (int i = 0;  i < types.length;  i++) {
         types[i].generate();
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ChoiceBeanSG.java  
  Index: ChoiceBeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl;
  
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.generator.sg.GroupSG;
  import org.apache.ws.jaxme.generator.sg.impl.ccsg.BeanSG;
  import org.apache.ws.jaxme.generator.sg.impl.ccsg.GroupBeanSG;
  import org.apache.ws.jaxme.js.JavaSource;
  import org.xml.sax.SAXException;
  
  
  /** Implementation of {@link BeanSG} for choice groups.
   */
  public class ChoiceBeanSG extends GroupBeanSG implements BeanSG {
  	/** Creates a new instance generating properties for the
  	 * given type into the Java class <code>pJs</code>.
  	 */
  	public ChoiceBeanSG(ComplexTypeSG pType, JavaSource pJs)
  			throws SAXException {
  		super(pType, pJs);
  	}
  
  	/** Creates a new instance generating properties for the
  	 * given group into the Java class <code>pJs</code>.
  	 */
  	public ChoiceBeanSG(ComplexTypeSG pType, GroupSG pGroup, JavaSource pJs)
  			throws SAXException {
  		super(pType, pGroup, pJs);
  	}
  }
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/SequenceBeanSG.java  
  Index: SequenceBeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl;
  
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.generator.sg.GroupSG;
  import org.apache.ws.jaxme.generator.sg.impl.ccsg.BeanSG;
  import org.apache.ws.jaxme.generator.sg.impl.ccsg.GroupBeanSG;
  import org.apache.ws.jaxme.js.JavaSource;
  import org.xml.sax.SAXException;
  
  
  /** Implementation of {@link BeanSG} for sequences.
   */
  public class SequenceBeanSG extends GroupBeanSG implements BeanSG {
  	/** Creates a new instance generating properties for the
  	 * given type into the Java class <code>pJs</code>.
  	 */
  	public SequenceBeanSG(ComplexTypeSG pType, JavaSource pJs)
  			throws SAXException {
  		super(pType, pJs);
  	}
  
  	/** Creates a new instance generating properties for the
  	 * given group into the Java class <code>pJs</code>.
  	 */
  	public SequenceBeanSG(ComplexTypeSG pType, GroupSG pGroup, JavaSource pJs)
  			throws SAXException {
  		super(pType, pGroup, pJs);
  	}
  }
  
  
  
  1.1                  \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/AllBeanSG.java  
  Index: AllBeanSG.java
  ===================================================================
  package org.apache.ws.jaxme.generator.sg.impl;
  
  import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
  import org.apache.ws.jaxme.generator.sg.GroupSG;
  import org.apache.ws.jaxme.generator.sg.impl.ccsg.BeanSG;
  import org.apache.ws.jaxme.generator.sg.impl.ccsg.GroupBeanSG;
  import org.apache.ws.jaxme.js.JavaSource;
  import org.xml.sax.SAXException;
  
  
  /** Implementation of {@link BeanSG} for "all" groups.
   */
  public class AllBeanSG extends GroupBeanSG implements BeanSG {
  	/** Creates a new instance generating properties for the
  	 * given type into the Java class <code>pJs</code>.
  	 */
  	public AllBeanSG(ComplexTypeSG pType, JavaSource pJs) throws SAXException {
  		super(pType, pJs);
  	}
  
  	/** Creates a new instance generating properties for the
  	 * given group into the Java class <code>pJs</code>.
  	 */
  	public AllBeanSG(ComplexTypeSG pType, GroupSG pGroup, JavaSource pJs)
  			throws SAXException {
  		super(pType, pGroup, pJs);
  	}
  }
  
  
  
  1.8       +0 -11     \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/ComplexTypeSG.java  
  Index: ComplexTypeSG.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/ComplexTypeSG.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ComplexTypeSG.java	10 Mar 2005 10:14:08 -0000	1.7
  +++ ComplexTypeSG.java	14 Mar 2005 02:16:09 -0000	1.8
  @@ -60,11 +60,6 @@
      */
     public JavaSource getXMLInterface(JavaSource pSource) throws SAXException;
   
  -  /** <p>Generates the types interface by adding methods
  -   * to the given class.</p>
  -   */
  -  public void generateXMLInterfaceMethods(JavaSource pSource) throws SAXException;
  -
     /** <p>Generates the types implementation as a standalone class.
      * This is used for global types.</p>
      */
  @@ -86,7 +81,6 @@
   
     /** <p>Generates the types XML handler as a standalone class.
      * This is used for global types.</p>
  - * @param pQName TODO
      */
     public JavaSource getXMLHandler(JavaQName pQName) throws SAXException;
   
  @@ -95,11 +89,6 @@
      */
     public JavaSource getXMLHandler(JavaSource pSource) throws SAXException;
   
  -  /** <p>Generates the types implementation by adding methods
  -   * to the given class.</p>
  -   */
  -  public void generateXMLImplementationMethods(JavaSource pSource) throws \
                SAXException;
  -
     /** <p>Returns whether the data type has attributes.</p>
      */
     public boolean hasAttributes();
  
  
  
  1.9       +0 -12     \
ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/GroupSG.java  
  Index: GroupSG.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/GroupSG.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- GroupSG.java	10 Mar 2005 10:14:08 -0000	1.8
  +++ GroupSG.java	14 Mar 2005 02:16:09 -0000	1.9
  @@ -53,18 +53,6 @@
   	 */
   	public Context getClassContext() throws SAXException;
   	
  -	/** <p>Generates the XML interfaces subclasses.</p>
  -	 */
  -	public void generateXMLInterfaceSubclasses(JavaSource pSource) throws \
                SAXException;
  -	
  -	/** <p>Generates the XML implementations subclasses.</p>
  -	 */
  -	public void generateXMLImplementationSubclasses(JavaSource pSource) throws \
                SAXException;
  -	
  -	/** <p>Generates the groups sources.</p>
  -	 */
  -	public void generate() throws SAXException;
  -	
   	/** <p>Returns the groups particles.</p>
   	 */
   	public ParticleSG[] getParticles() throws SAXException;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic