Package org.jibx.binding.model

Examples of org.jibx.binding.model.MappingElement


    private String mapQName(QName qname, Map complexTypeMap) throws RuntimeException {
        Object obj = complexTypeMap.get(qname);
        if (obj == null) {
            throw new RuntimeException("No mapping defined for element " + qname);
        }
        MappingElement mapping = (MappingElement)obj;
        String cname = mapping.getClassName();
        codeGenConfig.getTypeMapper().addTypeMappingName(qname, cname);
        return cname;
    }
View Full Code Here


                bindingMap.put(format, binding);

            } else if (child.type() == ElementBase.MAPPING_ELEMENT) {
               
                // record only abstract mappings with type names, and mappings with names
                MappingElement mapping = (MappingElement)child;
                bindingMap.put(mapping, binding);
                if (mapping.isAbstract() && mapping.getTypeQName() != null) {

                    // register named abstract mappings as complex type conversions
                    registerElement(mapping.getTypeQName(), mapping,
                                    complexTypeMap);

                } else if (mapping.getName() != null) {

                    // register concrete mappings as element conversions
                    String uri = mapping.getUri();
                    if (uri == null) {
                        uri = findDefaultNS(mapping.topChildIterator(),
                                            defaultns);
                    }
                    elementMap.put(new QName(uri, mapping.getName()), mapping);
                }
            }
        }
    }
View Full Code Here

                    detail.setAttribute("ns", tname.getNamespaceURI());
                    detail.setAttribute("name", tname.getLocalPart());
                    detail.setAttribute("type-index", clsindex);
                    bindinit.appendChild(detail);
                    if (mappedclass == null) {
                        MappingElement mapping = (MappingElement)complexTypeMap.get(tname);
                        mappedclass = mapping.getClassName();
                    }
                }
            }
            if (mappedclass == null) {
                mappedclass = "";
View Full Code Here

                    }
                   
                } else {
                   
                    // complex type translates to abstract mapping in binding
                    MappingElement mapping = (MappingElement)complexTypeMap.get(typename);
                    if (mapping == null) {
                        throw new RuntimeException("Cannot unwrap element " +
                            qname + ": no abstract mapping definition found for type " +
                            typename + " (used by element " + itemname + ')');
                    }
                    Integer tindex = (Integer)typeMappedClassMap.get(typename);
                    if (tindex == null) {
                        tindex = new Integer(typeMappedClassMap.size());
                        typeMappedClassMap.put(typename, tindex);
                    }
                    javatype = mapping.getClassName();
                    param.setAttribute("form", "complex");
                    param.setAttribute("type-index", tindex.toString());
                   
                }
                param.setAttribute("java-type", javatype);
View Full Code Here

        }
        Object obj = complexTypeMap.get(qname);
        if (obj == null) {
            throw new RuntimeException("No mapping defined for element " + qname);
        }
        MappingElement mapping = (MappingElement)obj;
        String cname = mapping.getClassName();
        codeGenConfig.getTypeMapper().addTypeMappingName(qname, cname);
        return cname;
    }
View Full Code Here

                // register named formats as simple type conversions
                FormatElement format = (FormatElement)child;
                registerElement(format.getQName(), format, simpleTypeMap);
               
            } else if (child.type() == ElementBase.MAPPING_ELEMENT) {
                MappingElement mapping = (MappingElement)child;
                if (mapping.isAbstract()) {
                   
                    // register named abstract mappings as complex type conversions
                    registerElement(mapping.getTypeQName(), mapping,
                        complexTypeMap);
                   
                } else {
                   
                    // register concrete mappings as element conversions
                    String uri = mapping.getUri();
                    if (uri == null) {
                        uri = findDefaultNS(mapping.topChildIterator(),
                            defaultns);
                    }
                    elementMap.put(new QName(uri, mapping.getName()), mapping);
                }
            }
        }
    }
View Full Code Here

            }
        };
        ctx.tourTree(holder.getBinding(), visitor);
    }
    public String getType(QName qn, boolean element) {
        MappingElement mappingElement = element ? elements.get(jibxQName(qn)) : types.get(jibxQName(qn));
        return (mappingElement == null) ? null : mappingElement.getClassName();
    }
View Full Code Here

        MappingElement mappingElement = element ? elements.get(jibxQName(qn)) : types.get(jibxQName(qn));
        return (mappingElement == null) ? null : mappingElement.getClassName();
    }

    public String getWrappedElementType(QName wrapperElement, QName item) {
        MappingElement mappingElement = elements.get(jibxQName(wrapperElement));
        return (mappingElement == null) ? null : itemType(mappingElement, item);
    }
View Full Code Here

        // add all top level mapping definitions to map from qname to class
        HashMap mappings = new HashMap();
        for (Iterator iter = binding.topChildIterator(); iter.hasNext();) {
            ElementBase child = (ElementBase)iter.next();
            if (child.type() == ElementBase.MAPPING_ELEMENT) {
                MappingElement mapping = (MappingElement)child;
                String name = mapping.getName();
                if (name != null) {
                    String uri = mapping.getUri();
                    if (uri == null) {
                        uri = findDefaultNS(mapping.topChildIterator());
                        if (uri == null) {
                            uri = defaultns;
                        }
                    }
                    mappings.put(new QName(uri, name), mapping.getClassName());
                }
            }
        }
        return mappings;
    }
View Full Code Here

            }
        };
        ctx.tourTree(holder.getBinding(), visitor);
    }
    public String getType(QName qn, boolean element) {
        MappingElement mappingElement = element ? elements.get(jibxQName(qn)) : types.get(jibxQName(qn));
        return (mappingElement == null) ? null : mappingElement.getClassName();
    }
View Full Code Here

TOP

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

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.