Package org.exolab.castor.xml.schema

Examples of org.exolab.castor.xml.schema.SimpleType


                                                 throws DTDException {

       AttributeDecl schemaAttribute = new AttributeDecl(schema,
                                                         dtdAttribute.getName());

       SimpleType type = null;

       if (dtdAttribute.isStringType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.STRING_TYPE) );
       }
       else if (dtdAttribute.isIDType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ID_TYPE) );
       }
       else if (dtdAttribute.isIDREFType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.IDREF_TYPE) );
       }
       else if (dtdAttribute.isIDREFSType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.IDREFS_TYPE) );
       }
       else if (dtdAttribute.isENTITYType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ENTITY_TYPE) );
       }
      
       else if (dtdAttribute.isENTITIESType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.ENTITIES_TYPE) );
       }
       else if (dtdAttribute.isNMTOKENType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKEN_TYPE) );
       }
       else if (dtdAttribute.isNMTOKENSType())
       {
           type = schema.getSimpleType( schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKENS_TYPE) );
       }
       else if (dtdAttribute.isNOTATIONType())
       {
          type = schema.createSimpleType(null,
                            schema.getBuiltInTypeName(SimpleTypesFactory.NOTATION_TYPE),
                                                                        "restriction");
           Iterator values = dtdAttribute.getValues();
           FacetFactory facetFactory = FacetFactory.getInstance();
           while (values.hasNext()) {
            Facet facet = facetFactory.createFacet(
                       Facet.ENUMERATION, (String) values.next());
            facet.setOwningType(type);
            type.addFacet(facet);
           }

       }
       else if (dtdAttribute.isEnumerationType())
       {
          type = schema.createSimpleType(null,
                            schema.getBuiltInTypeName(SimpleTypesFactory.NMTOKEN_TYPE),
                                                                        "restriction");
          Iterator values = dtdAttribute.getValues();
          FacetFactory facetFactory = FacetFactory.getInstance();
          while (values.hasNext()) {
            Facet facet = facetFactory.createFacet(
                     Facet.ENUMERATION, (String)values.next());
            facet.setOwningType(type);
            type.addFacet(facet);
          }
       }
       else
       {
          String err = "DTD to Schema converter: DTD attribute \"" + dtdAttribute.getName();
View Full Code Here


     *
     * @return the simpleType for the items of this ListType.
     */
    public SimpleType getItemType() {
        if (_hasReference) {
            SimpleType simpleType = resolveReference(_itemType);
            if (simpleType == null) {
                String err = "Unable to resolve type: " + _itemType.getName();
                throw new IllegalStateException(err);
            }
            _hasReference = false;
View Full Code Here

        if (SchemaNames.ANNOTATION.equals(name)) {
            _union.setLocalAnnotation((Annotation)_unmarshaller.getObject());
        }
        else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
           
            SimpleType simpleType =
                (SimpleType)_unmarshaller.getObject();
               
            //-- make sure type is not another Union
            if (simpleType instanceof Union) {
                String err = "A 'union' may only contain SimpleTypes of "+
View Full Code Here

            return;
           
        StringTokenizer st = new StringTokenizer(memberTypes);
        while (st.hasMoreTokens()) {
            String typeName = st.nextToken();
            SimpleType simpleType = _schema.getSimpleType(typeName);
            if (simpleType != null) {
                _union.addMemberType(simpleType);
            }
            else {
                _union.addMemberType(typeName);
View Full Code Here

         _complexType.setBase(base);
                 _complexType.setBaseType(baseType);
                if (_complexType.isSimpleContent()) {
                    //--set the content type
                    if (baseType.isSimpleType()) {
                        SimpleType simpleType = (SimpleType)baseType;
                      _complexType.setContentType(new SimpleContent(simpleType));
                    }
                    else {
                        ComplexType temp = (ComplexType)baseType;
                        SimpleContent simpleContent = (SimpleContent) temp.getContentType();
View Full Code Here

            return null;
        }

        XSType xsType = null;
        //-- determine base type
        SimpleType base = simpleType;

        while ((base != null) && (!base.isBuiltInType())) {
            base = (SimpleType) base.getBaseType();
        }

        // try to find a common type for UNIONs, and use it; if not,
        // use 'java.lang.Object' instead.
        if (simpleType.getStructureType() == Structure.UNION) {
            return convertUnion(simpleType, packageName, useWrapper, useJava50);
        } else if (base == null) {
            String className = _config.getJavaNaming().toJavaClassName(simpleType.getName());
            return new XSClass(new JClass(className));
        }

        xsType = findXSTypeForEnumeration(simpleType, packageName, javaClassBindingName);
        if (xsType != null) {
            return xsType;
        }

        // If we don't have the XSType yet, we have to look at the Type Code

        switch (base.getTypeCode()) {
            case SimpleTypesFactory.ID_TYPE:             //-- ID
                return new XSId();
            case SimpleTypesFactory.IDREF_TYPE:          //-- IDREF
                return new XSIdRef();
            case SimpleTypesFactory.IDREFS_TYPE:         //-- IDREFS
View Full Code Here

     */
    private XSType convertUnion(final SimpleType simpleType,
            final String packageName,
            final boolean useWrapper,
            final boolean useJava50) {
        SimpleType currentUnion = simpleType;
        SimpleType common = findCommonType((Union) currentUnion);
        // look at type hierarchy (if any), and try to
        // find a common type recursively
        while (common == null
                && currentUnion.getBaseType() != null
                && currentUnion.getBaseType().getStructureType() == Structure.UNION)
        {
            currentUnion = (SimpleType) currentUnion.getBaseType();
            common = findCommonType((Union) currentUnion);
        }
        if (common == null) {
            return new XSClass(SGTypes.OBJECT);
        }
       
        XSType convertedType = convertType(common, packageName, useWrapper, useJava50, null);
        Union unionType = (Union) simpleType;
        Enumeration<SimpleType> memberTypes = unionType.getMemberTypes();
        while (memberTypes.hasMoreElements()) {
            SimpleType memberType = memberTypes.nextElement();
            convertedType.setFacets(memberType);
        }
        return convertedType;
    }
View Full Code Here

     * @param union
     *            the Union to return the common type for
     * @return the common SimpleType for the Union.
     */
    private static SimpleType findCommonType(final Union union) {
        SimpleType common = null;
        Enumeration<SimpleType> enumeration = union.getMemberTypes();
        while (enumeration.hasMoreElements()) {
            SimpleType type = enumeration.nextElement();
            type = type.getBuiltInBaseType();
            if (common == null) {
                common = type;
            } else {
                common = findCommonType(common, type);
                //-- no common types
View Full Code Here

        if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = ((AnnotationUnmarshaller)unmarshaller).getAnnotation();
            _typeDefinition.setAnnotation(ann);
        }
        else if (SchemaNames.SIMPLE_TYPE.equals(name)) {
            SimpleType type = (SimpleType) unmarshaller.getObject();
            _typeDefinition.setBaseType(type);
        }
        else {
            Facet facet = (Facet) unmarshaller.getObject();
            facet.setOwningType((SimpleType) _typeDefinition.getBaseType());
View Full Code Here

        if (_redefineSchema.getSchemaLocation() == "") {
          String err = "In a <redefine>, only annotations can be defined when no -schemaLocation- is specified.";
          error(err);
        }
       
        SimpleType simpleType = null;
        simpleType = ((SimpleTypeUnmarshaller)_unmarshaller).getSimpleType();
            //-- Checks that the simpleType exists in the imported schema
        String structureName = simpleType.getName();
        if (structureName == null) {
          String err = "When redefining a simpleType, the simpleType must have a name.\n";
          error(err);
        }
       
        //1-- the simpleType must exist in the imported schema
        SimpleType original = _importedSchema.getSimpleType(structureName,_schema.getTargetNamespace() );
        if (original == null) {
          String err = "When redefining a simpleType, the simpleType must be present in the imported XML schema.\n"
            +"SimpleType: "+structureName+" is not defined in XML Schema:" + _importedSchema.getSchemaLocation();
          error(err);
        }
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.schema.SimpleType

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.