Package org.apache.ws.jaxme.xs

Examples of org.apache.ws.jaxme.xs.XSGroup


  }

  protected XSGroup assertGroup(XSParticle pParticle) {
    assertTrue(pParticle.isGroup());
    assertEquals(XSParticle.GROUP, pParticle.getType());
    XSGroup result = pParticle.getGroup();
    assertNotNull(result);
    return result;
  }
View Full Code Here


    private final XsEChoice choice;

    public XSChoiceComplexTypeImpl(XSType pOwner, XsTComplexType pType, XsEChoice pChoice) throws SAXException {
      super(pOwner, pType);
      choice = pChoice;
      XSGroup group = pOwner.getXSSchema().getXSObjectFactory().newXSGroup(pOwner, choice);
      group.validate();
      XSParticleImpl particle = new XSParticleImpl(group);
      particle.setMaxOccurs(pChoice.getMaxOccurs());
      particle.setMinOccurs(pChoice.getMinOccurs());     
      if (group.getParticles().length == 0) {
        throw new LocSAXException("The complex type must not have an empty element group, as it is a choice.",
                                     choice.getLocator());
      } else {
        setParticle(pType.isMixed() ? XsComplexContentType.MIXED : XsComplexContentType.ELEMENT_ONLY, particle);
      }
View Full Code Here

    private final XsTAll all;

    public XSAllComplexTypeImpl(XSType pOwner, XsTComplexType pType, XsTAll pAll) throws SAXException {
      super(pOwner, pType);
      all = pAll;
      XSGroup group = pOwner.getXSSchema().getXSObjectFactory().newXSGroup(pOwner, all);
      group.validate();
      XSParticleImpl particle = new XSParticleImpl(group);
      particle.setMaxOccurs(pAll.getMaxOccurs());
      particle.setMinOccurs(pAll.getMinOccurs());
      if (group.getParticles().length == 0) {
        setParticle(XsComplexContentType.EMPTY, particle);
      } else {
        setParticle(pType.isMixed() ? XsComplexContentType.MIXED : XsComplexContentType.ELEMENT_ONLY, particle);
      }
    }
View Full Code Here

      JAXBClass jaxbClass = a.getJAXBClass();
      assertNotNull(jaxbClass);
      assertEquals("b", jaxbClass.getName());
      assertEquals("com.b.c", jaxbClass.getImplClass());
      XSParticle p1 = assertComplexContent(assertComplexType(a));
      XSGroup group = assertGroup(p1);
      XSParticle[] particles = group.getParticles();
      assertEquals(2, particles.length);
      JAXBElement f = (JAXBElement) assertElement(particles[1]);
      jaxbClass = f.getJAXBClass();
      assertNotNull(jaxbClass);
      assertEquals("x", jaxbClass.getName());
      assertNull(jaxbClass.getImplClass());


      JAXBElement g = (JAXBElement) schema.getElement(new XsQName((String) null, "g"));
      assertNotNull(g);
      assertNull(g.getJAXBClass());

      JAXBGroup m = (JAXBGroup) schema.getGroup(new XsQName((String) null, "m"));
      jaxbClass = m.getJAXBClass();
      assertNotNull(jaxbClass);
      assertEquals("k", jaxbClass.getName());
      assertEquals("com.b.i", jaxbClass.getImplClass());
    }

    {
      final String schemaSource =
        "<?xml version='1.0'?>\n" +
        "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'" +
        "           xmlns:jaxb='" + JAXBParser.JAXB_SCHEMA_URI + "'>\n" +
        "  <xs:complexType name='d'>\n" +
        "    <xs:sequence>\n" +
        "      <xs:element name='e'>\n" +
        "        <xs:complexType name='a'>\n" +
        "          <xs:annotation>\n" +
        "            <xs:appinfo>\n" +
        "              <jaxb:class name='b'/>\n" +
        "            </xs:appinfo>\n" +
        "          </xs:annotation>\n" +
        "          <xs:sequence>\n" +
        "            <xs:element name='x' type='xs:int'/>\n" +
        "          </xs:sequence>\n" +
        "          <xs:attribute name='y' type='xs:string'/>\n" +
        "        </xs:complexType>\n" +
        "      </xs:element>\n" +
        "      <xs:element name='f' type='xs:string'>\n" +
        "        <xs:annotation>\n" +
        "          <xs:appinfo>\n" +
        "            <jaxb:class name='x'/>\n" +
        "          </xs:appinfo>\n" +
        "        </xs:annotation>\n" +
        "      </xs:element>\n" +
        "      <xs:element name='g' type='xs:string'/>\n" +
        "    </xs:sequence>\n" +
        "  </xs:complexType>\n" +
        "</xs:schema>";
 
      JAXBParser parser = newJAXBParser();
      InputSource isource = new InputSource(new StringReader(schemaSource));
      isource.setSystemId("testJAXBClass2.xsd");
      JAXBSchema schema = (JAXBSchema) parser.parse(isource);
      JAXBType d = (JAXBType) schema.getType(new XsQName((String) null, "d"));
      assertNotNull(d);
      XSGroup dGroup = assertGroup(assertComplexContent(assertComplexType(d)));
      assertSequence(dGroup);
      XSParticle[] particles = dGroup.getParticles();
      assertEquals(3, particles.length);
      JAXBElement e = (JAXBElement) assertElement(particles[0]);
      JAXBType a = (JAXBType) e.getType();
      JAXBClass jaxbClass = a.getJAXBClass();
      assertNotNull(jaxbClass);
View Full Code Here

    checkJAXBTypesafeEnumClass1BType(b);

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
    XSElement allTypesElement = elements[0];
    XSGroup allTypesGroup = assertGroup(assertComplexContent(assertComplexType(allTypesElement.getType())));
    assertSequence(allTypesGroup);
    XSParticle[] allTypesChilds = allTypesGroup.getParticles();
    assertEquals(2, allTypesChilds.length);
    checkJAXBTypesafeEnumClass1AType(assertElement(allTypesChilds[0]).getType());
    checkJAXBTypesafeEnumClass1BType(assertElement(allTypesChilds[1]).getType());   
  }
View Full Code Here

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);

    XSElement allTypesElement = elements[0];
    XSParticle allTypesElementParticle = assertComplexContent(assertComplexType(allTypesElement.getType()));
    XSGroup group = allTypesElementParticle.getGroup();
    assertSequence(group);
    XSParticle[] allTypesElementsChilds = group.getParticles();
    assertEquals(1, allTypesElementsChilds.length);
    XSElement allSimpleTypesElement = assertElement(allTypesElementsChilds[0]);
    XSParticle allSimpleTypesElementParticle = assertComplexContent(assertComplexType(allSimpleTypesElement.getType()));
    XSGroup allSimpleTypesElementGroup = allSimpleTypesElementParticle.getGroup();
    assertSequence(allSimpleTypesElementGroup);
    XSParticle[] allSimpleTypesElementChilds = allSimpleTypesElementGroup.getParticles();
    assertEquals(9, allSimpleTypesElementChilds.length);

    XSElement stringTypeElement = assertElement(allSimpleTypesElementChilds[0]);
    checkJAXBTypesafeEnumClass2StringType(stringTypeElement.getType());
  }
View Full Code Here

            XsTGroupRef groupRef = (XsTGroupRef) particle;
            XsQName myName = groupRef.getRef();
            if (myName == null) {
              throw new LocSAXException("Missing 'ref' attribute", groupRef.getLocator());
            }
            XSGroup group = getXSSchema().getGroup(myName);
            if (group == null) {
              throw new LocSAXException("Unknown group: " + myName, getLocator());
            }
            group.validate();
            myComplexType = new XSGroupComplexTypeImpl(this, myXsTComplexType, group);
          } else {
            throw new IllegalStateException("Invalid particle: " + particle.getClass().getName());
          }
        } else {
View Full Code Here

    XsAGOccurs occurs;
    XSParticleImpl p;
    if (pParticle instanceof XsTAll) {
      XsTAll all = (XsTAll) pParticle;
      occurs = all;
      XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, all);
      group.validate();
      p = new XSParticleImpl(group);
    } else if (pParticle instanceof XsTNestedParticle) {
      addParticle(pModelGroup, (XsTNestedParticle) pParticle);
      return;
    } else {
View Full Code Here

      wildcard.validate();
      p = new XSParticleImpl(wildcard);
    } else if (pParticle instanceof XsEChoice) {
      XsEChoice choice = (XsEChoice) pParticle;
      occurs = choice;
      XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, choice);
      group.validate();
      p = new XSParticleImpl(group);
    } else if (pParticle instanceof XsESequence) {
      XsESequence sequence = (XsESequence) pParticle;
      occurs = sequence;
      XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, sequence);
      group.validate();
      p = new XSParticleImpl(group);
    } else {
      XsTGroupRef groupRef = null;
      XsTLocalElement localElement = null;
      if (pParticle instanceof XsTGroupRef) {
        groupRef = (XsTGroupRef) pParticle;
      } else if (pParticle instanceof XsTLocalElement) {
        localElement = (XsTLocalElement) pParticle;
        // May be the referenced element is the head of a substitution group
        XsQName ref = localElement.getRef();
        if (ref != null) {
          XSElement referencedElement = getXSSchema().getElement(ref);
          if (referencedElement == null) {
            throw new LocSAXException("The referenced element " + ref + " is undefined.", localElement.getLocator());
          }
          XSGroup substitutedGroup = referencedElement.getSubstitutionGroup();
          if (substitutedGroup != null  &&  substitutedGroup != this) {
            XsObject parent = localElement.getParentObject();
            XsTGroupRefImpl groupRefImpl = (XsTGroupRefImpl) localElement.getObjectFactory().newXsTGroupRef(parent);
            groupRefImpl.setRef(substitutedGroup.getName());
            int maxOccurs = localElement.getMaxOccurs();
            if (maxOccurs == -1) {
              groupRefImpl.setMaxOccurs("unbounded");
            } else {
              groupRefImpl.setMaxOccurs(Integer.toString(maxOccurs));
            }
            groupRefImpl.setMinOccurs(localElement.getMinOccurs());
            groupRef = groupRefImpl;
          }
        }
      } else {
        throw new IllegalStateException("Unknown particle type: " + pParticle.getClass().getName());
      }
      if (groupRef == null) {
        occurs = localElement;
        XSElement element = getXSSchema().getXSObjectFactory().newXSElement(this, localElement);
        element.validate();
        p = new XSParticleImpl(element);
      } else {
        occurs = groupRef;
        XSGroup group = getXSSchema().getXSObjectFactory().newXSGroup(this, groupRef);
        group.validate();
        p = new XSParticleImpl(group);
      }
    }
    pModelGroup.addParticle(p);
    p.setMaxOccurs(occurs.getMaxOccurs());
View Full Code Here

    if (modelGroup == null) {
      XsQName myName = getName();
      if (myName == null) {
        throw new NullPointerException("Missing group name");
      }
      XSGroup group = getXSSchema().getGroup(myName);
      if (group == null) {
        throw new LocSAXException("Unknown group: " + myName, getLocator());
      }
      modelGroup = group;
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.xs.XSGroup

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.