Package org.apache.ws.jaxme.xs

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


    return result;
  }

  protected XSSimpleType assertSimpleType(XSType pType) throws SAXException {
    assertTrue(pType.isSimple());
    XSSimpleType result = pType.getSimpleType();
    assertNotNull(result);
    boolean haveException = false;
    try {
      pType.getComplexType();
    } catch (IllegalStateException e) {
View Full Code Here


  private SimpleTypeSGChain newAtomicTypeRestriction(TypeSG pController,
                                                     SGFactory pFactory,
                                                     SchemaSG pSchema,
                                                     XSType pType)
      throws SAXException {
    XSSimpleType simpleType = pType.getSimpleType();
    SimpleTypeSGChain result = newSimpleTypeSG(pController, pFactory, pSchema, simpleType.getRestrictedType());
    result = new SimpleTypeRestrictionSG(result, pType, simpleType);
   
    if (simpleType.getEnumerations().length > 0) {
        boolean generateTypesafeEnumClass = false;
        String className = null;
       
        if (simpleType instanceof JAXBSimpleType) {
            JAXBSimpleType jaxbSimpleType = (JAXBSimpleType) simpleType;
            JAXBTypesafeEnumClass jaxbTypesafeEnumClass = jaxbSimpleType.getJAXBTypesafeEnumClass();
            if (jaxbTypesafeEnumClass != null) {
                generateTypesafeEnumClass = true;
                className = jaxbTypesafeEnumClass.getName();
            }
        }
       
        if (!generateTypesafeEnumClass) {
            XSEnumeration[] enumerations = simpleType.getEnumerations();
            for (int i = 0;  i < enumerations.length;  i++) {
                XSEnumeration enumeration = enumerations[i];
                if (enumeration instanceof JAXBEnumeration) {
                    JAXBEnumeration jaxbEnumeration = (JAXBEnumeration) enumeration;
                    if (jaxbEnumeration.getJAXBTypesafeEnumMember() != null) {
View Full Code Here

        for (int i = 0;  i < globalJavaTypes.length;  i++) {
            if (globalJavaTypes[i].getXmlType().equals(currentType.getName())) {
            return globalJavaTypes[i];
            }
        }
        XSSimpleType simpleType = currentType.getSimpleType();
        if (simpleType.isRestriction()) {
          currentType = simpleType.getRestrictedType();
        } else {
          currentType = null;
        }
    }
    return null;
View Full Code Here

    }

    JAXBJavaType javaType = findJavaType(pSchema, pType);
    SimpleTypeSGChain result;
    if (javaType == null  ||  javaType.getName() == null) {
        XSSimpleType simpleType = pType.getSimpleType();
        JavaQName runtimeType;
        if (simpleType.isAtomic()) {
          result = newGlobalAtomicTypeSG(pFactory, pSchema, pType);
            if (result == null) {
                if (!simpleType.isRestriction()) {
                    throw new SAXParseException("Atomic type must be either a builtin or a restriction of another atomic type",
                                                pType.getLocator());
                }
                TypeSG type = pSchema.getType(simpleType.getRestrictedType().getName());
                runtimeType = type.getSimpleTypeSG().getRuntimeType();
                result = newAtomicTypeRestriction(pController, pFactory, pSchema, pType);
            } else {
                SimpleTypeSG simpleTypeSG = new SimpleTypeSGImpl(result);
                simpleTypeSG.init();
              runtimeType = simpleTypeSG.getRuntimeType();
            }
            if (javaType == null) {
                JAXBJavaType[] globalJavaTypes = pSchema.getJAXBJavaTypes();
                for (int i = 0;  i < globalJavaTypes.length;  i++) {
                  if (runtimeType.equals(globalJavaTypes[i].getName())) {
                        javaType = globalJavaTypes[i];
                        break;
                    }
                }
            }
        } else if (simpleType.isList()) {
          result = new ListTypeSGImpl(pFactory, pSchema, pType, classContext, pController.getName());
        } else if (simpleType.isUnion()) {
            result = new UnionTypeSGImpl(pFactory, pSchema, pType, classContext, pController.getName());
        } else {
            throw new IllegalStateException("Simple type " + pType + " is neither of atomic, list, or union");
        }
    } else {
View Full Code Here

    XSParticle quantity = itemGroupParticles[1];
    assertEquals(1, quantity.getMinOccurs());
    assertEquals(1, quantity.getMaxOccurs());
    XSElement quantityElement = assertElement(quantity);
    assertEquals(new XsQName((String) null, "quantity"), quantityElement.getName());
    XSSimpleType quantitySimpleType = assertSimpleType(quantityElement.getType());
    assertEquals(XSPositiveInteger.getInstance(), assertRestriction(quantitySimpleType));

    // Items.item.USPrice
    // <xsd:element name='USPrice'  type='xsd:decimal'/>
    XSParticle usPrice = itemGroupParticles[2];
    assertEquals(1, usPrice.getMinOccurs());
    assertEquals(1, usPrice.getMaxOccurs());
    XSElement usPriceElement = assertElement(usPrice);
    assertEquals(new XsQName((String) null, "USPrice"), usPriceElement.getName());
    assertEquals(XSDecimal.getInstance(), usPriceElement.getType());

    // Items.item.comment
    // <xsd:element ref='comment'   minOccurs='0'/>
    XSParticle comment = itemGroupParticles[3];
    assertEquals(comment.getMinOccurs(), 0);
    assertEquals(comment.getMaxOccurs(), 1);
    XSElement commentElement = assertElement(comment);
    assertEquals(new XsQName((String) null, "comment"), commentElement.getName());
    assertEquals(XSString.getInstance(), commentElement.getType());

    // Items.item.shipDate
    // <xsd:element name='shipDate' type='xsd:date' minOccurs='0'/>
    XSParticle shipDate = itemGroupParticles[4];
    assertEquals(shipDate.getMinOccurs(), 0);
    assertEquals(shipDate.getMaxOccurs(), 1);
    XSElement shipDateElement = assertElement(shipDate);
    assertEquals(XSDate.getInstance(), shipDateElement.getType());

    // PurchaseOrderType
    XSType purchaseOrderType = schemaTypes[0];
    assertTrue(purchaseOrderType.isGlobal());
    assertEquals(new XsQName((String) null, "PurchaseOrderType"), purchaseOrderType.getName());
    XSComplexType purchaseOrderTypeComplexType = assertComplexType(purchaseOrderType);
    XSParticle purchaseOrderTypeParticle = assertComplexContent(purchaseOrderTypeComplexType);
    XSGroup purchaseOrderTypeGroup = assertGroup(purchaseOrderTypeParticle);
    assertSequence(purchaseOrderTypeGroup);

    XSAttributable[] potAttributes = purchaseOrderTypeComplexType.getAttributes();
    assertEquals(1, potAttributes.length);
    // PurchaseOrderType.orderDate
    // <xsd:attribute name='orderDate' type='xsd:date'/>
    XSAttribute orderDate = (XSAttribute) potAttributes[0];
    assertEquals(new XsQName((String) null, "orderDate"), orderDate.getName());
    assertEquals(XSDate.getInstance(), orderDate.getType());

    XSParticle[] potChildren = purchaseOrderTypeGroup.getParticles();
    assertEquals(4, potChildren.length);
    // PurchaseOrderType.shipTo
    // <xsd:element name='shipTo' type='USAddress'/>
    XSParticle shipTo = potChildren[0];
    assertEquals(1, shipTo.getMinOccurs());
    assertEquals(1, shipTo.getMaxOccurs());
    XSElement shipToElement = assertElement(shipTo);
    assertEquals(new XsQName((String) null, "shipTo"), shipToElement.getName());
    XSType shipToType = shipToElement.getType();
    assertTrue(shipToType.isGlobal());
    assertEquals(new XsQName((String) null, "USAddress"), shipToType.getName());
    // PurchaseOrderType.billTo
    // <xsd:element name='billTo' type='USAddress'/>
    XSParticle billTo = potChildren[1];
    assertEquals(1, billTo.getMinOccurs());
    assertEquals(1, billTo.getMaxOccurs());
    XSElement billToElement = assertElement(billTo);
    assertEquals(new XsQName((String) null, "billTo"), billToElement.getName());
    XSType billToType = billToElement.getType();
    assertEquals(shipToType, billToType);
    // PurchaseOrderType.comment
    // <xsd:element ref='comment' minOccurs='0'/>
    XSParticle potComment = potChildren[2];
    assertEquals(0, potComment.getMinOccurs());
    assertEquals(1, potComment.getMaxOccurs());
    XSElement potCommentElement = assertElement(potComment);
    assertEquals(new XsQName((String) null, "comment"), potCommentElement.getName());
    assertEquals(potCommentElement.getType(), commentElement.getType());
    // PurchaseOrderType.items
    // <xsd:element name='items'  type='Items'/>
    XSParticle potItems = potChildren[3];
    assertEquals(1, potItems.getMinOccurs());
    assertEquals(1, potItems.getMaxOccurs());
    XSElement potItemsElement = assertElement(potItems);
    assertEquals(new XsQName((String) null, "items"), potItemsElement.getName());
    assertEquals(items, potItemsElement.getType());

    // SKU
    XSType sku = schemaTypes[3];
    assertTrue(sku.isGlobal());
    assertEquals(new XsQName((String) null, "SKU"), sku.getName());
    XSSimpleType skuSimpleType = assertSimpleType(sku);
    assertEquals(XSString.getInstance(), assertRestriction(skuSimpleType));
    assertEquals(sku, partNumType);

    // USAddress
    // <xsd:complexType name='USAddress'>
View Full Code Here

      isource.setSystemId("testSimpleTypeRestriction.xsd");
      XSParser xsParser = newXSParser();
      XSSchema schema = xsParser.parse(isource);
      XSType[] types = schema.getTypes();
      assertEquals(1, types.length);
      XSSimpleType simpleType = assertSimpleType(types[0]);
      assertAtomicType(simpleType);
      XSEnumeration[] enumerations = simpleType.getEnumerations();
      assertEquals(2, enumerations.length);
      assertEquals("0", enumerations[0].getValue());
      assertEquals("2", enumerations[1].getValue());
  }
View Full Code Here

        XSSchema schema = pParser.parse(isource);
        XSType[] types = schema.getTypes();
        assertEquals(2, types.length);
        assertEquals(new XsQName("http://asi.sbc.com/cpsosasos/trouble/data", "NameTypeType"),
                     types[1].getName());
        XSSimpleType nameTypeType = assertSimpleType(types[1]);
        assertUnionType(nameTypeType);
        assertEquals(new XsQName("http://asi.sbc.com/cpsosasos/trouble/data", "ServiceIDType"),
                     types[0].getName());
        XSSimpleType serviceIDType = assertSimpleType(types[0]);
        assertUnionType(serviceIDType);
        assertTrue(serviceIDType.isRestriction());
    }
View Full Code Here

        XSSchema schema = parse(schemaSpec, "jira44.xsd");
        XSType[] types = schema.getTypes();
        assertEquals(3, types.length);
        XSType threeOrFourType = types[0];
        XSSimpleType threeOrFourSimpleType = assertSimpleType(threeOrFourType);
        XSType restrictedType = assertRestriction(threeOrFourSimpleType);
        XSEnumeration[] threeOrFourTypeEnums = threeOrFourSimpleType.getEnumerations();
        assertEquals(2, threeOrFourTypeEnums.length);
        assertEquals("3", threeOrFourTypeEnums[0].getValue());
        assertEquals("4", threeOrFourTypeEnums[1].getValue());
        assertEquals(XSString.getInstance(), restrictedType);
        XSType outerType1 = types[1];
View Full Code Here

    }
    XSObjectFactory factory = pParent.getXSSchema().getXSObjectFactory();
    if (myComplexType.isExtension()) {
      XSType extendedType = myComplexType.getSimpleContent().getType();
      extendedType.validate();
      XSSimpleType extendedSimpleType = extendedType.getSimpleType();
 
      XSSimpleType mySimpleType;
      if (extendedSimpleType.isAtomic()) {
        mySimpleType = factory.newXSAtomicType(this, extendedType, pRestriction);
      } else if (extendedSimpleType.isList()) {
        mySimpleType = factory.newXSListType(this, extendedType, pRestriction);
      } else if (extendedSimpleType.isUnion()) {
        mySimpleType = factory.newXSUnionType(this, extendedType, pRestriction);
      } else {
        throw new LocSAXException("Unknown restriction type: " + extendedType,
                              pRestriction.getLocator());
      }

      simpleType = mySimpleType;
      //was: setSimpleType( extendedType.getSimpleType() );
    } else {
      XsTLocalSimpleType localSimpleType = pRestriction.getSimpleType();
      XSType restrictedType;
      if (localSimpleType != null) {
        restrictedType = factory.newXSType(this, localSimpleType);
      } else {
        restrictedType = myComplexType.getSimpleContent().getType();
      }
      restrictedType.validate();
      XSSimpleType restrictedSimpleType = restrictedType.getSimpleType();
      if (restrictedSimpleType.isAtomic()) {
        simpleType = factory.newXSAtomicType(this, restrictedType, pRestriction);
      } else if (restrictedSimpleType.isList()) {
        simpleType = factory.newXSListType(this, restrictedType, pRestriction);
      } else if (restrictedSimpleType.isUnion()) {
        simpleType = factory.newXSUnionType(this, restrictedType, pRestriction);
      }
    }
    this.name = null;
    isSimple = true;
View Full Code Here

          result.validate();
          annotations = new XSAnnotation[]{result};
      }

      if (isSimple()) {
          XSSimpleType mySimpleType;
          Object baseObject = getXsObject();
          if (baseObject instanceof XsTSimpleType) {
              XsTSimpleType myXsTSimpleType = (XsTSimpleType) baseObject;
              XsEList list = myXsTSimpleType.getList();
              if (list == null) {
                  XsEUnion union = myXsTSimpleType.getUnion();
                  if (union == null) {
                      XsERestriction restriction = myXsTSimpleType.getRestriction();
                      if (restriction == null) {
                          throw new LocSAXException("Either of the 'list', 'union', or 'restriction' child elements must be set.",
                                  myXsTSimpleType.getLocator());
                      }
                      XsQName myName = restriction.getBase();
                      XSType restrictedType;         
                      if (myName == null) {
                          XsTLocalSimpleType baseType = restriction.getSimpleType();
                          if (baseType == null) {
                              throw new LocSAXException("Neither the 'base' attribute nor an inner 'simpleType' element are present",
                                      restriction.getLocator());
                          } else {
                              restrictedType = getXSSchema().getXSObjectFactory().newXSType(this, baseType);
                          }
                      } else {
                          restrictedType = getXSSchema().getType(myName);
                          if (restrictedType == null) {
                              throw new LocSAXException("Unknown base type: " + myName,
                                      restriction.getLocator());
                          }
                      }
                      restrictedType.validate();
                      if (!restrictedType.isSimple()) {
                          throw new LocSAXException("The restricted type " + myName + " is complex.",
                                  restriction.getLocator());
                      }
                      XSSimpleType baseType = restrictedType.getSimpleType();
                      if (baseType.isAtomic()) {
                          mySimpleType = getXSSchema().getXSObjectFactory().newXSAtomicType(this, restrictedType, restriction);
                      } else if (baseType.isList()) {
                          mySimpleType = getXSSchema().getXSObjectFactory().newXSListType(this, restrictedType, restriction);
                      } else if (baseType.isUnion()) {
                          mySimpleType = getXSSchema().getXSObjectFactory().newXSUnionType(this, restrictedType, restriction);
                      } else {
                          throw new LocSAXException("Unknown restriction type: " + baseType, restriction.getLocator());
                      }
                  } else {
View Full Code Here

TOP

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

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.