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

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


    ObjectSG[] elements = jschema.getElements();
    assertNotNull(elements);
    assertEquals(2, elements.length);

    ObjectSG ea = elements[0];
    assertTrue(ea.getTypeSG().isComplex());
    ComplexTypeSG eact = ea.getTypeSG().getComplexTypeSG();
    AttributeSG[] eactAttr = eact.getAttributes();
    assertEquals(3, eactAttr.length);
    assertEquals(new XsQName((String) null, "d"), eactAttr[0].getName());
    assertEquals(eactAttr[0].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(Calendar.class));
    assertEquals(new XsQName((String) null, "e"), eactAttr[1].getName());
    assertEquals(eactAttr[1].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(float.class));
    assertEquals(new XsQName((String) null, "a"), eactAttr[2].getName());
    assertEquals(eactAttr[2].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(String.class));

    ObjectSG eb = elements[1];
    assertTrue(eb.getTypeSG().isComplex());
    ComplexTypeSG ebct = eb.getTypeSG().getComplexTypeSG();
    AttributeSG[] ebctAttr = ebct.getAttributes();
    assertEquals(5, ebctAttr.length);
    assertEquals(new XsQName((String) null, "g"), ebctAttr[0].getName());
    assertEquals(ebctAttr[0].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(double.class));
    assertEquals(new XsQName((String) null, "d"), ebctAttr[1].getName());
View Full Code Here


    SchemaSG jschema = parse(schema, "testElements.xsd");

    ObjectSG[] elements = jschema.getElements();
    assertEquals(4, elements.length);

    ObjectSG e1 = elements[0];
    assertEquals(new XsQName((String) null, "a"), e1.getName());
    TypeSG t1 = e1.getTypeSG();
    assertTrue(!t1.isComplex());
    assertTrue(t1.getSimpleTypeSG().isAtomic());
    assertEquals(t1.getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(String.class));

    ObjectSG e2 = elements[1];
    assertEquals(new XsQName((String) null, "b"), e2.getName());
    TypeSG t2 = e2.getTypeSG();
    assertTrue(!t2.isComplex());
    SimpleTypeSG st2 = t2.getSimpleTypeSG();
    assertTrue(st2.isAtomic());
    assertEquals(JavaQNameImpl.getInstance(float.class), st2.getRuntimeType());

    ObjectSG e3 = elements[2];
    assertEquals(new XsQName((String) null, "c"), e3.getName());
    TypeSG t3 = e3.getTypeSG();
    assertTrue(t3.isComplex());
    ComplexTypeSG ct3 = t3.getComplexTypeSG();
    assertTrue(!ct3.hasSimpleContent());
    ComplexContentSG cct3 = ct3.getComplexContentSG();
    ParticleSG[] childs = cct3.getGroupSG().getParticles();
    assertEquals(2, childs.length);
    assertTrue(childs[0].isElement());
    ObjectSG child1 = childs[0].getObjectSG();
    assertEquals(new XsQName((String) null, "a"), child1.getName());
    assertTrue(childs[1].isElement());
    ObjectSG child2 = childs[1].getObjectSG();
    assertEquals(new XsQName((String) null, "d"), child2.getName());
    assertTrue(!child2.getTypeSG().isComplex());
    SimpleTypeSG st4 = child2.getTypeSG().getSimpleTypeSG();
    assertEquals(JavaQNameImpl.getInstance(double.class.getName()), st4.getRuntimeType());
    AttributeSG[] attributes = ct3.getAttributes();
    assertEquals(1, attributes.length);
    assertEquals(new XsQName((String) null, "e"), attributes[0].getName());
    assertTrue(!attributes[0].getTypeSG().isComplex());

    ObjectSG e4 = elements[3];
    assertTrue(e4.getTypeSG().isComplex());
    ComplexTypeSG ct4 = e4.getTypeSG().getComplexTypeSG();
    assertTrue(ct4.hasSimpleContent());
    SimpleContentSG sct4 = ct4.getSimpleContentSG();
    assertTrue(!sct4.getContentTypeSG().isComplex());
    assertEquals(JavaQNameImpl.getInstance(int.class), sct4.getContentTypeSG().getRuntimeType());
    assertEquals(1, ct4.getAttributes().length);
View Full Code Here

   
    SchemaSG jschema = parse(schema, "testFacets.xsd");

    ObjectSG[] elements = jschema.getElements();
    assertEquals(1, elements.length);
    ObjectSG se1 = elements[0];
    assertEquals(new XsQName((String) null, "a"), se1.getName());
    assertTrue(!se1.getTypeSG().isComplex());
    SimpleTypeSG sst1 = se1.getTypeSG().getSimpleTypeSG();
    assertEquals(JavaQNameImpl.getInstance(String.class), sst1.getRuntimeType());
    Facet facet = sst1.getFacet(Facet.ENUMERATION);
    assertNotNull(facet);
    String[] values = facet.getValues();
    assertNotNull(values);
View Full Code Here

    // purchaseOrder
    // <xsd:element name='purchaseOrder' type='PurchaseOrderType'/>
    ObjectSG[] elements = jschema.getElements();
    assertNotNull(elements);
    assertEquals(2, elements.length);
    ObjectSG purchaseOrder = elements[1];
    assertEquals(new XsQName((String) null, "purchaseOrder"), purchaseOrder.getName());
    assertTrue(purchaseOrder.getTypeSG().isComplex());
    assertTrue(purchaseOrder.getTypeSG().isGlobalType());
    assertEquals(new XsQName((String) null, "PurchaseOrderType"), purchaseOrder.getTypeSG().getName());
  }
View Full Code Here

      "</xsd:schema> \n";

    SchemaSG jschema = parse(schema, "testRestrictionMaxExclusive.xsd");
    ObjectSG[] elements = jschema.getElements();
    assertEquals(1, elements.length);
    ObjectSG quantity = elements[0];
    String maxExclusive = quantity.getTypeSG().getSimpleTypeSG().getAtomicType().getMaxExclusive();
    assertNotNull(maxExclusive);
    assertEquals("100", maxExclusive);
  }
View Full Code Here

      if (childs != null) {
        for (int i = 0;  i < childs.length;  i++) {
          ParticleSG child = childs[i];
          // Accept only simple elements
          if (child.isElement()) {
            ObjectSG objectSG = child.getObjectSG();
            if (!objectSG.getTypeSG().isComplex()) {
              allChilds.add(child);
            }
          }
        }
      }
View Full Code Here

      pSG.generate(js);
    } else {
      elementSG.generate(pJs);
    }

    ObjectSG oSG = pParticle.getObjectSG();
    TypeSG typeSG = oSG.getTypeSG();
    if (!typeSG.isGlobalType()  &&  !typeSG.isGlobalClass()  &&  typeSG.isComplex()) {
      ComplexTypeSG complexTypeSG = typeSG.getComplexTypeSG();
      if (pJs.isInterface()) {
        complexTypeSG.getXMLInterface(pJs);
      } else {
View Full Code Here

    return particleSG.getMinOccurs() > 0;
  }

  protected void handleStartOfChildElement(Object pUnmarshallerHandler,
                       JavaMethod pJm, ParticleSG pParticle) {
    ObjectSG oSG = pParticle.getObjectSG();
    TypeSG tSG = oSG.getTypeSG();
    if (tSG.isComplex()) {
      JavaQName elementInterfaceClass = pParticle.getObjectSG().getClassContext().getXMLInterfaceName();
      Object[] o, h;
      if (oSG.getClassContext().isGlobal()) {
        LocalJavaField manager = pJm.newJavaField(JMManager.class);
        manager.addLine("getHandler().getJMUnmarshaller().getJAXBContextImpl().getManagerS(",
            elementInterfaceClass, ".class)");
        o = new Object[]{manager, ".getElementS();"};
        h = new Object[]{manager, ".getHandler();"};
      } else {
        Context context = oSG.getClassContext();
        o = new Object[]{" new ", context.getXMLImplementationName(), "()"};
        h = new Object[]{" new ", context.getXMLHandlerName(), "()"};
      }
      LocalJavaField oField = pJm.newJavaField(Object.class);
      oField.addLine(o);
      LocalJavaField hField = pJm.newJavaField(JMSAXElementParser.class);
      hField.addLine(h);
      XsQName name = oSG.getName();
      pJm.addLine(hField, ".init(", pUnmarshallerHandler, ", ", oField, ", ",
          JavaSource.getQuoted(name.getNamespaceURI()), ", ",
          JavaSource.getQuoted(name.getLocalName()),
      ", ", pUnmarshallerHandler, ".getLevel());");
      pJm.addLine(hField, ".setAttributes(", getParamAttrs(), ");");
View Full Code Here

      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(),
View Full Code Here

  }

  private void handleEndElementState(JavaMethod pJm, LocalJavaField pElement,
                     ParticleSG pParticle) throws SAXException {
    if (pParticle.isElement()) {
      ObjectSG oSG = pParticle.getObjectSG();
      TypeSG childType = oSG.getTypeSG();
      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(uriCondition, "  &&  ", JavaSource.getQuoted(name.getLocalName()),
          ".equals(", getParamLocalName(), ")");
      JavaQName type;
      TypedValue v = getParamResult();
      if (childType.isComplex()) {
        type = childType.getComplexTypeSG().getClassContext().getXMLInterfaceName();
      } else {
        v = createSimpleTypeConversion(pJm, childType, v, oSG.getName().toString());
        type = null;
        if (isMixed) {
          LocalJavaField f = pJm.newJavaField(GroupUtil.getContentClass(group, pParticle, ctSG.getClassContext().getXMLInterfaceName()));
          f.addLine("new ", GroupUtil.getContentClass(group, pParticle, ctSG.getClassContext().getXMLImplementationName()), "()");
          pJm.addLine(f, ".setValue(", v, ");");
View Full Code Here

TOP

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

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.