Package org.apache.ws.jaxme.xs

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


      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


    }
  }

  public XSSimpleType getSimpleType() throws SAXException {
    validate();
    XSSimpleType result = simpleType;
    if (result == null) {
      throw new IllegalStateException("This is a complex type.");
    }
    return result;
  }
View Full Code Here

   */
  protected EnumerationSG(SimpleTypeSGChain o, JavaQName pName, XSType pType) throws SAXException {
    super(o);
    qName = pName;

    XSSimpleType simpleType = pType.getSimpleType();
    XSEnumeration[] enumerations = simpleType.getEnumerations();
    List enums = new ArrayList();
    for (int i = 0;  i < enumerations.length;  i++) {
      XSEnumeration en = enumerations[i];
      String name = null;
      String value = en.getValue();
View Full Code Here

  private SimpleTypeSGChain newSimpleTypeSG(TypeSG pController, SGFactory pFactory,
                                             SchemaSG pSchema, XSType pType) throws SAXException {
    if (!pType.isSimple()) {
      throw new IllegalStateException("Expected a simple type");
    }
    XSSimpleType simpleType = pType.getSimpleType();
    if (simpleType.isAtomic()) {
      if (pType.isGlobal()) {
        XsQName myName = pType.getName();
        if (myName.equals(XSEntity.getInstance().getName())      ||
            myName.equals(XSNotation.getInstance().getName())    ||
            myName.equals(XSGYearMonth.getInstance().getName())  ||
            myName.equals(XSGYear.getInstance().getName())       ||
            myName.equals(XSGMonthDay.getInstance().getName())   ||
            myName.equals(XSGMonth.getInstance().getName())      ||
            myName.equals(XSGDay.getInstance().getName())) {
          throw new SAXException("The type " + myName + " is not supported.");
        } else if (myName.equals(XSIDREF.getInstance().getName())) {
          return new IDREFSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSID.getInstance().getName())) {
          return new IDSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSByte.getInstance().getName())) {
          return new ByteSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSShort.getInstance().getName())) {
          return new ShortSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSInt.getInstance().getName())) {
          return new IntSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSLong.getInstance().getName())) {
          return new LongSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSUnsignedByte.getInstance().getName())  ||
                    myName.equals(XSUnsignedShort.getInstance().getName())) {
          return new UnsignedShortSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSUnsignedInt.getInstance().getName())) {
          return new UnsignedIntSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSInteger.getInstance().getName())             ||
                    myName.equals(XSNonPositiveInteger.getInstance().getName())  ||
                    myName.equals(XSNegativeInteger.getInstance().getName())     ||
                    myName.equals(XSUnsignedLong.getInstance().getName())        ||
                    myName.equals(XSPositiveInteger.getInstance().getName())     ||
                    myName.equals(XSNonNegativeInteger.getInstance().getName())) {
          return new IntegerSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDecimal.getInstance().getName())) {
          return new DecimalSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSQName.getInstance().getName())) {
          return new QNameSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDouble.getInstance().getName())) {
          return new DoubleSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSFloat.getInstance().getName())) {
          return new FloatSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSHexBinary.getInstance().getName())) {
          return new HexBinarySG(pFactory, pSchema, pType);
        } else if (myName.equals(XSBase64Binary.getInstance().getName())) {
          return new Base64BinarySG(pFactory, pSchema, pType);
        } else if (myName.equals(XSBoolean.getInstance().getName())) {
          return new BooleanSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDate.getInstance().getName())) {
          return new DateSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDateTime.getInstance().getName())) {
          return new DateTimeSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSTime.getInstance().getName())) {
          return new TimeSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDuration.getInstance().getName())) {
          return new DurationSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSAnySimpleType.getInstance().getName())     ||
                    myName.equals(XSString.getInstance().getName())            ||
                    myName.equals(XSAnyURI.getInstance().getName())            ||
                    myName.equals(XSNormalizedString.getInstance().getName())  ||
                    myName.equals(XSToken.getInstance().getName())             ||
                    myName.equals(XSLanguage.getInstance().getName())          ||
                    myName.equals(XSName.getInstance().getName())              ||
                    myName.equals(XSNMToken.getInstance().getName())           ||
                    myName.equals(XSNCName.getInstance().getName())) {
          return new StringSG(pFactory, pSchema, pType);
        }
      }

      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;
        String packageName = 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) {
                generateTypesafeEnumClass = true;
                break;
              }
            }
          }
        }

        if (!generateTypesafeEnumClass  &&  pType.isGlobal()) {
          XsQName[] qNames = new XsQName[]{XSNMToken.getInstance().getName()};
          XSSchema xsSchema = xsType.getXSSchema();
          if (xsSchema instanceof JAXBSchema) {
            JAXBSchema jaxbSchema = (JAXBSchema) xsSchema;
            JAXBGlobalBindings globalBindings = jaxbSchema.getJAXBGlobalBindings();
            if (globalBindings != null) {
              qNames = globalBindings.getTypesafeEnumBase();
            }
          }

          for (XSType restrType = xsType;  !generateTypesafeEnumClass;  ) {
            restrType = restrType.getSimpleType().getRestrictedType();
            if (restrType.isGlobal()) {
              for (int i = 0;  i < qNames.length;  i++) {
                if (qNames[i].equals(restrType.getName())) {
                  generateTypesafeEnumClass = true;
                  break;
                }
              }
              if (XSAnySimpleType.getInstance().getName().equals(restrType.getName())) {
                break;
              }
            }
          }
        }

        if (xsType instanceof JAXBType) {
          JAXBSchemaBindings jaxbSchemaBindings = ((JAXBType) xsType).getJAXBSchemaBindings();
          if (jaxbSchemaBindings != null) {
            JAXBSchemaBindings.Package jaxbPackage = jaxbSchemaBindings.getPackage();
            if (jaxbPackage != null) {
              packageName = jaxbPackage.getName();
            }
          }
        }
        if (packageName == null) {
          XsQName qName = pController.getName();
          packageName = AbstractContext.getPackageNameFromURI(pController.getLocator(), qName.getNamespaceURI());
        }

        if (generateTypesafeEnumClass) {
          if (className == null) {
            XsQName qName = pType.isGlobal() ? pType.getName() : pController.getName();
            className = AbstractContext.getClassNameFromLocalName(pController.getLocator(),
                                                                  qName.getLocalName(),
                                                                  pSchema) + "Class";
          }
          result = new EnumerationSG(result, JavaQNameImpl.getInstance(packageName, className), pType);
        }
      }

      return result;
    } else if (simpleType.isList()) {
      return new ListTypeSGImpl(pFactory, pSchema, pType, classContext, pController.getName());
    } else if (simpleType.isUnion()) {
      return new UnionTypeSGImpl(pFactory, pSchema, pType, classContext, pController.getName());
    } else {
      throw new IllegalStateException("Simple type " + pType + " is neither of atomic, list, or union");
    }
  }
View Full Code Here

  private SimpleTypeSGChain newSimpleTypeSG(TypeSG pController, SGFactory pFactory,
                                             SchemaSG pSchema, XSType pType) throws SAXException {
    if (!pType.isSimple()) {
      throw new IllegalStateException("Expected a simple type");
    }
    XSSimpleType simpleType = pType.getSimpleType();
    if (simpleType.isAtomic()) {
      if (pType.isGlobal()) {
        XsQName myName = pType.getName();
        if (myName.equals(XSEntity.getInstance().getName())      ||
            myName.equals(XSNotation.getInstance().getName())    ||
            myName.equals(XSGYearMonth.getInstance().getName())  ||
            myName.equals(XSGYear.getInstance().getName())       ||
            myName.equals(XSGMonthDay.getInstance().getName())   ||
            myName.equals(XSGMonth.getInstance().getName())      ||
            myName.equals(XSGDay.getInstance().getName())) {
          throw new SAXException("The type " + myName + " is not supported.");
        } else if (myName.equals(XSIDREF.getInstance().getName())) {
          return new IDREFSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSID.getInstance().getName())) {
          return new IDSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSByte.getInstance().getName())) {
          return new ByteSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSShort.getInstance().getName())) {
          return new ShortSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSInt.getInstance().getName())) {
          return new IntSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSLong.getInstance().getName())) {
          return new LongSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSUnsignedByte.getInstance().getName())  ||
                    myName.equals(XSUnsignedShort.getInstance().getName())) {
          return new UnsignedShortSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSUnsignedInt.getInstance().getName())) {
          return new UnsignedIntSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSInteger.getInstance().getName())             ||
                    myName.equals(XSNonPositiveInteger.getInstance().getName())  ||
                    myName.equals(XSNegativeInteger.getInstance().getName())     ||
                    myName.equals(XSUnsignedLong.getInstance().getName())        ||
                    myName.equals(XSPositiveInteger.getInstance().getName())     ||
                    myName.equals(XSNonNegativeInteger.getInstance().getName())) {
          return new IntegerSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDecimal.getInstance().getName())) {
          return new DecimalSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSQName.getInstance().getName())) {
          return new QNameSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDouble.getInstance().getName())) {
          return new DoubleSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSFloat.getInstance().getName())) {
          return new FloatSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSHexBinary.getInstance().getName())) {
          return new HexBinarySG(pFactory, pSchema, pType);
        } else if (myName.equals(XSBase64Binary.getInstance().getName())) {
          return new Base64BinarySG(pFactory, pSchema, pType);
        } else if (myName.equals(XSBoolean.getInstance().getName())) {
          return new BooleanSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDate.getInstance().getName())) {
          return new DateSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDateTime.getInstance().getName())) {
          return new DateTimeSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSTime.getInstance().getName())) {
          return new TimeSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDuration.getInstance().getName())) {
          return new DurationSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSAnySimpleType.getInstance().getName())     ||
                    myName.equals(XSString.getInstance().getName())            ||
                    myName.equals(XSAnyURI.getInstance().getName())            ||
                    myName.equals(XSNormalizedString.getInstance().getName())  ||
                    myName.equals(XSToken.getInstance().getName())             ||
                    myName.equals(XSLanguage.getInstance().getName())          ||
                    myName.equals(XSName.getInstance().getName())              ||
                    myName.equals(XSNMToken.getInstance().getName())           ||
                    myName.equals(XSNCName.getInstance().getName())) {
          return new StringSG(pFactory, pSchema, pType);
        }
      }

      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;
        String packageName = 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) {
                generateTypesafeEnumClass = true;
                break;
              }
            }
          }
        }

        if (!generateTypesafeEnumClass  &&  pType.isGlobal()) {
          XsQName[] qNames = new XsQName[]{XSNMToken.getInstance().getName()};
          XSSchema xsSchema = xsType.getXSSchema();
          if (xsSchema instanceof JAXBSchema) {
            JAXBSchema jaxbSchema = (JAXBSchema) xsSchema;
            JAXBGlobalBindings globalBindings = jaxbSchema.getJAXBGlobalBindings();
            if (globalBindings != null) {
              qNames = globalBindings.getTypesafeEnumBase();
            }
          }

          for (XSType restrType = xsType;  !generateTypesafeEnumClass;  ) {
            restrType = restrType.getSimpleType().getRestrictedType();
            if (restrType.isGlobal()) {
              for (int i = 0;  i < qNames.length;  i++) {
                if (qNames[i].equals(restrType.getName())) {
                  generateTypesafeEnumClass = true;
                  break;
                }
              }
              if (XSAnySimpleType.getInstance().getName().equals(restrType.getName())) {
                break;
              }
            }
          }
        }

        JAXBSchemaBindings jaxbSchemaBindings;
        if (xsType instanceof JAXBType) {
            jaxbSchemaBindings = ((JAXBType) xsType).getJAXBSchemaBindings();
        } else {
            jaxbSchemaBindings = null;
        }
        packageName = AbstractContext.getPackageName(pSchema, jaxbSchemaBindings,
                                   pController.getLocator(),
                                   pController.getName());

        if (generateTypesafeEnumClass) {
          if (className == null) {
            XsQName qName = pType.isGlobal() ? pType.getName() : pController.getName();
            className = AbstractContext.getClassNameFromLocalName(pController.getLocator(),
                                                                  qName.getLocalName(),
                                                                  pSchema) + "Class";
          }
          result = new EnumerationSG(result, JavaQNameImpl.getInstance(packageName, className), pType);
        }
      }

      return result;
    } else if (simpleType.isList()) {
      return new ListTypeSGImpl(pFactory, pSchema, pType, classContext, pController.getName());
    } else if (simpleType.isUnion()) {
      return new UnionTypeSGImpl(pFactory, pSchema, pType, classContext, pController.getName());
    } else {
      throw new IllegalStateException("Simple type " + pType + " is neither of atomic, list, or union");
    }
  }
View Full Code Here

    XSType[] types = schema.getTypes();
    assertEquals(3, types.length);
   
    XSType t1 = types[0];
    assertEquals(new XsQName((String) null, "a"), t1.getName());
    XSSimpleType st1 = assertSimpleType(t1);
    assertAtomicType(st1);
    XSType t1_1 = assertRestriction(st1);
    assertEquals(XSString.getInstance(), t1_1);
   
    XSType t2 = types[1];
    assertEquals(new XsQName((String) null, "b"), t2.getName());
    XSSimpleType st2 = assertSimpleType(t2);
    XSListType lt = assertListType(st2);
    XSType it = lt.getItemType();
    assertNotNull(it);
    assertEquals(XSInt.getInstance(), it);
    XSSimpleType it2 = assertSimpleType(it);
    assertAtomicType(it2);
   
    XSType t3 = types[2];
    assertEquals(new XsQName((String) null, "c"), t3.getName());
    XSSimpleType st3 = assertSimpleType(t3);
    XSUnionType ut3 = assertUnionType(st3);
    XSType[] memberTypes = ut3.getMemberTypes();
    assertEquals(2, memberTypes.length);
    XSType mt3_1 = memberTypes[0];
    assertEquals(mt3_1, t1);
View Full Code Here

    XSAttribute attr1 = (XSAttribute) attr[0];
    assertTrue(attr1.isGlobal());
    assertEquals(new XsQName((String) null, "a"), attr1.getName());
    XSType t1 = attr1.getType();
    assertEquals(XSString.getInstance(), t1);
    XSSimpleType st1 = assertSimpleType(attr1.getType());
    assertAtomicType(st1);

    XSAttribute attr2 = (XSAttribute) attr[1];
    assertTrue(attr2.isGlobal());
    assertEquals(new XsQName((String) null, "b"), attr2.getName());
    XSType t2 = attr2.getType();
    assertTrue(!XSInt.getInstance().equals(t2));
    XSType t2_1 = assertRestriction(assertSimpleType(t2));
    assertEquals(XSInt.getInstance(), t2_1);
    XSSimpleType st2 = assertSimpleType(t2);
    assertAtomicType(st2);

    XSAttribute attr3 = (XSAttribute) attr[2];
    assertTrue(attr3.isGlobal());
    assertEquals(new XsQName((String) null, "c"), attr3.getName());
    XSType t3 = attr3.getType();
    assertEquals(XSInt.getInstance(), t3);
    XSSimpleType st3 = assertSimpleType(t3);
    assertAtomicType(st3);
  }
View Full Code Here

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
    XSElement e1 = elements[0];
    assertEquals(new XsQName((String) null, "a"), e1.getName());
    XSSimpleType st1 = assertSimpleType(e1.getType());
    assertEquals(XSString.getInstance(), assertRestriction(st1));
    XSEnumeration[] enumerations = st1.getEnumerations();
    assertNotNull(enumerations);
    assertEquals(3, enumerations.length);
    assertEquals(3, enumerations.length);
    assertEquals("AK", enumerations[0].getValue());
    assertEquals("AL", enumerations[1].getValue());
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);
    // TODO: test restriction pattern

    // 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

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.