ws-jaxme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joc...@apache.org
Subject cvs commit: ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl JAXBGroupSG.java
Date Thu, 27 May 2004 11:00:40 GMT
jochen      2004/05/27 04:00:40

  Modified:    src/jaxme/org/apache/ws/jaxme/generator/sg/impl
                        JAXBGroupSG.java
  Log:
  Fixed a bug in the creation of sequences introduced with the previous revision.
  
  Revision  Changes    Path
  1.10      +46 -27    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JAXBGroupSG.java	29 Apr 2004 20:40:36 -0000	1.9
  +++ JAXBGroupSG.java	27 May 2004 11:00:40 -0000	1.10
  @@ -19,17 +19,16 @@
   import java.util.ArrayList;
   import java.util.Collections;
   import java.util.HashSet;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Set;
   
   import javax.xml.bind.JAXBException;
  -import javax.xml.bind.ValidationEvent;
   import javax.xml.namespace.QName;
   
   import org.apache.ws.jaxme.JMElement;
   import org.apache.ws.jaxme.JMHandler;
   import org.apache.ws.jaxme.JMXmlSerializer;
  -import org.apache.ws.jaxme.ValidationEvents;
   import org.apache.ws.jaxme.generator.sg.ComplexTypeSG;
   import org.apache.ws.jaxme.generator.sg.Context;
   import org.apache.ws.jaxme.generator.sg.GroupSG;
  @@ -494,8 +493,10 @@
   															   DirectAccessible pStateVar,
   															   JavaMethod pMethod,
   															   String pURI,
  +                                                               Parameter pNamespaceURI,
   															   Parameter pQName,
   															   Parameter pLocalName,
  +                                                               Parameter pAttr,
   															   ParticleSG[] pParticles) throws SAXException {
         // Now handle all elements with the namespace uri
         boolean first = true;
  @@ -556,14 +557,17 @@
             
             pMethod.addBreak();
             pMethod.addDefault();
  -          pMethod.addLine("validationEvent(", ValidationEvent.class, ".WARNING, ",
  -                  JavaSource.getQuoted("The element "), " + ", pQName, " + ",
  -				  JavaSource.getQuoted(" was unexpected at this place."),
  -				  ", ", ValidationEvents.class,
  -				  ".EVENT_UNEXPECTED_CHILD_STATE);");
  +          pMethod.addLine("super.startElement(", pNamespaceURI, ", ", pLocalName, ", ",
pQName, ", ", pAttr, ");");
             pMethod.addBreak();
             pMethod.addEndSwitch();
         }
  +      if (!first) {
  +      	  pMethod.addElse();
  +      }
  +      pMethod.addLine("super.startElement(", pNamespaceURI, ", ", pLocalName, ", ", pQName,
", ", pAttr, ");");
  +      if (!first) {
  +          pMethod.addEndIf(); 
  +      }
     }
   
     private void extendXMLHandlersStartElementMethod(GroupSG pController, JavaSource pSource,
  @@ -576,16 +580,20 @@
         
         JavaQName STRING_TYPE = JavaQNameImpl.getInstance(String.class);
         JavaQName ATTRIBUTES_TYPE = JavaQNameImpl.getInstance(Attributes.class);
  -      JavaMethod jm = pSource.getMethod("startElement", new JavaQName[]{STRING_TYPE, STRING_TYPE,
STRING_TYPE,
  -              ATTRIBUTES_TYPE});
  +      JavaMethod jm = pSource.getMethod("startElement", new JavaQName[]{STRING_TYPE,
  +      		                                                            STRING_TYPE,
  +                                                                        STRING_TYPE,
  +																	    ATTRIBUTES_TYPE});
         if (jm == null) {
             throw new IllegalStateException("No such method: 'startElement' in '" + pSource.getQName()
+ "'.");
         }
  +
         PlaceHolder placeHolder = jm.getPlaceHolder("GroupSG");
         if (placeHolder == null) {
             throw new IllegalStateException("No such placeholder: 'GroupSG' in method 'startElement'");
         }
         placeHolder.remove();
  +
         Parameter[] parameters = jm.getParams();
         Parameter pNamespaceURI = parameters[0];
         Parameter pLocalName = parameters[1];
  @@ -595,28 +603,39 @@
         jm.addCase("1");
         Set namespaces = new HashSet();
         for (int i = 0;  i < myParticles.length;  i++) {
  -          ParticleSG child = myParticles[i];
  +      	  ParticleSG child = myParticles[i];
             if (child.isGroup()) {
  -              // TODO: process group case properly.
  +              // TODO: Process group case properly 
             } else if (child.isWildcard()) {
  -              throw new IllegalStateException();
  +          	  throw new IllegalStateException("Wildcards aren't implemented yet.");
             } else if (child.isElement()) {
  -	          // Did we have the same namespace before? If so, skip
  -	          String uri = child.getObjectSG().getName().getNamespaceURI();
  -	          if (namespaces.contains(uri)) {
  -	              continue;
  -	          }
  -	          
  -	          if ("".equals(uri)) {
  -	              jm.addIf(namespaces.isEmpty(), pNamespaceURI, " == null  ||  ", pNamespaceURI,
".length() == 0");
  -	          } else {
  -	              jm.addIf(namespaces.isEmpty(), JavaSource.getQuoted(uri), ".equals(", pNamespaceURI,
")");
  -	          }
  -	          namespaces.add(uri);
  -	          extendXMLHandlersStartElementMethodAddNamespace(pController, pHandlerVar, pStateVar,
  -	                  										  jm, uri, pQName, pLocalName, myParticles);
  -	          jm.addEndIf();
  +          	  namespaces.add(child.getObjectSG().getName().getNamespaceURI());
  +          } else {
  +              throw new IllegalStateException("Unknown particle type");
             }
  +      }
  +
  +      boolean firstNamespace = true;
  +      for (Iterator iter = namespaces.iterator();  iter.hasNext();  ) {
  +      	  String uri = (String) iter.next();
  +          if ("".equals(uri)) {
  +              jm.addIf(firstNamespace, pNamespaceURI, " == null  ||  ", pNamespaceURI,
".length() == 0");
  +          } else {
  +          	  jm.addIf(firstNamespace, JavaSource.getQuoted(uri), ".equals(", pNamespaceURI,
")");
  +          }
  +          firstNamespace = false;
  +
  +          extendXMLHandlersStartElementMethodAddNamespace(pController, pHandlerVar, pStateVar,
  +          		                                          jm, uri, pNamespaceURI,
  +                                                          pQName, pLocalName, pAttr,
  +                                                          myParticles);
  +      }
  +      if (!firstNamespace) {
  +      	  jm.addElse();
  +      }
  +      jm.addLine("super.startElement(", pNamespaceURI, ", ", pLocalName, ", ", pQName,
", ", pAttr, ");");
  +      if (!firstNamespace) {
  +      	  jm.addEndIf();
         }
         jm.addBreak();
         
  
  
  

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


Mime
View raw message