Package org.jibx.binding.model

Examples of org.jibx.binding.model.StructureElement


               
            }
        } else {
           
            // must be a structure, check children
            StructureElement struct = (StructureElement)comp;
            if (struct.children().size() > 0) {
               
                // structure with children, choice or sequence from order
                ComplexTypeElement type = new ComplexTypeElement();
                if (struct.isOrdered()) {
                   
                    // ordered children go to sequence element
                    SequenceElement seq = new SequenceElement();
                    type.setContentDefinition(seq);
                   
                } else {
                   
                    // unordered children go to repeated choice element
                    ChoiceElement choice = new ChoiceElement();
                    type.setContentDefinition(choice);
                }
                type.setContentDefinition(buildCompositor(struct, 0, false, hold));
                fillAttributes(struct, 0, type.getAttributeList(), hold);
                elem.setTypeDefinition(type);
               
            } else {
               
                // no children, must be a mapping reference
                MappingElementBase ref = (MappingElementBase)struct.getEffectiveMapping();
                if (ref == null) {
                   
                    // TODO: handle this with xs:any strict?
                    m_context.addWarning("Handling not implemented for unspecified mapping", struct);
                   
View Full Code Here


                    }
                   
                } else if (comp instanceof StructureElement) {
                   
                    // no children, must be mapping reference
                    StructureElement struct = (StructureElement)comp;
                    MappingElementBase ref = (MappingElementBase)struct.getEffectiveMapping();
                    if (ref == null) {
                       
                        // TODO: handle this with xs:any strict?
                        m_context.addWarning("Handling not implemented for unspecified mapping", struct);
                       
View Full Code Here

                    fillAttributes(contain, 0, attrs, hold);
                   
                } else if (comp instanceof StructureElement) {
                   
                    // no children, must be mapping reference
                    StructureElement struct = (StructureElement)comp;
                    if (struct.isOptional()) {
                        m_context.addError("No schema equivalent for optional abstract mapping with attributes", comp);
                    } else {
                        MappingElementBase ref = (MappingElementBase)struct.getEffectiveMapping();
                        if (ref != null && ref.isAbstract()) {
                           
                            // abstract inline treated as group
                            MappingDetail detail = m_detailDirectory.getMappingDetail(ref);
                            AttributeGroupRefElement group = new AttributeGroupRefElement();
View Full Code Here

                // add <structure> with map-as for abstract mapping
                QName qname = detail.getTypeQName();
                if (iname == null) {
                    iname = custom.getElementName();
                }
                StructureElement struct = new StructureElement();
                if (qname == null) {
                    struct.setMapAsName(itype);
                } else {
                   
                    // set the type reference and namespace dependency
                    String uri = qname.getUri();
                    hold.addTypeNameReference(uri, uri);
                    struct.setMapAsQName(qname);
                   
                }
                struct.setName(iname);
                hold.addNamespaceUsage(hold.getNamespace());
                struct.setCreateType(custom.getCreateType());
                struct.setFactoryName(custom.getFactoryMethod());
                coll.addChild(struct);
               
            } else {
               
                // just set item-type for concrete mapping
                coll.setItemTypeName(itype);
               
            }
           
        } else if (m_global.isKnownMapping(itype)) {
           
            // just set item-type for known mapping
            coll.setItemTypeName(itype);
           
        } else if (Types.isSimpleValue(itype) || isValueClass(itype)) {
           
            // add <value> for simple type, or enum type with optional value method
            ValueElement value = new ValueElement();
            value.setName(iname);
            value.setDeclaredType(itype);
            coll.addChild(value);
            if (custom != null) {
                value.setDefaultText(custom.getEnumValueMethod());
            }
           
        } else {
           
            // embed structure definition within the collection
            StructureElement struct = new StructureElement();
            struct.setDeclaredType(itype);
            if (iname == null) {
                iname = custom.getElementName();
            }
            struct.setName(iname);
            hold.addNamespaceUsage(hold.getNamespace());
            fillStructure(custom, null, null, struct, hold);
            coll.addChild(struct);
           
        }
View Full Code Here

                    parent.addChild(value);
                   
                } else {
                   
                    // create <structure> with name and access information
                    StructureElement struct = new StructureElement();
                    if (memb.getFieldName() == null) {
                        struct.setGetName(gmeth);
                        struct.setSetName(memb.getSetName());
                    } else {
                        struct.setFieldName(memb.getFieldName());
                    }
                    setTypes(memb, struct);
                   
                    // check for optional value
                    if (!memb.isRequired()) {
                        struct.setUsageName("optional");
                    }
                   
                    // set details based on class handling
                    ClassCustom mcust = m_global.getClassCustomization(memb.getWorkingType());
                    fillStructure(mcust, memb, null, struct, hold);
View Full Code Here

                ClassCustom scust = m_global.getClassCustomization(stype);
                exmethmap = new HashMap();
                if (cust.getMembers().size() > 0) {
                   
                    // add child <structure> element for superclass, followed by content from this class
                    StructureElement sstruct = new StructureElement();
                    sstruct.setDeclaredType(stype);
                    fillStructure(scust, null, exmethmap, sstruct, hold);
                    struct.addChild(sstruct);
                   
                } else {
                   
                    // just replace class reference with superclass reference in existing <structure>
                    struct.setDeclaredType(stype);
                    fillStructure(scust, null, exmethmap, struct, hold);
                   
                }
               
            } else {
               
                // check for interface with abstract mapping to reference
                String[] intfs = sclas.getInterfaces();
                for (int i = 0; i < intfs.length; i++) {
                    String intf = intfs[i];
                    BindingMappingDetail idetail = (BindingMappingDetail)m_mappingDetailsMap.get(intf);
                    if (idetail != null && idetail.isUseAbstract() && idetail.getTypeQName() == null) {
                       
                        // reference abstract mapped interface
                        struct = new StructureElement();
                        struct.setMapAsName(intf);
                        exmethmap = idetail.getAccessMethodMap();
                        break;
                    }
                }
View Full Code Here

            if (mainmapping.isAbstract()) {
                hold.addTypeNameReference(uri, uri);
            }
           
            // check for superclass mapping to be extended (do this first for compatibility with schema type extension)
            StructureElement struct = null;
            String ptype = detail.getExtendsType();
            Map exmembmap = Collections.EMPTY_MAP;
            Map inmembmap = new HashMap();
            if (ptype == null) {
               
                // not extending a base mapping, check if need to include superclass
                IClass parent = clas.getSuperClass();
                if (cust.isUseSuper() && parent != null) {
                    ptype = parent.getName();
                    if (checkInclude(ptype)) {
                        struct = new StructureElement();
                        struct.setDeclaredType(ptype);
                        ClassCustom scust = m_global.getClassCustomization(ptype);
                        exmembmap = new HashMap();
                        fillStructure(scust, null, exmembmap, struct, hold);
                    }
                }
               
            } else {
               
                // create reference to parent mapping
                struct = new StructureElement();
                BindingMappingDetail pdetail = (BindingMappingDetail)m_mappingDetailsMap.get(ptype);
                if (!pdetail.isGenerated()) {
                    addMapping(ptype, pdetail);
                }
                exmembmap = pdetail.getAccessMethodMap();
                if (pdetail.isUseAbstract()) {
                   
                    // reference abstract mapped superclass
                    QName tname = pdetail.getTypeQName();
                    if (tname == null) {
                        throw new IllegalStateException("Internal error: unimplemented case of superclass " + ptype
                            + " to be extended by subclass " + type + ", without an abstract <mapping> ");
                    } else {
                        uri = tname.getUri();
                        hold.addTypeNameReference(uri, uri);
                        struct.setMapAsQName(tname);
                    }
                   
                } else {
                   
                    // reference concrete mapped superclass
                    struct.setMapAsName(ptype);
                   
                }
               
                // set extension for child concrete mapping
                if (mapcon != null) {
                    mapcon.setExtendsName(ptype);
                }
               
            }
           
            // add extension reference structure to mapping
            if (struct != null) {
                mainmapping.addChild(struct);
            }
           
            // add all details of class member handling to binding
            inmembmap.putAll(exmembmap);
            addMemberBindings(cust, exmembmap, inmembmap, mainmapping, hold);
            hold.addMapping(mainmapping);
            if (mapabs != null && mapcon != null) {
               
                // define content as structure reference to abstract mapping
                struct = new StructureElement();
                QName tname = detail.getTypeQName();
                uri = tname.getUri();
                hold.addTypeNameReference(uri, uri);
                struct.setMapAsQName(tname);
                mapcon.addChild(struct);
                hold.addMapping(mapcon);
               
            }
           
View Full Code Here

                    }
                   
                    // create single structure child invoking the type mapping
                    holder = m_bindingDirectory.getRequiredBinding(elschema);
                    setName(element.getEffectiveQName(), elmapping, holder);
                    StructureElement struct = new StructureElement();
                    QName qname = mapping.getTypeQName();
                    String uri = qname.getUri();
                    if (uri != null) {
                        m_bindingDirectory.addTypeNameReference(holder, uri, schema);
                    }
                    struct.setMapAsQName(qname);
                    elmapping.addChild(struct);
                    holder.addMapping(elmapping);
                   
                }
            }
View Full Code Here

            }
           
        } else {
           
            // check for reference to a mapped class
            StructureElement structure = (StructureElement)comp;
            TemplateElementBase templ = structure.getEffectiveMapping();
            if (! (templ instanceof MappingElement)) {
               
                // unknown content, leave it to user to fill in details
                if (only) {
                    addComment(egroup, " Replace \"any\" with details of " +
                        "content to complete schema ");
                    addChildElement(egroup, "any");
                } else {
                    addComment(egroup, " No mapping for structure at " +
                        ValidationException.describe(structure) + " ");
                    addComment(egroup,
                        " Fill in details of content here to complete schema ");
                }
               
            } else {
                MappingElementBase mapping = (MappingElementBase)templ;
                if (mapping.isAbstract()) {
                   
                    // check name to be used for instance of type
                    String ename = structure.getName();
                    if (ename == null) {
                        ename = mapping.getName();
                    }
                    if (ename == null) {
                       
                        // no schema equivalent, embed definition directly
                        addComment(egroup, "No schema representation for " +
                            "directly-embedded type, inlining definition");
                        addComment(egroup, "Add element name to structure at " +
                            ValidationException.describe(structure) +
                            " to avoid inlining");
                        defineList(mapping.children(), egroup, agroup, false);
                       
                    } else {
                       
                        // handle abstract mapping element as reference to type
                        Element element = addChildElement(egroup, "element");
                        String tname = simpleClassName(mapping.getClassName());
                        if (element.getPrefix() == null) {
                            tname = "tns:" + tname;
                        }
                        element.setAttribute("type", tname);
                        String name = structure.getName();
                        if (name == null) {
                            name = mapping.getName();
                        }
                        element.setAttribute("name", name);
                        if (structure.isOptional()) {
                            element.setAttribute("minOccurs", "0");
                        }
                    }
                   
                } else {
                   
                    // concrete mapping, check for name overridden
                    String sname = structure.getName();
                    String mname = mapping.getName();
                    if (sname != null && !sname.equals(mname)) {
                       
                        // inline definition for overridden name
                        addComment(egroup, "No schema representation for " +
                            "element reference with different name, inlining " +
                            "definition");
                        addComment(egroup,
                            "Remove name on mapping reference at " +
                            ValidationException.describe(structure) +
                            " to avoid inlining");
                        defineList(mapping.children(), egroup, agroup, false);
                       
                    } else {
                       
                        // use element reference for concrete mapping
                        Element element = addChildElement(egroup, "element");
                        String tname = simpleClassName(mapping.getClassName());
                        if (element.getPrefix() == null) {
                            tname = "tns:" + tname;
                        }
                        element.setAttribute("ref", tname);
                        if (structure.isOptional()) {
                            element.setAttribute("minOccurs", "0");
                        }
                    }
                   
                }
View Full Code Here

TOP

Related Classes of org.jibx.binding.model.StructureElement

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.