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

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


    }
  }

  private void findGroups(ParticleSG[] pParticles) throws SAXException {
    for (int i = 0;  i < pParticles.length;  i++) {
      ParticleSG particle = pParticles[i];
      if (particle.isGroup()) {
        GroupSG group = particle.getGroupSG();
        if (!groups.containsKey(group)) {
          GroupHandlerSG handler = newGroupHandlerSG(group);
          groups.put(group, handler);
        }
      }
View Full Code Here


    if (pFrom < ||  pFrom >= particles.length  ||
        pTo < ||  pTo >= particles.length  ||  pTo < pFrom) {
      return;
    }
    for (int i = pFrom;  i <= pTo;  i++) {
      ParticleSG particle = particles[i];
      if (particle.isElement()) {
        ObjectSG oSG = particle.getObjectSG();
        XsQName name = oSG.getName();
        Object uriCondition;
        if ("".equals(name.getNamespaceURI())) {
          uriCondition = new Object[]{"(", getParamNamespaceURI(),
              " == null  ||  ",
              getParamNamespaceURI(),
          ".length() == 0)"};
        } else {
          uriCondition = new Object[]{JavaSource.getQuoted(name.getNamespaceURI()),
              ".equals(", getParamNamespaceURI(), ")"};
        }
        pJm.addIf(i == pFrom, uriCondition, "  &&  ",
              JavaSource.getQuoted(name.getLocalName()),
              ".equals(", getParamLocalName(), ")");
        acceptParticle(pJm, i);
        handleStartOfChildElement(pUnmarshallerHandler, pJm, particle);
        pJm.addLine("return true;");
      } else if (particle.isGroup()) {
        GroupSG gSG = particle.getGroupSG();
        GroupHandlerSG handlerSG = getGroupHandlerSG(gSG);
        pJm.addIf(i == pFrom,
              pUnmarshallerHandler, ".testGroupParser(new ",
              handlerSG.getJavaSource().getQName(), "(), ",
              getParamNamespaceURI(), ", ", getParamLocalName(),
              ", ", getParamQName(), ", ", getParamAttrs(), ")");
        acceptParticle(pJm, i);
        pJm.addLine("return true;");
      } else if (particle.isWildcard()) {
        throw new IllegalStateException("TODO: Add support for wildcards");
      } else {
        throw new IllegalStateException("Invalid particle type");
      }
    }
View Full Code Here

    LocalJavaField element = result.newJavaField(elementInterface);
    element.addLine("(", elementInterface, ") result");
    result.addSwitch(getEndElementState());
    for (int i = 0;  i < particles.length;  i++) {
      result.addCase(new Integer(getState(i)));
      ParticleSG particle = particles[i];
      handleEndElementState(result, element, particle);
    }
    result.addDefault();
    result.addThrowNew(IllegalStateException.class,
               JavaSource.getQuoted("Illegal state: "), " + ",
View Full Code Here

         * corrected via customization.
         */
        elementParticleArray = (Particle[]) elementParticles.toArray(new Particle[elementParticles.size()]);
        for (int i = 0;  i < elementParticleArray.length;  i++) {
            Particle pParticle = elementParticleArray[i];
            ParticleSG p = pParticle.getParticleSG();
            String name = p.getPropertySG().getXMLFieldName();
            for (int j = i+1;  j < elementParticles.size();  j++) {
                Particle qParticle = elementParticleArray[j];
                ParticleSG q = qParticle.getParticleSG();
                if (name.equals(q.getPropertySG().getXMLFieldName())) {
                    ObjectSG pObject = p.getObjectSG();
                    ObjectSG qObject = q.getObjectSG();
                    if (!pObject.isGlobal()  ||  !qObject.isGlobal()  ||
                        pObject != qObject) {
                        throw new SAXParseException("Multiple element particles named " + name
                                                    + ", which aren't references to "
                                                    + " a common global element, are present in a common"
View Full Code Here

        if (isEmpty) {
            return;
        }
        Particle[] particles = getLocalElementParticles(pController);
        for (int i = 0;  i < elementParticleArray.length;  i++) {
      ParticleSG particle = particles[i].getParticleSG();
            PropertySG elementSG = particle.getPropertySG();
      elementSG.generate(pSource);
        }
        log.finest(mName, "<-");
    }
View Full Code Here

        sep = "Choice";
      }
      int num = 0;
      ParticleSG[] groupParticles = pGroup.getParticles();
      for (int i = 0;  i < groupParticles.length;  i++) {
        ParticleSG particle = groupParticles[i];
        if (particle.isElement()) {
          if (num++ > 0) {
            sb.append(sep);
          }
          String f = particle.getPropertySG().getXMLFieldName();
          sb.append(Character.toUpperCase(f.charAt(0)) + f.substring(1));
          if (num == 3) {
            break;
          }
        }
View Full Code Here

  protected int getState(int pParticleNum) { return pParticleNum; }

  protected void acceptParticle(JavaMethod pJm, int pNum) throws SAXException {
    pJm.addIf(getStateField());
    ParticleSG particle = particles[pNum];
    pJm.addIf(getChildNumField(), " != " + pNum);
    pJm.addLine("getHandler().validationEvent(", ValidationEvent.class, ".WARNING, ",
          JavaSource.getQuoted("Multiple different particles present in a choive group."),
          ", ", ValidationEvents.class, ".EVENT_CHOICE_GROUP_REUSE, null);");
    if (!particles[pNum].isMultiple()) {
      pJm.addElse();
      if (particle.isElement()) {
        pJm.addLine("getHandler().validationEvent(", ValidationEvent.class, ".WARNING, ",
              JavaSource.getQuoted("The element " + particle.getObjectSG().getName() +
                           " has already been defined."),
              ", ", ValidationEvents.class, ".EVENT_CHOICE_GROUP_REUSE, null);");
      } else if (particle.isGroup()) {
        pJm.addLine("getHandler().validationEvent(", ValidationEvent.class, ".WARNING, ",
              JavaSource.getQuoted("The group " + GroupUtil.getGroupName(particle.getGroupSG()) +
                         " has already been defined."),
                ", ", ValidationEvents.class, ".EVENT_CHOICE_GROUP_REUSE, null);");
      } else if (particle.isWildcard()) {
        throw new IllegalStateException("TODO: Add support for wildcards.");
      } else {
        throw new IllegalStateException("Invalid particle type");
      }
    }
View Full Code Here

    return getChildNumField();
  }

  protected void acceptParticle(JavaMethod pJm, int pNum) throws SAXException {
    pJm.addIf(getStateField(), "[" + pNum, "]");
    ParticleSG particle = particles[pNum];
    if (particle.isElement()) {
      pJm.addLine("getHandler().validationEvent(", ValidationEvent.class, ".WARNING, ",
            JavaSource.getQuoted("The element " + particle.getObjectSG().getName() +
                         " has already been defined."),
              ", ", ValidationEvents.class, ".EVENT_ALL_GROUP_REUSE, null);");
    } else if (particle.isGroup()) {
      pJm.addLine("getHandler().validationEvent(", ValidationEvent.class, ".WARNING, ",
            JavaSource.getQuoted("The group " + GroupUtil.getGroupName(particle.getGroupSG()) +
                       " has already been defined."),
              ", ", ValidationEvents.class, ".EVENT_ALL_GROUP_REUSE, null);");
    } else if (particle.isWildcard()) {
      throw new IllegalStateException("TODO: Add support for wildcards.");
    } else {
      throw new IllegalStateException("Invalid particle type");
    }
    pJm.addEndIf();
View Full Code Here

    jc.addLine("If the same child occurs again, and the childs boolean");
    jc.addLine("value is true, then an exception is thrown.");
    jc.addLine("These are the indices, to which the child elements are");
    jc.addLine("mapped:");
    for (int i = 0;  i < particles.length;  i++) {
      ParticleSG particle = particles[i];
      if (particle.isGroup()) {
        GroupSG group = particle.getGroupSG();
        if (group.isGlobal()) {
          jc.addLine(" " + i + " = The nested group " + group.getName());
        } else {
          jc.addLine(" " + i + " = An anonymous nested group.");
        }
      } else if (particle.isElement()) {
        jc.addLine(" " + i + " = The child element " + particle.getObjectSG().getName());
      } else if (particle.isWildcard()) {
        throw new IllegalStateException("TODO: Add support for wildcards.");
      } else {
        throw new IllegalStateException("Invalid particle type.");
      }
    }
View Full Code Here

    serializerSG.generate();
    if (!pController.hasSimpleContent()) {
      ComplexContentSG ccSG = pController.getComplexContentSG();
      ParticleSG[] particles = ccSG.getElementParticles();
      for (int i = 0;  i < particles.length;  i++) {
        ParticleSG particle = particles[i];
        TypeSG tSG = particle.getObjectSG().getTypeSG();
        if (tSG.isComplex()  &&  !tSG.isGlobalClass()) {
          tSG.getComplexTypeSG().getXMLSerializer(pSource);
        }
      }
    }
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.