Package org.exolab.castor.builder.binding

Examples of org.exolab.castor.builder.binding.XMLBindingComponent


        String className   = JavaNaming.toJavaClassName(typeName);
       
        //--XMLBindingComponent is only used to retrieve the java package
        //-- we need to optimize it by enabling the binding of simpleTypes.
        XMLBindingComponent comp = new XMLBindingComponent(_config);
        if (_binding != null) {
            comp.setBinding(_binding);
        }
        comp.setView(simpleType);
        String packageName = comp.getJavaPackage();
        if ((packageName == null) || (packageName.length() == 0)) {
            packageName = sgState.packageName;
        }

        if (simpleType.hasFacet(Facet.ENUMERATION)) {
View Full Code Here


        if (complexType == null)
            return;

        Enumeration enumeration = complexType.getAttributeDecls();
        XMLBindingComponent component = new XMLBindingComponent(_config);
        if (_binding != null) component.setBinding(_binding);
        while (enumeration.hasMoreElements()) {
            AttributeDecl attr = (AttributeDecl)enumeration.nextElement();
           
            component.setView(attr);
    
            //-- if we have a new SimpleType...generate ClassInfo
            SimpleType sType = attr.getSimpleType();
            if (sType != null) {
                if ( ! (SimpleTypesFactory.isBuiltInType(sType.getTypeCode())) )
               
                if (sType.getSchema() == component.getSchema())
                {
                    if (state.resolve(sType) == null) {   
                        if (sType.hasFacet(Facet.ENUMERATION)) {
                            createSourceCode(sType, state.getSGStateInfo());
                        }
View Full Code Here

     * @param state the FactoryState.
    **/
    private void processComplexType
        (ComplexType complexType, FactoryState state)
    {
        XMLBindingComponent component = new XMLBindingComponent(_config);
        if (_binding != null) component.setBinding(_binding);
        component.setView(complexType);
       
        String typeName = component.getXMLName();

        ClassInfo classInfo = state.classInfo;
        classInfo.setSchemaType(new XSClass(state.jClass, typeName));

        /// I don't believe this should be here: kv 20030423
        ///classInfo.setNamespaceURI(component.getTargetNamespace());

        //- Handle derived types
        XMLType base = complexType.getBaseType();

        //-- if the base is a complexType, we need to process it
    if (base != null) {
            if (base.isComplexType()) {
                String baseClassName = null;
               
                component.setView(base);                       
                //-- Is this base type from the schema we are currently generating source for?
          //////////////////////////////////////////////////////////
                //NOTE: generate sources if the flag for generating sources
                //from imported schemas in on
                //////////////////////////////////////////////////////////
                if (base.getSchema() == complexType.getSchema()) {
                    ClassInfo cInfo = state.resolve(base);
            //--no classInfo yet so no source code available
                    //--for the base type: we need to generate it
                    if (cInfo == null) {
                        JClass[] classes = createSourceCode(component, state.getSGStateInfo());
              cInfo = state.resolve(base);
              baseClassName = classes[0].getName();
            } else {
                        baseClassName = cInfo.getJClass().getName();
                    }
                    //set the base class
                    classInfo.setBaseClass(cInfo);
                } else {
            //-- Create qualified class name for a base type class
                    //-- from another package
            baseClassName = component.getQualifiedName();
           }
          //-- Set super class
                //-- and reset the view on the current ComplexType
        component.setView(complexType);
                //--only set a super class name if the current complexType
                //--is not a restriction of a simpleContent (--> no object hierarchy, only content hierarchy)
                if (! ( complexType.isRestricted() && ((ComplexType)base).isSimpleContent() ) )
                    state.jClass.setSuperClass(baseClassName);
            } //--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
   


       //---------------------/
        //- handle attributes -/
        //- and mixed content -/
        //---------------------/
        if (!state.isCreateGroupItem()) {
            processAttributes(complexType, state);
            //--reset the view on the current ComplexType
            component.setView(complexType);
            if (complexType.getContentType() == ContentType.mixed) {
                FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(new XSString());
                handleField(fieldInfo, state);
            }
        }
View Full Code Here

        //------------------------------/

        Enumeration enumeration = contentModel.enumerate();

        FieldInfo fieldInfo = null;
        XMLBindingComponent component = new XMLBindingComponent(_config);
        if (_binding != null) component.setBinding(_binding);
       
        while (enumeration.hasMoreElements()) {

            Annotated annotated = (Annotated)enumeration.nextElement();
            component.setView(annotated);

            switch(annotated.getStructureType()) {

                //-- handle element declarations
                case Structure.ELEMENT:
View Full Code Here

            }//--AnyType
            else if (xmlType.isComplexType() && (xmlType.getName() != null)) {
                //--if we use the type method then no class is output for
                //--the element we are processing
                if (_config.mappingSchemaType2Java()) {
                    XMLBindingComponent temp = new XMLBindingComponent(_config);
                    temp.setBinding(component.getBinding());
                    temp.setView(xmlType);
                    String className = temp.getQualifiedName();
                    if (className != null) {
                      xsType = new XSClass(new JClass(className));
                        className = null;
                    }
                }
View Full Code Here

        _sourceFactory = new SourceFactory(this, _infoFactory);
        _descSourceFactory = new DescriptorSourceFactory(this);
       
        _header = new JComment(JComment.HEADER_STYLE);
        _header.appendComment(DEFAULT_HEADER);
        _bindingComponent = new XMLBindingComponent(this);
        //--set the binding
        setBinding(binding);

    } //-- SourceGenerator
View Full Code Here

                ComplexType complexType = (ComplexType)type;
                if (complexType.isTopLevel() && creatingForAnElement) {
                     //--move the view and keep the structure
                     Annotated saved = component.getAnnotated();
                     String previousPackage = component.getJavaPackage();
                     XMLBindingComponent baseComponent = new XMLBindingComponent();
                     baseComponent.setBinding(component.getBinding());
                     baseComponent.setView(complexType);
                     String baseClassName = null;
                     String basePackage = baseComponent.getJavaPackage();
                     //--if the base class is not in the same package
                     //--of the current class then we have to qualify the base
                     //--class
                     if (basePackage != null && !basePackage.equals(previousPackage)) {
                         baseClassName = baseComponent.getQualifiedName();
                         if (baseClassName.indexOf('.') == -1) {
                             //--be sure it is a valid className
                             baseClassName = JavaNaming.toJavaClassName(baseClassName);
                         }
                     } else {
                         baseClassName = baseComponent.getJavaClassName();
                     }
                     jClass.setSuperClass(baseClassName);
                     basePackage = null;
                     baseClassName = null;
                     component.setView(saved);
View Full Code Here

            typeName += "Type";
        }

        String className   = JavaNaming.toJavaClassName(typeName);
       
        XMLBindingComponent comp = new XMLBindingComponent();
        if (_binding != null) {
            comp.setBinding(_binding);
        }
        comp.setView(simpleType);
        String packageName = comp.getJavaPackage();
        if ((packageName == null) || (packageName.length() == 0)) {
            packageName = sgState.packageName;
        }

        if (simpleType.hasFacet(Facet.ENUMERATION)) {
View Full Code Here

     * @param state the FactoryState.
    **/
    private void processComplexType
        (ComplexType complexType, FactoryState state)
    {
        XMLBindingComponent component = new XMLBindingComponent();
        if (_binding != null) component.setBinding(_binding);
        component.setView(complexType);
       
        String typeName = component.getXMLName();

        ClassInfo classInfo = state.classInfo;
        classInfo.setSchemaType(new XSClass(state.jClass, typeName));

        /// I don't believe this should be here: kv 20030423
        ///classInfo.setNamespaceURI(component.getTargetNamespace());

        //- Handle derived types
        XMLType base = complexType.getBaseType();

        //-- if the base is a complexType, we need to process it
    if (base != null) {
            if (base.isComplexType()) {
                String baseClassName = null;
               
                component.setView(base);                       
                //-- Is this base type from the schema we are currently generating source for?
          //////////////////////////////////////////////////////////
                //NOTE: generate sources if the flag for generating sources
                //from imported schemas in on
                //////////////////////////////////////////////////////////
                if (base.getSchema() == complexType.getSchema()) {
                    ClassInfo cInfo = state.resolve(base);
            //--no classInfo yet so no source code available
                    //--for the base type: we need to generate it
                    if (cInfo == null) {
                        JClass[] classes = createSourceCode(component, state.getSGStateInfo());
              cInfo = state.resolve(base);
              baseClassName = classes[0].getName();
            } else {
                        baseClassName = cInfo.getJClass().getName();
                    }
                    //set the base class
                    classInfo.setBaseClass(cInfo);
                } else {
            //-- Create qualified class name for a base type class
                    //-- from another package
            baseClassName = component.getQualifiedName();
           }
          //-- Set super class
                //-- and reset the view on the current ComplexType
        component.setView(complexType);
                //--only set a super class name if the current complexType
                //--is not a restriction of a simpleContent (--> no object hierarchy, only content hierarchy)
                if (!(complexType.isSimpleContent() && ((ComplexType)base).isRestricted()) )
                    state.jClass.setSuperClass(baseClassName);
            } //--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
   


       //---------------------/
        //- handle attributes -/
        //- and mixed content -/
        //---------------------/
        if (!state.isCreateGroupItem()) {
            processAttributes(complexType, state);
            //--reset the view on the current ComplexType
            component.setView(complexType);
            if (complexType.getContentType() == ContentType.mixed) {
                FieldInfo fieldInfo = memberFactory.createFieldInfoForContent(new XSString());
                handleField(fieldInfo, state);
            }
        }
View Full Code Here

            }//--AnyType
            else if (xmlType.isComplexType() && (xmlType.getName() != null)) {
                //--if we use the type method then no class is output for
                //--the element we are processing
                if (SourceGenerator.mappingSchemaType2Java()) {
                    XMLBindingComponent temp = new XMLBindingComponent();
                    temp.setBinding(component.getBinding());
                    temp.setView(xmlType);
                    String className = temp.getQualifiedName();
                    if (className != null) {
                      xsType = new XSClass(new JClass(className));
                        className = null;
                    }
                }
View Full Code Here

TOP

Related Classes of org.exolab.castor.builder.binding.XMLBindingComponent

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.