Package org.apache.ws.jaxme.xs

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


      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

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

        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

    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

    XSElement stringTypeElement = assertElement(allSimpleTypesElementChilds[0]);
    checkJAXBTypesafeEnumClass2StringType(stringTypeElement.getType());
  }

  private void checkJAXBTypesafeEnumClass2StringType(XSType pType) throws SAXException {
    XSSimpleType stStringType = assertSimpleType(pType);
    assertEquals(XSString.getInstance(), assertRestriction(stStringType));
    assertTrue(stStringType instanceof JAXBSimpleType);
    JAXBSimpleType jaxbStringType = (JAXBSimpleType) stStringType;
    JAXBTypesafeEnumClass typesafeEnumClass = jaxbStringType.getJAXBTypesafeEnumClass();
    assertNotNull(typesafeEnumClass);
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

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.