Package org.jibx.binding.classes

Examples of org.jibx.binding.classes.ClassItem


                    attribute = false;
                } else if (tname.startsWith("java.")) {
                   
                    // check for standard library classes we can handle
                    ClassFile pcf = ClassCache.requireClassFile(tname);
                    ClassItem init = pcf.getInitializerMethod
                        ("(Ljava/lang/String;)");
                    if (init != null) {
                        simple = pcf.getMethod("toString",
                            "()Ljava/lang/String;") != null;
                        attribute = false;
                    }
                   
                }
               
                // check type of handling to use for value
                if (m_enumerationNames.get(tname) != null) {
                   
                    // define a value using deserializer method
                    String mname = (String)m_enumerationNames.get(tname);
                    int split = mname.lastIndexOf('.');
                    ClassFile dcf =
                        ClassCache.requireClassFile(mname.substring(0, split));
                    ClassItem dser =
                        dcf.getStaticMethod(mname.substring(split+1),
                        "(Ljava/lang/String;)");
                    if (dser == null || !tname.equals(dser.getTypeName())) {
                        throw new JiBXException("Deserializer method not " +
                            "found for enumeration class " + tname);
                    }
                    ValueElement value = new ValueElement();
                    value.setFieldName(fname);
View Full Code Here


        for (int i = 0; i < props.size(); i++) {
            String pname = (String)props.get(i);
            String base = Character.toUpperCase(pname.charAt(0)) +
                pname.substring(1);
            String gname = "get" + base;
            ClassItem gmeth = cf.getMethod(gname, "()");
            if (gmeth == null) {
                throw new JiBXException("No method " + gname +
                    "() found for property " + base + " in class " +
                    cf.getName());
            } else {
                String tname = gmeth.getTypeName();
                String sname = "set" + base;
                String sig = "(" + gmeth.getSignature().substring(2) + ")V";
                ClassItem smeth = cf.getMethod(sname, sig);
                if (smeth == null) {
                    throw new JiBXException("No method " + sname + "(" + tname +
                        ") found for property " + base + " in class " +
                        cf.getName());
                } else {
                   
                    // find type of handling needed for field type
                    boolean simple = false;
                    boolean object = true;
                    boolean attribute = true;
                    if (ClassItem.isPrimitive(tname)) {
                        simple = true;
                        object = false;
                    } else if (s_objectPrimitiveSet.contains(tname)) {
                        simple = true;
                    } else if (tname.equals("byte[]")) {
                        simple = true;
                        attribute = false;
                    } else if (tname.startsWith("java.")) {
                       
                        // check for standard library classes we can handle
                        ClassFile pcf = ClassCache.requireClassFile(tname);
                        if (pcf.getInitializerMethod("()") != null) {
                            simple = pcf.getMethod("toString",
                                "()Ljava/lang/String;") != null;
                            attribute = false;
                        }
                       
                    }
                    if (simple) {
                       
                        // define a simple value
                        ValueElement value = new ValueElement();
                        value.setGetName(gname);
                        value.setSetName(sname);
                        value.setName(valueName(pname));
                        if (object) {
                            value.setUsageName("optional");
                        }
                        if (!attribute) {
                            value.setStyleName("element");
                        }
                        contain.addChild(value);
                       
                    } else if (m_enumerationNames.get(tname) != null) {
                       
                        // define a value using deserializer method
                        String mname = (String)m_enumerationNames.get(tname);
                        int split = mname.lastIndexOf('.');
                        ClassFile dcf = ClassCache.
                            requireClassFile(mname.substring(0, split));
                        ClassItem dser =
                            dcf.getStaticMethod(mname.substring(split+1),
                            "(Ljava/lang/String;)");
                        if (dser == null || !tname.equals(dser.getTypeName())) {
                            throw new JiBXException("Deserializer method not " +
                                "found for enumeration class " + tname);
                        }
                        ValueElement value = new ValueElement();
                        value.setGetName(gname);
View Full Code Here

        HashSet dataset, HashSet exceptset) throws JiBXException {
        ClassFile cf = ClassCache.getClassFile(cname);
        if (cf != null) {
            for (int i = 0; i < mnames.size(); i++) {
                String mname = (String)mnames.get(i);
                ClassItem mitem = cf.getMethod(mname, "");
                if (mitem == null) {
                    System.err.println("Method " + mname +
                        " not found in class " + cname);
                } else {
                    if (dataset != null) {
                        String type = mitem.getTypeName();
                        if (type != null && isMappable(type)) {
                            dataset.add(type);
                        }
                        String[] args = mitem.getArgumentTypes();
                        for (int j = 0; j < args.length; j++) {
                            type = args[j];
                            if (isMappable(type)) {
                                dataset.add(args[j]);
                            }
                        }
                    }
                    if (exceptset != null) {
                        String[] excepts = mitem.getExceptions();
                        for (int j = 0; j < excepts.length; j++) {
                            exceptset.add(excepts[j]);
                        }
                    }
                }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.binding.model.IClass#getDirectField(java.lang.String)
     */
    public IClassItem getDirectField(String name) {
        ClassItem item = m_class.getDirectField(name);
        if (item == null) {
            return null;
        } else {
            return buildItem(item);
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.binding.model.IClass#getMethod(java.lang.String, java.lang.String)
     */
    public IClassItem getMethod(String name, String sig) {
        ClassItem item = m_class.getMethod(name, sig);
        if (item == null) {
            return null;
        } else {
            return buildItem(item);
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.binding.model.IClass#getMethod(java.lang.String, java.lang.String[])
     */
    public IClassItem getMethod(String name, String[] sigs) {
        ClassItem item = m_class.getMethod(name, sigs);
        if (item == null) {
            return null;
        } else {
            return buildItem(item);
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.binding.model.IClass#getInitializerMethod(java.lang.String)
     */
    public IClassItem getInitializerMethod(String sig) {
        ClassItem item = m_class.getInitializerMethod(sig);
        if (item == null) {
            return null;
        } else {
            return buildItem(item);
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.binding.model.IClass#getStaticMethod(java.lang.String, java.lang.String)
     */
    public IClassItem getStaticMethod(String name, String sig) {
        ClassItem item = m_class.getStaticMethod(name, sig);
        if (item == null) {
            return null;
        } else {
            return buildItem(item);
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.binding.model.IClass#getBestMethod(java.lang.String, java.lang.String, java.lang.String[])
     */
    public IClassItem getBestMethod(String name, String type, String[] args) {
        ClassItem item = m_class.getBestMethod(name, type, args);
        if (item == null) {
            return null;
        } else {
            return buildItem(item);
        }
View Full Code Here

                            "long".equals(itype) || "double".equals(itype);
                        if (bdef.isInput()) {
                           
                            // define strategy for adding items to collection
                            if (aname != null) {
                                ClassItem meth = cf.getBestMethod(aname,
                                    null, new String[] { itype });
                                if (meth == null) {
                                    ctx.throwStartTagException
                                        ("Add method " + aname +
                                        " not found in collection type " +
                                        cf.getName());
                                }
                                boolean hasval =
                                    !"void".equals(meth.getTypeName());
                                store = new NestedCollection.AddStore(meth,
                                    isdoub, hasval);
                            } else if (stname != null) {
                                ClassItem meth = cf.getBestMethod(stname,
                                    null, new String[] { "int", itype });
                                if (meth == null) {
                                    ctx.throwStartTagException
                                        ("Indexed store method " + stname +
                                        " not found in collection type " +
                                        cf.getName());
                                }
                                boolean hasval =
                                    !"void".equals(meth.getTypeName());
                                store = new NestedCollection.IndexedStore(meth,
                                    isdoub, hasval);
                            } else if (cf.isArray()) {
                                store = new NestedCollection.ArrayStore(itype,
                                    isdoub);
                            } else {
                                ctx.throwStartTagException
                                    ("Unknown collection " +
                                    "type with no add or store method defined");
                            }
                           
                        }
                        if (bdef.isOutput()) {
                           
                            // define strategy for loading items from collection
                            if (lname != null) {
                                ClassItem smeth = cf.getMethod(szname, "()I");
                                if (smeth == null) {
                                    ctx.throwStartTagException
                                        ("Size method " + szname +
                                        " not found in collection type " +
                                        cf.getName());
                                }
                                ClassItem lmeth = cf.getBestMethod(lname,
                                    itype, new String[] { "int" });
                                if (lmeth == null) {
                                    ctx.throwStartTagException
                                        ("Load method " + lname +
                                        " not found in collection type " +
                                        cf.getName());
                                }
                                load = new NestedCollection.
                                    IndexedLoad(smeth, isdoub, lmeth);
                            } else if (iname != null) {
                                String mname = "hasNext";
                                String nname = "next";
                                ClassItem meth = cf.getMethod(iname,
                                    "()Ljava/util/Iterator;");
                                if (meth == null) {
                                    mname = "hasMoreElements";
                                    nname = "nextElement";
                                    meth = cf.getMethod(iname,
View Full Code Here

TOP

Related Classes of org.jibx.binding.classes.ClassItem

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.