Package org.apache.ws.jaxme.generator.sg

Examples of org.apache.ws.jaxme.generator.sg.ParticleSG


  public void generateProperties(GroupSG pController, JavaSource pSource) throws SAXException {
    final String mName = "generateProperties(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()) {
        PropertySG elementSG = particle.getPropertySG();
        elementSG.generate(pSource);
      } else if (particle.isGroup()) {
        GroupSG groupSG = particle.getGroupSG();
        groupSG.generateProperties(pSource);
      } else if (particle.isWildcard()) {
        PropertySG wildcardSG = particle.getPropertySG();
        wildcardSG.generate(pSource);
      } else {
        throw new IllegalStateException("Unknown particle type: Neither of element, group, or wildcard");
      }
    }
View Full Code Here


  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");
      }
    }
View Full Code Here

  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");
      }
    }
View Full Code Here

  private JavaMethod getXMLSerializersInitMethod(GroupSG pController, JavaSource pSource) throws SAXException {
    ParticleSG[] myParticles = pController.getParticles();
    JavaMethod jm = null;
    DirectAccessible pFactory = null;
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG particle = myParticles[i];
      if (!particle.isElement()) {
        continue;
      }
      ObjectSG child = particle.getObjectSG();
      if (!child.getTypeSG().isComplex()) {
        continue;
      }
      if (jm == null) {
        jm = pSource.newJavaMethod("init", JavaQNameImpl.VOID, JavaSource.PUBLIC);
        pFactory = jm.addParam(JAXBContextImpl.class, "pFactory");
        jm.addLine("super.init(", pFactory, ");");
        jm.addThrows(JAXBException.class);
      }
      String serializerName = getXMLSerializersFieldName(particle.getPropertySG());
      Context myClassContext = child.getTypeSG().getComplexTypeSG().getClassContext();
      JavaQName serializerClass = myClassContext.getXMLSerializerName();
      pSource.newJavaField(serializerName, serializerClass, JavaSource.PRIVATE);
    }
    return jm;
View Full Code Here

    ParticleSG[] myParticles = pController.getParticles();
    JavaMethod jm = null;
    LocalJavaField pElement = null;
    XMLSerializersMarshalChildsSGlet sgLet = null;
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG particle = myParticles[i];
      if (jm == null) {
        jm = pSource.newJavaMethod("marshalChilds", JavaQNameImpl.VOID, JavaSource.PROTECTED);
        DirectAccessible pData = jm.addParam(JavaQNameImpl.getInstance(JMXmlSerializer.Data.class), "pData");
        sgLet = new XMLSerializersMarshalChildsSGlet(pData);
        JavaQName elementInterface = pController.getClassContext().getXMLInterfaceName();
        DirectAccessible pObject = jm.addParam(Object.class, "pObject");
        pElement = jm.newJavaField(elementInterface);
        pElement.addLine("(", elementInterface, ") ", pObject);
        jm.addThrows(SAXException.class);
      }

      if (!particle.isElement()) {
        // TODO: Implement handling for wildcards and subgroups
        //throw new IllegalStateException("Wildcards and subgroups are not implemented.");
        return jm;
      }
     
      sgLet.setChild(particle);
      sgLet.setFieldName(getXMLSerializersFieldName(particle.getPropertySG()));
      particle.getPropertySG().forAllNonNullValues(jm, pElement, sgLet);
    }
    log.finest(mName, "<-");
    return jm;
  }
View Full Code Here

    log.finest(mName, "->", pSource.getQName());
    getXMLSerializersInitMethod(pController, pSource);
    getXMLSerializersMarshalChildsMethod(pController, pSource);
    ParticleSG[] myParticles = pController.getParticles();
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG particle = myParticles[i];
      if (particle.isElement()) {
        ObjectSG objectSG = particle.getObjectSG();
        TypeSG typeSG = objectSG.getTypeSG();
        if (typeSG.isComplex()  &&  !typeSG.isGlobalClass()) {
          typeSG.getComplexTypeSG().getXMLSerializer(pSource);
        }
      }
View Full Code Here

  }

  private void getXMLHandlersElements(GroupSG pController, JavaSource pSource) throws SAXException {
    ParticleSG[] myParticles = pController.getParticles();
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG particle = myParticles[i];
      if (particle.isElement()) {
        ObjectSG objectSG = particle.getObjectSG();
        TypeSG typeSG = objectSG.getTypeSG();
        if (typeSG.isComplex()  &&  !typeSG.isGlobalClass()) {
          typeSG.getComplexTypeSG().getXMLHandler(pSource);
        }
      }
View Full Code Here

  private JavaMethod getXMLHandlersInitMethod(GroupSG pController, JavaSource pSource) throws SAXException {
    JavaMethod jm = null;
    DirectAccessible pData = null;
    ParticleSG[] myParticles = pController.getParticles();
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG particle = myParticles[i];
      if (particle.isElement()) {
        ObjectSG objectSG = particle.getObjectSG();
        TypeSG typeSG = objectSG.getTypeSG();
        if (typeSG.isComplex()) {
          if (jm == null) {
            jm = pSource.newJavaMethod("init", JavaQNameImpl.VOID, JavaSource.PUBLIC);
            pData = jm.addParam(JMHandler.Data.class, "pData");
            jm.addThrows(JAXBException.class);
            jm.addLine("super.init(", pData, ");");
          }

          String f = particle.getPropertySG().getXMLFieldName();
          String handlerFieldName = "__handler_" + f;
          String handlerMethodName = getXMLHandlersMethodName(particle.getPropertySG());

          JavaField jf = pSource.newJavaField(handlerFieldName, JMHandler.class, JavaSource.PRIVATE);
          JavaMethod jm2 = pSource.newJavaMethod(handlerMethodName, JMHandler.class, "protected");
          jm2.addThrows(SAXException.class);
          jm2.addIf(handlerFieldName, " == null");
View Full Code Here

      jc.addLine("The current state. The following values are valid states:");
      jc.addLine(" 0 = Before parsing the element");
      jc.addLine(" 1 = Parsing an unknown element");
      jc.addLine(" 2 = After parsing the element");
      for (int i = 0;  i < myParticles.length;  i++) {
          ParticleSG particle = myParticles[i];
          if (particle.isGroup()) {
              // TODO: process group case properly.
              continue;
          } else if (particle.isElement()) {
              jc.addLine(" " + (3+i) + " = While parsing the child element " + myParticles[i].getObjectSG().getName());
          } else if (particle.isWildcard()) {
              jc.addLine(" " + (3+i) + " = While parsing the wildcard");
          } else {
              throw new IllegalStateException("Invalid particle type.");
          }
      }
View Full Code Here

                                                               Parameter pAttr,
                                 ParticleSG[] pParticles) throws SAXException {
      // Now handle all elements with the namespace uri
      boolean first = true;
      for (int j = 0;  j < pParticles.length;  j++) {
          ParticleSG child = pParticles[j];
          if (!child.isElement()) {
              continue;
          }
          XsQName name = child.getObjectSG().getName();
          if (!name.getNamespaceURI().equals(pURI)) {
              continue;
          }
          pMethod.addIf(first, JavaSource.getQuoted(name.getLocalName()), ".equals(", pLocalName, ")");
          first = false;

          List validStates = new ArrayList();
          if (child.isMultiple()) {
              validStates.add(new Integer(j+3));
          }
          if (pController.isChoice()) {
              validStates.add(new Integer(0));
          } else if (pController.isSequence()) {
              boolean stateZeroIsValid = true;
              for (int k = j-1;  k >= 0;  k--) {
                  ParticleSG kChild = pParticles[k];
                  validStates.add(new Integer(k+3));
                  if (kChild.getMinOccurs() > 0) {
                      stateZeroIsValid = false;
                      break;
                  }
              }
              if (stateZeroIsValid) {
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.generator.sg.ParticleSG

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.