Package org.jibx.binding.model

Examples of org.jibx.binding.model.ElementBase


     * @param typemap map from fully-qualified class name to type qualified name
     */
    private static void accumulateBindingDefinitions(BindingElement binding, Map elemmap, Map typemap) {
        ArrayList childs = binding.topChildren();
        for (int i = 0; i < childs.size(); i++) {
            ElementBase element = (ElementBase)childs.get(i);
            if (element.type() == ElementBase.INCLUDE_ELEMENT) {
               
                // use recursive call to add nested definitions in included binding
                accumulateBindingDefinitions(((org.jibx.binding.model.IncludeElement)element).getBinding(), elemmap,
                    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()) {
View Full Code Here


                    defineCollection(itype, iname, coll, hold);
                   
                    // check for special case of two unwrapped collections with same item-type and no children
                    ArrayList siblings = parent.children();
                    if (siblings.size() > 0 && coll.children().size() == 0 && coll.getName() == null) {
                        ElementBase sibling = (ElementBase)siblings.get(siblings.size()-1);
                        if (sibling.type() == ElementBase.COLLECTION_ELEMENT) {
                            CollectionElement lastcoll = (CollectionElement)sibling;
                            if (lastcoll.children().size() == 0 && lastcoll.getName() == null &&
                                Utility.safeEquals(lastcoll.getItemTypeName(), coll.getItemTypeName())) {
                                throw new IllegalStateException("Need to use wrapper element for collection member '" +
                                    memb.getBaseName() + "' of class " + cust.getName());
View Full Code Here

     * @param typemap map from type qualified name to class data
     */
    private static void accumulateBindingDefinitions(BindingElement binding, Map elemmap, Map typemap) {
        ArrayList childs = binding.topChildren();
        for (int i = 0; i < childs.size(); i++) {
            ElementBase element = (ElementBase)childs.get(i);
            if (element.type() == ElementBase.INCLUDE_ELEMENT) {
               
                // use recursive call to add nested definitions in included binding
                BindingElement inclbinding = ((org.jibx.binding.model.IncludeElement)element).getBinding();
                if (inclbinding != null) {
                    accumulateBindingDefinitions(inclbinding, elemmap,
                        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();
                TypeData data = buildClassData(cname, false);
                if (mapping.isAbstract()) {
                    QName qname = mapping.getTypeQName();
                    if (qname != null) {
                        typemap.put(qname, data);
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug("Added class " + cname + " for type " + qname);
                        }
                    }
                } else {
                    QName qname = new QName(mapping.getNamespace().getUri(), mapping.getName());
                    elemmap.put(qname, data);
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Added class " + cname + " for element " + qname);
                    }
                }
               
            } else if (element.type() == ElementBase.FORMAT_ELEMENT) {
               
                // add named format as simple type definition
                FormatElement format = (FormatElement)element;
                String name = format.getTypeName();
                if (name != null) {
View Full Code Here

     * @param binding
     * @return <code>true</code> if no-namespace namespace used, <code>false</code> if not
     */
    public static boolean checkNoNamespace(BindingElement binding) {
        loop: for (Iterator childiter = binding.topChildIterator(); childiter.hasNext();) {
            ElementBase child = (ElementBase)childiter.next();
            switch (child.type()) {
               
                case ElementBase.NAMESPACE_ELEMENT:
                    if (((NamespaceElement)child).getPrefix() == null) {
                        return true;
                    }
View Full Code Here

    private void defineList(ArrayList comps, Element egroup, Element agroup,
        boolean mult) {
       
        // handle all nested elements of container
        for (int i = 0; i < comps.size(); i++) {
            ElementBase child = (ElementBase)comps.get(i);
            switch (child.type()) {
               
                case ElementBase.COLLECTION_ELEMENT:
                case ElementBase.STRUCTURE_ELEMENT:
                {
                    defineStructureComponent((StructureElementBase)child,
View Full Code Here

       
        // process each mapping definition for binding
        m_structureStack.push(binding);
        ArrayList tops = binding.topChildren();
        for (int i = 0; i < tops.size(); i++) {
            ElementBase top = (ElementBase)tops.get(i);
            if (top.type() == ElementBase.MAPPING_ELEMENT) {
               
                // find or create schema for mapped class
                MappingElementBase mapping = (MappingElementBase)top;
                String uri = mapping.getNamespace().getUri();
                Element schema = (Element)m_schemaMap.get(uri);
View Full Code Here

                        param.setAttribute("type-index", tindex.toString());
                       
                        // merge contained namespace definitions into set for operation
                        Iterator citer = mapping.topChildIterator();
                        while (citer.hasNext()) {
                            ElementBase child = (ElementBase)citer.next();
                            if (child.type() == ElementBase.NAMESPACE_ELEMENT) {
                                dfltns = mapNamespace((NamespaceElement)child, dfltns, nsmap);
                            } else {
                               break;
                            }
                        }
                       
                        // also merge namespace definitions from binding
                        BindingElement binding = (BindingElement)bindingMap.get(mapping);
                        citer = binding.topChildIterator();
                        while (citer.hasNext()) {
                            ElementBase child = (ElementBase)citer.next();
                            if (child.type() == ElementBase.NAMESPACE_ELEMENT) {
                                dfltns = mapNamespace((NamespaceElement)child, dfltns, nsmap);
                            } else if (child.type() != ElementBase.INCLUDE_ELEMENT) {
                               break;
                            }
                        }
                    }
                    param.setAttribute("java-type", javatype);
View Full Code Here

        // check default namespace set at top level of binding
        String defaultns = findDefaultNS(binding.topChildIterator(), dns);
       
        // add all top level mapping and format definitions to maps
        for (Iterator iter = binding.topChildIterator(); iter.hasNext();) {
            ElementBase child = (ElementBase)iter.next();
            if (child.type() == ElementBase.INCLUDE_ELEMENT) {
               
                // recurse to process included binding definitions
                IncludeElement include = (IncludeElement)child;
                collectTopLevelComponents(include.getBinding(), defaultns,
                    elementMap, complexTypeMap, simpleTypeMap, bindingMap);
               
            } else if (child.type() == ElementBase.FORMAT_ELEMENT) {
               
                // register named formats as simple type conversions
                FormatElement format = (FormatElement)child;
                registerElement(format.getQName(), format, simpleTypeMap);
                bindingMap.put(format, binding);
               
            } else if (child.type() == ElementBase.MAPPING_ELEMENT) {
                MappingElement mapping = (MappingElement)child;
                bindingMap.put(mapping, binding);
                if (mapping.isAbstract()) {
                   
                    // register named abstract mappings as complex type conversions
View Full Code Here

     * @param dns default namespace if not overridden
     * @return default namespace
     */
    private static String findDefaultNS(Iterator iter, String dns) {
        while (iter.hasNext()) {
            ElementBase child = (ElementBase)iter.next();
            if (child.type() == ElementBase.NAMESPACE_ELEMENT) {
                NamespaceElement namespace = (NamespaceElement)child;
                String defaultName = namespace.getDefaultName();
                if ("elements".equals(defaultName) || "all".equals(defaultName)) {
                    return namespace.getUri();
                }
View Full Code Here

                        }

                        // merge contained namespace definitions into set for operation
                        Iterator citer = mapping.topChildIterator();
                        while (citer.hasNext()) {
                            ElementBase child = (ElementBase)citer.next();
                            if (child.type() == ElementBase.NAMESPACE_ELEMENT) {
                                dfltns = mapNamespace((NamespaceElement)child, dfltns, nsmap);
                            } else {
                                break;
                            }
                        }

                        // also merge namespace definitions from binding
                        BindingElement binding = (BindingElement)bindingMap.get(mapping);
                        citer = binding.topChildIterator();
                        while (citer.hasNext()) {
                            ElementBase child = (ElementBase)citer.next();
                            if (child.type() == ElementBase.NAMESPACE_ELEMENT) {
                                dfltns = mapNamespace((NamespaceElement)child, dfltns, nsmap);
                            } else if (child.type() != ElementBase.INCLUDE_ELEMENT) {
                                break;
                            }
                        }
                    }
                    param.setAttribute("java-type", javatype);
View Full Code Here

TOP

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

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.