Package org.jibx.custom.classes

Examples of org.jibx.custom.classes.ClassCustom


     *
     * @param info class information (<code>null</code> if not available)
     * @param root
     */
    private void addDocumentation(IClass info, AnnotatedBase root) {
        ClassCustom custom = m_custom.getClassCustomization(info.getName());
        if (info != null && custom.isUseJavaDocs()) {
            List nodes = m_formatCache.getFormatter(custom).getClassDocumentation(info);
            if (nodes != null) {
                AnnotationElement anno = new AnnotationElement();
                DocumentationElement doc = new DocumentationElement();
                for (Iterator iter = nodes.iterator(); iter.hasNext();) {
View Full Code Here


     *
     * @param item
     * @param elem
     */
    private void setDocumentation(IClassItem item, AnnotatedBase elem) {
        ClassCustom custom = m_custom.getClassCustomization(item.getOwningClass().getName());
        if (custom != null && custom.isUseJavaDocs()) {
            List nodes = m_formatCache.getFormatter(custom).getItemDocumentation(item);
            if (nodes != null) {
                AnnotationElement anno = new AnnotationElement();
                DocumentationElement doc = new DocumentationElement();
                for (Iterator iter = nodes.iterator(); iter.hasNext();) {
View Full Code Here

        // process all the simple type definitions (formats or enums)
        Collection simples = m_detailDirectory.getSimpleDetails();
        for (Iterator iter = simples.iterator(); iter.hasNext();) {
            EnumDetail detail = (EnumDetail)iter.next();
            if (detail.isGlobal()) {
                ClassCustom custom = detail.getCustom();
                SimpleTypeElement type = buildSimpleType(custom.getClassInformation());
                type.setName(custom.getTypeName());
                SchemaHolder hold = findSchema(custom.getNamespace());
                hold.getSchema().getTopLevelChildren().add(type);
                m_classSimpletypes.put(custom.getName(), custom.getTypeQName());
            }
        }
       
        // process all the mapping definitions from directory
        Collection mappings = m_detailDirectory.getComplexDetails();
View Full Code Here

     *
     * @param type fully qualified class name
     * @return <code>true</code> if simple value, <code>false</code> if not
     */
    public boolean isValueClass(String type) {
        ClassCustom clas = m_global.addClassCustomization(type);
        if (clas.isSimpleValue()) {
            m_formatSet.add(type);
            return true;
        }
        IClass sinfo = clas.getClassInformation().getSuperClass();
        if (sinfo != null && "java.lang.Enum".equals(sinfo.getName())) {
            return true;
        } else {
            return false;
        }
View Full Code Here

            return false;
        } else {
           
            // check if any members are to be included
            boolean include = false;
            ClassCustom clas = m_global.addClassCustomization(type);
            if (clas.isSimpleValue()) {
                include = true;
            } else {
               
                // check each member to find anything to be included
                for (Iterator iter = clas.getMembers().iterator(); iter.hasNext();) {
                    ValueCustom memb = (ValueCustom)iter.next();
                    String mtype = memb.isCollection() ? memb.getItemType() : memb.getWorkingType();
                    if (Types.isSimpleValue(mtype) || isValueClass(mtype) || !m_global.isKnownMapping(mtype)
                        || checkInclude(mtype)) {
                        include = true;
                        break;
                    }
                }
               
            }
            if (!include) {
               
                // force superclass handling if appropriate
                if (clas.getMembers().size() > 0 && clas.isUseSuper()) {
                    String stype = clas.getClassInformation().getSuperClass().getName();
                    if (!"java.lang.Object".equals(stype) && checkInclude(stype)) {
                        include = true;
                    }
                }
            }
View Full Code Here

     */
    public void expandReferences(String type, ReferenceCountMap refmap) {
        if (checkInclude(type)) {
           
            // skip any member processing if a simple value
            ClassCustom clas = m_global.addClassCustomization(type);
            if (clas.isSimpleValue()) {
                return;
            }
           
            // increment reference count if forced mapping requested for class
            if (clas.isForceMapping() || clas.isAbstractMappingForced() || clas.isConcreteMappingForced()) {
                refmap.incrementCount(type);
            }
           
            // expand all references from members
            for (Iterator iter = clas.getMembers().iterator(); iter.hasNext();) {
                ValueCustom memb = (ValueCustom)iter.next();
                String mtype = memb.isCollection() ? memb.getItemType() : memb.getWorkingType();
                if (!Types.isSimpleValue(mtype) && !isValueClass(mtype) && !m_global.isKnownMapping(mtype)) {
                    if ((mtype.startsWith("java.")) || (mtype.startsWith("javax."))) {
                        throw new IllegalStateException("No way to handle type " + mtype + ", referenced from " + type);
                    } else if (checkInclude(mtype)) {
                        if (refmap.incrementCount(mtype) <= 1) {
                            expandReferences(mtype, refmap);
                        }
                        m_directSet.add(mtype);
                    }
                }
            }
           
            // force superclass handling if appropriate
            if (clas.getMembers().size() > 0 && clas.isUseSuper()) {
                String stype = clas.getClassInformation().getSuperClass().getName();
                if (!"java.lang.Object".equals(stype) && !Types.isSimpleValue(stype) && !isValueClass(stype)
                    && !m_global.isKnownMapping(stype) && checkInclude(stype)) {
                    if (refmap.incrementCount(stype) <= 1) {
                        expandReferences(stype, refmap);
                    }
View Full Code Here

     */
    public void defineCollection(String itype, String iname, CollectionElement coll, BindingHolder hold) {
       
        // check item type handling
        BindingMappingDetail detail = (BindingMappingDetail)m_mappingDetailsMap.get(itype);
        ClassCustom custom = m_global.getClassCustomization(itype);
        if (detail != null) {
            if (detail.isUseAbstract() && !detail.isExtended()) {
               
                // add <structure> with map-as for abstract mapping
                QName qname = detail.getTypeQName();
                if (iname == null) {
                    iname = custom.getElementName();
                }
                StructureElement struct = new StructureElement();
                if (qname == null) {
                    struct.setMapAsName(itype);
                } else {
                   
                    // set the type reference and namespace dependency
                    String uri = qname.getUri();
                    hold.addTypeNameReference(uri, uri);
                    struct.setMapAsQName(qname);
                   
                }
                struct.setName(iname);
                hold.addNamespaceUsage(hold.getNamespace());
                struct.setCreateType(custom.getCreateType());
                struct.setFactoryName(custom.getFactoryMethod());
                coll.addChild(struct);
               
            } else {
               
                // just set item-type for concrete mapping
                coll.setItemTypeName(itype);
               
            }
           
        } else if (m_global.isKnownMapping(itype)) {
           
            // just set item-type for known mapping
            coll.setItemTypeName(itype);
           
        } else if (Types.isSimpleValue(itype) || isValueClass(itype)) {
           
            // add <value> for simple type, or enum type with optional value method
            ValueElement value = new ValueElement();
            value.setName(iname);
            value.setDeclaredType(itype);
            coll.addChild(value);
            if (custom != null) {
                value.setDefaultText(custom.getEnumValueMethod());
            }
           
        } else {
           
            // embed structure definition within the collection
            StructureElement struct = new StructureElement();
            struct.setDeclaredType(itype);
            if (iname == null) {
                iname = custom.getElementName();
            }
            struct.setName(iname);
            hold.addNamespaceUsage(hold.getNamespace());
            fillStructure(custom, null, null, struct, hold);
            coll.addChild(struct);
View Full Code Here

                    }
                    value.setName(memb.getXmlName());
                    hold.addNamespaceUsage(hold.getNamespace());
                  
                    // pass on optional value method for enum
                    ClassCustom icust = m_global.getClassCustomization(wtype);
                    if (icust != null) {
                        value.setEnumValueName(icust.getEnumValueMethod());
                    }
                   
                    // check for optional value
                    if (!memb.isRequired()) {
                        value.setUsageName("optional");
                    }
                   
                    // configure added property values
                    int style = memb.getStyle();
                    if (style == NestingBase.ATTRIBUTE_VALUE_STYLE) {
                        value.setStyleName("attribute");
                    } else if (style == NestingBase.ELEMENT_VALUE_STYLE) {
                        value.setStyleName("element");
                    } else {
                        value.setStyleName("text");
                        value.setName(null);
                    }
                    if (memb.getActualType() != null) {
                        value.setDeclaredType(memb.getActualType());
                    }
                    parent.addChild(value);
                   
                } else {
                   
                    // create <structure> with name and access information
                    StructureElement struct = new StructureElement();
                    if (memb.getFieldName() == null) {
                        struct.setGetName(gmeth);
                        struct.setSetName(memb.getSetName());
                    } else {
                        struct.setFieldName(memb.getFieldName());
                    }
                    setTypes(memb, struct);
                   
                    // check for optional value
                    if (!memb.isRequired()) {
                        struct.setUsageName("optional");
                    }
                   
                    // set details based on class handling
                    ClassCustom mcust = m_global.getClassCustomization(memb.getWorkingType());
                    fillStructure(mcust, memb, null, struct, hold);
                    parent.addChild(struct);
                   
                }
            }
View Full Code Here

            String stype = sclas.getName();
            Map exmethmap = Collections.EMPTY_MAP;
            if (checkInclude(stype)) {
               
                // check if any added content from this class
                ClassCustom scust = m_global.getClassCustomization(stype);
                exmethmap = new HashMap();
                if (cust.getMembers().size() > 0) {
                   
                    // add child <structure> element for superclass, followed by content from this class
                    StructureElement sstruct = new StructureElement();
View Full Code Here

     * @param detail mapping details
     */
    private void addMapping(String type, BindingMappingDetail detail) {
       
        // create the basic mapping structure(s)
        ClassCustom cust = m_global.addClassCustomization(type);
        MappingElementBase mainmapping = null;
        QName qname = null;
        MappingElementBase mapcon = null;
        IClass clas = cust.getClassInformation();
        if (detail.isUseConcrete()) {
           
            // create concrete mapping
            mapcon = createMapping(type, cust);
            qname = detail.getElementQName();
            mapcon.setName(qname.getName());
            detail.setConcreteMapping(mapcon);
           
            // make "concrete" mapping abstract if no class creation possible
            if (clas.isAbstract() || clas.isInterface()) {
                mapcon.setAbstract(true);
            }
           
            // fill details directly to this mapping unless abstract also created
            mainmapping = mapcon;
           
        }
        MappingElement mapabs = null;
        if (detail.isUseAbstract()) {
           
            // create abstract mapping
            mapabs = createMapping(type, cust);
            mapabs.setAbstract(true);
            qname = detail.getTypeQName();
            mapabs.setTypeQName(qname);
            detail.setAbstractMapping(mapabs);
           
            // use abstract mapping for details (concrete will reference this one)
            mainmapping = mapabs;
           
        }
        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);
                    }
                }
               
View Full Code Here

TOP

Related Classes of org.jibx.custom.classes.ClassCustom

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.