Package org.apache.ws.jaxme.xs

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


        }
        XsQName base = restriction.getBase();
        if (base == null) {
          throw new LocSAXException("Invalid 'restriction': Missing 'base' attribute", getLocator());
        }
        XSType type = getXSSchema().getType(base);
        if (type == null) {
          throw new LocSAXException("Invalid 'restriction': Unknown base type " + base, getLocator());
        }
        if (type.isSimple()) {
          throw new LocSAXException("Invalid 'restriction': The base type " + getName() + " is simple.", getLocator());
        }
        XsTTypeDefParticle particle = restriction.getTypeDefParticle();

        XSGroup group = getGroupByParticle(particle);
        if (group == null) {
          // TODO: Restriction of the ur-type
          complexContentParticle = null;
        } else {
          complexContentParticle = new XSParticleImpl(group);
        }
        complexContentType = getContentTypeByParticle(particle, group);
        attributes = XSAttributeGroupImpl.getAttributes(XSTypeImpl.this, restriction);
        restrictedType = type;
      } else {
        XsQName base = extension.getBase();
        if (base == null) {
          throw new LocSAXException("Invalid 'extension': Missing 'base' attribute", getLocator());
        }
        XSType type = getXSSchema().getType(base);
        if (type == null) {
          throw new LocSAXException("Invalid 'extension': Unknown base type " + base, getLocator());
        }
        if (type.isSimple()) {
          throw new LocSAXException("Invalid 'extension': The base type " + base + " is simple.", getLocator());
        }
        XSComplexType myComplexType = type.getComplexType();
        if (myComplexType.hasSimpleContent()) {
          throw new LocSAXException("Invalid 'extension': The base type " + base + " has simple content.",
                                       getLocator());
        }
        XsTTypeDefParticle particle = extension.getTypeDefParticle();
View Full Code Here


    return result;
  }

  protected XSType assertRestriction(XSSimpleType pType) throws SAXException {
    assertTrue(pType.isRestriction());
    XSType result = pType.getRestrictedType();
    assertNotNull(result);
    assertSimpleType(result);
    return result;
  }
View Full Code Here

  protected XSSimpleContentType assertSimpleContent(XSComplexType pType) {
    assertTrue(pType.hasSimpleContent());
    XSSimpleContentType result = pType.getSimpleContent();
    assertNotNull(result);
    XSType resultType = result.getType();
    assertNotNull(resultType);
    assertTrue(resultType.isSimple());
    boolean haveException = false;
    try {
      pType.getComplexContentType();
    } catch (IllegalStateException e) {
      haveException = true;
View Full Code Here

    JAXBParser parser = newJAXBParser();
    InputSource isource = new InputSource(new StringReader(schemaSource));
    isource.setSystemId("testJAXBProperty1.xsd");
    JAXBSchema schema = (JAXBSchema) parser.parse(isource);
    XSType type = schema.getType(new XsQName((String) null, "ct"));
    XSComplexType complexType = assertComplexType(type);
    XSAttributable[] attributes = complexType.getAttributes();
    assertNotNull(attributes);
    assertEquals(1, attributes.length);
    JAXBAttribute a1 = (JAXBAttribute) attributes[0];
View Full Code Here

    JAXBSchema schema = (JAXBSchema) parser.parse(isource);
    XSAttributable[] outerAttr = schema.getAttributes();
    assertEquals(1, outerAttr.length);
    JAXBAttribute outerA = (JAXBAttribute) outerAttr[0];
   
    XSType ct = schema.getType(new XsQName((String) null, "ct"));
    XSAttributable[] attributes = assertComplexType(ct).getAttributes();
    assertNotNull(attributes);
    assertEquals(1, attributes.length);
    JAXBAttribute a1 = (JAXBAttribute) attributes[0];
    assertEquals(XSDateTime.getInstance(), a1.getType());
View Full Code Here

    JAXBParser parser = newJAXBParser();
    InputSource isource = new InputSource(new StringReader(schemaSource));
    isource.setSystemId("testJAXBJavaType1.xsd");
    JAXBSchema schema = (JAXBSchema) parser.parse(isource);
    XSType a = schema.getType(new XsQName((String) null, "a"));
    JAXBSimpleType ast = (JAXBSimpleType) assertSimpleType(a);
    JAXBJavaType ajjt = ast.getJAXBJavaType();
    assertEquals("java.math.BigDecimal", ajjt.getName());
    assertEquals("javax.xml.bind.DatatypeConverter.parseInteger", ajjt.getParseMethod());
    assertEquals("javax.xml.bind.DatatypeConverter.printInteger", ajjt.getPrintMethod());
    assertTrue(!ajjt.hasNsContext());

    XSElement b = schema.getElement(new XsQName((String) null, "b"));
    XSType bt = b.getType();
    JAXBSimpleType bst = (JAXBSimpleType) assertSimpleType(bt);
    assertEquals(a, assertRestriction(bst));
    assertNull(bst.getJAXBJavaType());

    XSElement c = schema.getElement(new XsQName((String) null, "c"));
    XSType ct = c.getType();
    JAXBSimpleType cst = (JAXBSimpleType) assertSimpleType(ct);
    assertEquals(a, assertRestriction(cst));
    JAXBJavaType cjjt = cst.getJAXBJavaType();
    assertEquals("java.math.BigInteger", cjjt.getName());
    assertEquals("javax.xml.bind.DatatypeConverter.parseInt", cjjt.getParseMethod());
View Full Code Here

    JAXBParser parser = newJAXBParser();
    InputSource isource = new InputSource(new StringReader(schemaSource));
    isource.setSystemId("testJAXBJavaTypesafeEnumClass1.xsd");
    JAXBSchema schema = (JAXBSchema) parser.parse(isource);
    XSType a = schema.getType(new XsQName((String) null, "a"));
    checkJAXBTypesafeEnumClass1AType(a);

    XSType b = schema.getType(new XsQName((String) null, "b"));
    checkJAXBTypesafeEnumClass1BType(b);

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
    XSElement allTypesElement = elements[0];
View Full Code Here

    XSType[] types = schema.getTypes();
    assertEquals(7, types.length);


    XSType stringType = types[0];
    checkJAXBTypesafeEnumClass2StringType(stringType);

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
View Full Code Here

    XsQName myName = pRestriction.getBase();
    if (myName == null) {
      throw new LocSAXException("Invalid 'restriction': Missing 'base' attribute.",
                                   pRestriction.getLocator());
    }
    XSType type = getXSSchema().getType(myName);
    if (type == null) {
      throw new LocSAXException("Invalid 'restriction': Unknown 'base' type " + myName,
                                   pRestriction.getLocator());
    }
    type.validate();
    if (type.isSimple()) {
      throw new LocSAXException("The 'base' type " + myName + " of 'simpleContent/restriction' is simple." +
                                   " It ought to be a complex type with simple content: ",
                                   pRestriction.getLocator());
    }
    XSComplexType myComplexType = type.getComplexType();
    if (!myComplexType.hasSimpleContent()) {
      throw new LocSAXException("The 'base' type " + myName + " of 'simpleContent/restriction' is complex," +
                                   " but doesn't have simple content: ", pRestriction.getLocator());
    }
    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()) {
View Full Code Here

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

TOP

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

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.