Package org.jibx.binding.model

Examples of org.jibx.binding.model.BindingHolder


        BindGen gen = new BindGen(custom);
        ArrayList types = new ArrayList();
        types.add("DefaultPackageClass");
        gen.generate(null, types);
        gen.finish("binding");
        BindingHolder hold = gen.getBinding(null);
        assertNotNull("no-namespace binding", hold);
        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;
View Full Code Here


        BindGen gen = new BindGen(custom);
        ArrayList types = new ArrayList();
        types.add("org.jibx.binding.generator.DataClass1");
        gen.generate(null, types);
        gen.finish("binding");
        BindingHolder hold = gen.getBinding("http://jibx.org/binding/generator");
        assertNotNull("default namespace binding", hold);
        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;
View Full Code Here

        ArrayList types = new ArrayList();
        types.add("org.jibx.binding.generator.DataClass1");
        types.add("org.jibx.binding.generator.DataClass2");
        gen.generate(null, types);
        gen.finish("binding");
        BindingHolder hold = gen.getBinding("http://jibx.org/binding/generator");
        assertNotNull("default namespace binding", hold);
        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;
View Full Code Here

        ArrayList types = new ArrayList();
        types.add("org.jibx.binding.generator.DataClass1");
        types.add("org.jibx.binding.generator.DataClass2");
        gen.generate(null, types);
        gen.finish("binding");
        BindingHolder hold = gen.getBinding("http://www.jibx.org/test");
        assertNotNull("specified namespace binding", hold);
        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;
View Full Code Here

        Set unbounduris = new HashSet();
        for (Iterator iter = services.iterator(); iter.hasNext();) {
            ServiceCustom service = (ServiceCustom)iter.next();
            List ops = service.getOperations();
            String uri = service.getNamespace();
            BindingHolder hold = m_bindingGenerator.addBinding(uri, false);
            for (Iterator iter1 = ops.iterator(); iter1.hasNext();) {
                OperationCustom op = (OperationCustom)iter1.next();
                List parms = op.getParameters();
                for (Iterator iter2 = parms.iterator(); iter2.hasNext();) {
                    ValueCustom parm = (ValueCustom)iter2.next();
                    if (parm.getItemType() != null) {
                        addCollectionBinding(doclit, parm, typemap, hold);
                    }
                }
                ValueCustom ret = op.getReturn();
                if (ret.getItemType() != null) {
                    addCollectionBinding(doclit, ret, typemap, hold);
                }
            }
            if (hold.getMappingCount() == 0) {
                unbounduris.add(uri);
            }
        }
       
        // ensure references for URIs with no mapping definitions
        m_bindingGenerator.addRootUris(unbounduris);
       
        // complete bindings and check if anything to be written
        String name = m_generationParameters.getBindingName();
        File path = m_generationParameters.getGeneratePath();
        BindingHolder rhold = m_bindingGenerator.finish(name);
        if (rhold.getBinding().topChildren().size() > 0) {
           
            // write and validate the bindings
            List bindings = m_bindingGenerator.validateFiles(path, m_generationParameters.getLocator(), rhold);
            if (bindings == null) {
                return null;
View Full Code Here

            bindmap.put(bindpair.getKey(), bindpair.getValue());
        }
        BindingOrganizer bindorg = generator.getBindingDirectory();
        bindorg.configureFiles("binding", pack, Collections.EMPTY_LIST);
        for (Iterator iter = bindorg.iterateBindings(); iter.hasNext();) {
            BindingHolder holder = (BindingHolder)iter.next();
            if (holder != null) {
                String match = (String)bindmap.get(holder.getNamespace());
                assertNotNull("Found unexpected binding for namespace " + holder.getNamespace() + ": " +
                    bindingText(holder), match);
                verifyBinding(match, holder);
            }
        }
    }
View Full Code Here

        }
        if (mainmapping != null) {
           
            // find the binding containing this mapping
            String uri = qname.getUri();
            BindingHolder hold = m_directory.getBinding(uri);
            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);
               
            }
           
            // set the member property map for mapping
            detail.setAccessMethodMap(inmembmap);
View Full Code Here

     * @param uri
     * @param dflt namespace is default for elements in binding flag
     * @return binding holder
     */
    public BindingHolder addBinding(String uri, boolean dflt) {
        BindingHolder hold = m_directory.getBinding(uri);
        if (hold == null) {
            hold = m_directory.addBinding(uri, uri, null, dflt);
        }
        return hold;
    }
View Full Code Here

     *
     * @param name file name for root or singleton binding definition
     * @return holder for root binding definition
     */
    public BindingHolder finish(String name) {
        BindingHolder root = m_directory.configureFiles(name, m_targetPackage, Collections.EMPTY_LIST);
        return root;
    }
View Full Code Here

            List bindings = new ArrayList();
            bindings.add(binding);
            URL base = dir.toURI().toURL();
            for (Iterator iter = uris.iterator(); iter.hasNext();) {
                String uri = (String)iter.next();
                BindingHolder hold = getBinding(uri);
                if (hold != root) {
                    URL url = new URL(base, hold.getFileName());
                    if (binding.addIncludePath(url.toExternalForm(), false)) {
                        throw new IllegalStateException("Binding not found when read from file");
                    } else {
                        bindings.add(binding.getExistingIncludeBinding(url));
                    }
View Full Code Here

TOP

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

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.