Package org.jibx.binding.model

Examples of org.jibx.binding.model.MappingElementBase


        JavaClass clas = cf.getRawClass();
        if (m_verbose) {
            System.out.println("\nBuilding mapping definition for " +
                clas.getClassName());
        }
        MappingElementBase element = new MappingElement();
        element.setAbstract(abstr || clas.isAbstract() || clas.isInterface());
        String name = clas.getClassName();
        element.setClassName(name);
        if (abstr) {
            element.setAbstract(true);
        } else {
            element.setName((String)m_mappedNames.get(name));
        }
        m_structureStack.push(name);
        defineStructure(cf, element);
        m_structureStack.pop();
        return element;
View Full Code Here


        m_enumerationNames = enums;
        for (int i = 0; i < names.size(); i++) {
            String cname = (String)names.get(i);
            if (!abstracts.contains(cname)) {
                ClassFile cf = ClassCache.requireClassFile(cname);
                MappingElementBase mapping = createMapping(cf, false);
                mapping.setComment(" generated mapping for class " + cname);
                binding.addTopChild(mapping);
            }
        }
        for (Iterator iter = abstracts.iterator(); iter.hasNext();) {
            String cname = (String)iter.next();
            ClassFile cf = ClassCache.requireClassFile(cname);
            MappingElementBase mapping = createMapping(cf, true);
            mapping.setComment(" generate abstract mapping for class " + cname);
            binding.addTopChild(mapping);
        }
       
        // finish with custom mapping definitions
        for (Iterator iter = customs.keySet().iterator(); iter.hasNext();) {
            String cname = (String)iter.next();
            String mname = (String)customs.get(cname);
            MappingElementBase mapping = new MappingElement();
            mapping.setComment(" specified mapping for class " + cname);
            mapping.setClassName(cname);
            mapping.setName((String)m_mappedNames.get(cname));
            mapping.setMarshallerName(mname);
            mapping.setUnmarshallerName(mname);
            binding.addTopChild(mapping);
        }
       
        // list classes handled if verbose
        if (m_verbose) {
View Full Code Here

        BindingElement binding = hold.getBinding();
        ArrayList childs = binding.topChildren();
        assertEquals("child count", 2, childs.size());
        Object child = childs.get(0);
        assertTrue("child type", child instanceof MappingElement);
        MappingElementBase mapping = (MappingElementBase)child;
        assertEquals("mapped class", mapping.getClassName(), "DefaultPackageClass");
        assertEquals("mapped items", 5, mapping.children().size());
    }
View Full Code Here

        BindingElement binding = hold.getBinding();
        ArrayList childs = binding.topChildren();
        assertEquals("child count", 3, childs.size());
        Object child = childs.get(1);
        assertTrue("child type", child instanceof MappingElement);
        MappingElementBase mapping = (MappingElementBase)child;
        assertEquals("mapped class", mapping.getClassName(), "org.jibx.binding.generator.DataClass1");
        assertEquals("mapped items", 4, mapping.children().size());
    }
View Full Code Here

        BindingElement binding = hold.getBinding();
        ArrayList childs = binding.topChildren();
        assertEquals("child count", 5, childs.size());
        Object child = childs.get(1);
        assertTrue("child type", child instanceof MappingElement);
        MappingElementBase mapping = (MappingElementBase)child;
        assertTrue("expected abstract mapping first", mapping.isAbstract());
        assertEquals("mapped class", mapping.getClassName(), "org.jibx.binding.generator.DataClass1");
        QName qname = mapping.getTypeQName();
        assertNotNull("type name", qname);
        assertEquals("default type name", "dataClass1", qname.getName());
        assertEquals("default type namespace", "http://jibx.org/binding/generator", qname.getUri());
        assertEquals("mapped items", 4, mapping.children().size());
        // order of child values inside mapping not specified for class, so don't check
        child = childs.get(2);
        assertTrue("child type", child instanceof MappingElement);
        mapping = (MappingElementBase)child;
        assertFalse("expected concrete mapping second", mapping.isAbstract());
        assertEquals("mapped class", mapping.getClassName(), "org.jibx.binding.generator.DataClass1");
        assertEquals("default element name", "dataClass1", mapping.getName());
        assertEquals("mapped items", 1, mapping.children().size());
        child = mapping.children().get(0);
        assertTrue("child type", child instanceof StructureElement);
        StructureElement struct = (StructureElement)child;
        assertEquals("mapping reference structure content", 0, struct.children().size());
        qname = struct.getMapAsQName();
        assertNotNull("type name", qname);
View Full Code Here

        BindingElement binding = hold.getBinding();
        ArrayList childs = binding.topChildren();
        assertEquals("child count", 5, childs.size());
        Object child = childs.get(1);
        assertTrue("child type", child instanceof MappingElement);
        MappingElementBase mapping = (MappingElementBase)child;
        assertTrue("expected abstract mapping first", mapping.isAbstract());
        assertEquals("mapped class", mapping.getClassName(), "org.jibx.binding.generator.DataClass1");
        QName qname = mapping.getTypeQName();
        assertNotNull("type name", qname);
        assertEquals("specified type name", "class1", qname.getName());
        assertEquals("specified type namespace", "http://www.jibx.org/test", qname.getUri());
        ArrayList mapchilds = mapping.children();
        assertEquals("mapped items", 3, mapchilds.size());
        child = mapchilds.get(0);
        assertTrue("child type", child instanceof ValueElement);
        ValueElement value = (ValueElement)child;
        assertEquals("get method", "getString", value.getGetName());
        assertEquals("set method", "setString", value.getSetName());
        assertEquals("value style", "element", value.getStyleName());
        assertEquals("element name", "string", value.getName());
        child = mapchilds.get(1);
        assertTrue("child type", child instanceof StructureElement);
        StructureElement struct = (StructureElement)child;
        assertEquals("get method", "getLinked", struct.getGetName());
        assertEquals("set method", "setLinked", struct.getSetName());
        assertEquals("element name", "linked", struct.getName());
        child = mapchilds.get(2);
        assertTrue("child type", child instanceof ValueElement);
        value = (ValueElement)child;
        assertEquals("get method", "getInt", value.getGetName());
        assertEquals("set method", "setInt", value.getSetName());
        assertEquals("value style", "attribute", value.getStyleName());
        assertEquals("element name", "int", value.getName());
        child = childs.get(2);
        assertTrue("child type", child instanceof MappingElement);
        mapping = (MappingElementBase)child;
        assertFalse("expected concrete mapping second", mapping.isAbstract());
        assertEquals("mapped class", mapping.getClassName(), "org.jibx.binding.generator.DataClass1");
        assertEquals("specified element name", "class1", mapping.getName());
        assertEquals("mapped items", 1, mapping.children().size());
        child = mapping.children().get(0);
        assertTrue("child type", child instanceof StructureElement);
        struct = (StructureElement)child;
        assertEquals("mapping reference structure content", 0, struct.children().size());
        qname = struct.getMapAsQName();
        assertNotNull("type name", qname);
View Full Code Here

                       
                        // add container structure to expansion list
                        expands.add(comp);
                       
                    } else {
                        MappingElementBase ref = (MappingElementBase)struct.getEffectiveMapping();
                        if (ref != null) {
                           
                            // mapping element reference, check if named
                            if (ref.getName() != null) {
                                haschild = true;
                            } else {
                                expands.add(ref);
                                m_forceTypeMappings.add(ref);
                            }
View Full Code Here

            // check for either not an array, or plain doc/lit
            String type = value.getWorkingType();
            if (doclit || !type.endsWith("[]")) {
               
                // create abstract mapping for collection class type
                MappingElementBase mapping = new MappingElement();
                mapping.setClassName(type);
                mapping.setAbstract(true);
                mapping.setCreateType(value.getCreateType());
                mapping.setFactoryName(value.getFactoryMethod());
               
                // generate the mapping type name from item class name and suffix
                String suffix;
                GlobalCustom global = m_generationParameters.getGlobal();
                IClass clas = global.getClassInfo(type);
                if (clas.isImplements("Ljava/util/List;")) {
                    suffix = "List";
                } else if (clas.isImplements("Ljava/util/Set;")) {
                    suffix = "Set";
                } else {
                    suffix = "Collection";
                }
                String itype = value.getItemType();
                ClassCustom cust = global.addClassCustomization(itype);
               
                // register the type name for mapping
                String name = cust.getSimpleName() + suffix;
                String uri = bind.getNamespace();
                qname = new QName(uri, CustomBase.convertName(name, CustomBase.CAMEL_CASE_NAMES));
                mapping.setTypeQName(qname);
                bind.addTypeNameReference(uri, uri);
                typemap.put(ptype, qname);
               
                // add collection definition details
                CollectionElement coll = new CollectionElement();
                m_bindingGenerator.defineCollection(itype, value.getItemName(), coll, bind);
                mapping.addChild(coll);
               
                // add mapping to binding
                bind.addMapping(mapping);
            }
        }
View Full Code Here

                    typemap);
               
            } else if (element.type() == ElementBase.MAPPING_ELEMENT) {
               
                // handle mapping as type if abstract with type name, or as element if concrete
                MappingElementBase mapping = (MappingElementBase)element;
                String cname = mapping.getClassName();
                if (mapping.isAbstract()) {
                    QName qname = mapping.getTypeQName();
                    if (qname != null) {
                        typemap.put(cname, qname);
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug("Added class " + cname + " with type " + qname);
                        }
                    }
                } else {
                    QName qname = new QName(mapping.getNamespace().getUri(), mapping.getName());
                    elemmap.put(cname, qname);
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Added class " + cname + " with element " + qname);
                    }
                }
View Full Code Here

            for (int i = childs.size() - 1; i >= 0 ; i--) {
                Object child = childs.get(i);
                if (child instanceof MappingElement) {
                   
                    // end scan if a real mapping is found
                    MappingElementBase map = (MappingElementBase)child;
                    ClassFile cf = map.getHandledClass().getClassFile();
                    if (!cf.isInterface() && cf.isModifiable()) {
                        return cf;
                    }
                   
                } else if (child instanceof IncludeElement) {
View Full Code Here

TOP

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

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.