Package org.jibx.binding.model

Examples of org.jibx.binding.model.FormatElement


                valid = false;
               
            } else if (format != null) {
               
                // check format for existence and consistency
                FormatElement def = (FormatElement)s_nameToFormat.get(format);
                if (def == null) {
                    vctx.addError('\'' + format + "' is not a valid built-in format name", ctx.getStackTop());
                    valid = false;
                } else {
                    if (jclas == null) {
                        jclas = def.getTypeName();
                    }
                }
            }
           
            // look through all attributes of current element
View Full Code Here


                            child = m_package.addClass(fullname, m_baseName, m_nameConverter, m_decorators,
                                group.isEnumeration(), m_holder);
                            m_importsTracker.addImport(child.getFullName(), true);
                            text = child.getName();
                            if (group.isEnumeration()) {
                                FormatElement format = new FormatElement();
                                format.setTypeName(child.getBindingName());
                                ((EnumerationClassHolder)child).setBinding(format);
                                bindhold.addFormat(format);
                            }
                            if (s_logger.isDebugEnabled()) {
                                s_logger.debug("Added derived class " + child.getFullName());
View Full Code Here

     */
    private void addInnerFormats(MappingElementBase mapping) {
        for (int i = 0; i < m_inners.size(); i++) {
            ClassHolder inner = (ClassHolder)m_inners.get(i);
            if (inner.isSimpleValue()) {
                FormatElement format = new FormatElement();
                format.setTypeName(inner.getBindingName());
                ((EnumerationClassHolder)inner).setBinding(format);
                mapping.addTopChild(format);
            } else {
                ((StructureClassHolder)inner).addInnerFormats(mapping);
            }
View Full Code Here

           
            // determine format conversion handling for type
            String valsername = null;
            String valdesername = null;
            String valuename = null;
            FormatElement format = (FormatElement)s_formatMap.get(type);
            boolean passctx = false;
            if (format != null) {
                valsername = format.getSerializerName();
                valdesername = format.getDeserializerName();
                if (valsername == null && !"java.lang.String".equals(type)) {
                    valuename = "toString";
                }
                passctx = "org.jibx.runtime.QName".equals(type);
            } else if (item instanceof ReferenceItem) {
View Full Code Here

            int fill = 0;
            for (int i = 0; i < childs.size(); i++) {
                Object child = childs.get(i);
                boolean keep = true;
                if (child instanceof FormatElement) {
                    FormatElement format = (FormatElement)child;
                    keep = format.getDefaultText() != null || format.getDeserializerName() != null ||
                        format.getEnumValueName() != null || format.getSerializerName() != null;
                }
                if (keep) {
                    childs.set(fill++, child);
                }
            }
View Full Code Here

        // add any required format definitions
        for (Iterator iter = m_formatSet.iterator(); iter.hasNext();) {
            String type = (String)iter.next();
            ClassCustom clas = m_global.getClassCustomization(type);
            if (clas.getSerializer() != null || clas.getDeserializer() != null) {
                FormatElement format = new FormatElement();
                format.setDeserializerName(clas.getDeserializer());
                format.setSerializerName(clas.getSerializer());
                format.setTypeName(type);
                m_directory.addFormat(format);
            }
        }
    }
View Full Code Here

            SchemaElement schema = comp.getSchema();
            BindingHolder holder = m_bindingDirectory.getRequiredBinding(schema);
            if (definition.isEnumeration()) {
               
                // construct format and add to binding
                FormatElement format = new FormatElement();
                format.setTypeName(clas.getBindingName());
                format.setQName(definition.getQName());
                ((EnumerationClassHolder)clas).setBinding(format);
                m_bindingDirectory.addFormat(format);
               
            } else {
               
View Full Code Here

                }
               
            } 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) {
                    TypeData data = buildClassData(name, true);
                    typemap.put(format.getQName(), data);
                }
               
            }
        }
    }
View Full Code Here

     * @param dflt default value
     * @param map schema type qname to format definition map
     */
    private static void buildFormat(String stype, String jtype, String sname,
        String dname, String dflt, Map map) {
        FormatElement format = new FormatElement();
        format.setTypeName(jtype);
        format.setSerializerName(sname);
        format.setDeserializerName(dname);
        format.setDefaultText(dflt);
        map.put(new QName(SCHEMA_NAMESPACE, stype), format);
    }
View Full Code Here

                    param.setAttribute("array", Boolean.toString(isarray));
                    String javatype;
                    if (element.getSchemaType() instanceof XmlSchemaSimpleType) {
                       
                        // simple type translates to format element in binding
                        FormatElement format = (FormatElement)simpleTypeMap.get(typename);
                        if (format == null) {
                            throw new RuntimeException("Cannot unwrap element " +
                                qname + ": no format definition found for type " +
                                typename + " (used by element " + itemname + ')');
                        }
                        javatype = format.getTypeName();
                        param.setAttribute("form", "simple");
                        param.setAttribute("serializer", format.getSerializerName());
                        param.setAttribute("deserializer", format.getDeserializerName());
                       
                        // convert primitive types to wrapper types for nillable
                        if (element.isNillable() && s_wrapperMap.containsKey(javatype)) {
                            param.setAttribute("wrapped-primitive", "true");
                            param.setAttribute("value-method", javatype + "Value");
                            javatype = (String)s_wrapperMap.get(javatype);
                        } else {
                            param.setAttribute("wrapped-primitive", "false");
                            String dflt = element.getDefaultValue();
                            if (dflt == null) {
                                dflt = format.getDefaultText();
                            }
                            if (dflt != null) {
                                param.setAttribute("default", dflt);
                            }
                        }
View Full Code Here

TOP

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

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.