Package org.exolab.castor.xml.schema

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


         }
                 _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


    public static XSType convertType(SimpleType simpleType, boolean useWrapper, String packageName) {
        if (simpleType == null) return null;

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

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

        if (simpleType.getStructureType() == Structure.UNION) {
            SimpleType common = findCommonType((Union)simpleType);
            if (common == null) {
                return new XSClass(SGTypes.Object);
            }
            return convertType(common, useWrapper,packageName);
        }
View Full Code Here

                }
            }

            //--5b the type is a simpleType
            else if (type.isSimpleType()) {
                SimpleType simpleType = (SimpleType)type;
                //-- handle our special case for enumerated types
                if (simpleType.hasFacet(Facet.ENUMERATION)) {
            //-- Don't create source code for simple types that
            //-- don't belong in the elements target namespace
            String tns = simpleType.getSchema().getTargetNamespace();
            boolean create = false;
            if (tns == null)
                create = (component.getTargetNamespace() == null);
            else
                        create = tns.equals(component.getTargetNamespace());
                    if (create) {
              JClass tmpClass = createSourceCode(simpleType, sgState);
              classInfo.setSchemaType(new XSClass(tmpClass));
            }
                } else {
                    //////////////////////////////////////////////////////////
                    //NOTE: generate sources if the flag for generating sources
                    //from imported schemas in on
                    //////////////////////////////////////////////////////////
                    return new JClass[0];
                }
            }
            //--5c the type is an anyType
            else if (type.isAnyType()) {
                //-- Do not create classes for AnyType
                classInfo.setSchemaType(new XSClass(SGTypes.Object));
                return new JClass[0];
            }
        }
        //--no type we must be facing an XML schema group
        else {
            //--MODEL GROUP OR GROUP
            try{
                createForGroup = true;
                Group group = (Group)component.getAnnotated();
                processContentModel(group, state);
                component.setView(group);
                //-- Check Group Type
                Order order = group.getOrder();
                if (order == Order.choice)
                    classInfo.getGroupInfo().setAsChoice();
                else if (order == Order.seq)
                    classInfo.getGroupInfo().setAsSequence();
                else
                    classInfo.getGroupInfo().setAsAll();
            } catch (ClassCastException ce) {
                //--Should not happen
                throw new IllegalArgumentException("Illegal binding component:"+ce.getMessage());
            }
        }

        //6--createGroupItem
        if (createGroupItem) {
        //-- create Bound Properties code
        if (component.hasBoundProperties())
            createPropertyChangeMethods(jClass);

            sgState.bindReference(jClass, classInfo);

            classes[1] = jClass;

            //-- create main group class
            String fname = component.getJavaClassName() + ITEM_NAME;
            fname  = JavaNaming.toJavaMemberName(fname, false);

            FieldInfo fInfo = null;
            if (createForGroup) {
                //A choice Item can occur only once in the nested group
                fInfo = infoFactory.createFieldInfo(new XSClass(jClass),
                                                                fname);
            } else {
                fInfo = infoFactory.createCollection(new XSClass(jClass),
                                                            "_items", fname);
            }
            fInfo.setContainer(true);
            className = className.substring(0,className.length()-4);
            state     = new FactoryState(className, sgState, packageName);
        classInfo = state.classInfo;
            jClass    = state.jClass;
        initialize(jClass);
            if (type != null && type.isComplexType()) {
               
                ComplexType complexType = (ComplexType)type;
                if (complexType.isTopLevel() ^ creatingForAnElement) {
                    //process attributes and content type
                    //since it has not be performed before
                    Annotated saved = component.getAnnotated();
                    processAttributes(complexType, state);
                    component.setView(saved);
                    if (complexType.getContentType() == ContentType.mixed) {
                        FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(new XSString());
                        handleField(fieldInfo, state);
                    }
                    else if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                        SimpleContent simpleContent = (SimpleContent)complexType.getContentType();
                        SimpleType temp = simpleContent.getSimpleType();
                        XSType xsType = TypeConversion.convertType(temp, packageName);
                        FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(xsType);
                    handleField(fieldInfo,state);
                    temp = null;
                    }
View Full Code Here

            } //--complexType

            //--if the content type is a simpleType create a field info for it.
            if (complexType.getContentType().getType() == ContentType.SIMPLE) {
                SimpleContent simpleContent = (SimpleContent)complexType.getContentType();
                SimpleType temp = simpleContent.getSimpleType();
                XSType xsType = TypeConversion.convertType(temp, state.packageName);
                FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(xsType);
            handleField(fieldInfo,state);
            }
    }//--base not null
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.