⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertyattributes.java

📁 对xml很好的java处理引擎,编译中绑定xml
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	}        /**     * Get set method name.     *      * @return set method name (or <code>null</code> if none)     */    public String getSetName() {        return m_setName;    }        /**     * Get set method information. This method is only usable after a call to     * {@link #validate}.     *      * @return set method information (or <code>null</code> if none)     */    public IClassItem getSet() {        return m_setItem;    }        /**     * Get type for value stored from stack. This method is only usable after a     * call to {@link #validate}.     *      * @return set value type (or <code>null</code> if none)     */    public IClass getSetType() {        return m_setType;    }        /**     * Set set method name.     *      * @param set set method name (or <code>null</code> if none)     */    public void setSetName(String set) {        m_setName = set;    }        /**     * Get type information. This method is only usable after a call to {@link     * #validate}.     *      * @return type information (or <code>null</code> if none)     */    public IClass getType() {        return m_type;    }        /**     * Check if empty property definition. Empty property definitions occur     * because every <b>collection</b>, <b>structure</b>, and <b>value</b>     * element has associated property attributes but these may not actually     * reference a property (when using the containing object). This call is     * only meaningful after prevalidation.     *      * @return <code>true</code> if implicit property, <code>false</code> if not     */    public boolean isImplicit() {        return m_isImplicit;    }        /* (non-Javadoc)     * @see org.jibx.binding.model.AttributeBase#prevalidate(org.jibx.binding.model.ValidationContext)     */    public void prevalidate(ValidationContext vctx) {                // check usage value        if (m_usageName != null) {            m_usage = s_usageEnum.getValue(m_usageName);            if (m_usage < 0) {                vctx.addError("Value \"" + m_usageName +                    "\" is not a valid choice for usage");            }        } else {            m_usage = vctx.getParentElement().getDefaultStyle();        }                // handle basic lookups and checks        ContainerElementBase parent = vctx.getParentContainer();        IClass cobj = parent.getChildObjectType();        String dtype = null;        String gtype = null;        String stype = null;        boolean err = false;        m_isImplicit = true;        if (m_fieldName != null) {                        // field means this is real (not implicit)            m_isImplicit = false;                        // look up the field information            m_fieldItem = cobj.getField(m_fieldName);            if (m_fieldItem == null) {                vctx.addFatal("Nonstatic field " + m_fieldName +                    " not found in class " + cobj.getName());                err = true;            } else {                dtype = gtype = stype = m_fieldItem.getTypeName();            }                    }        if (m_testName != null) {                        // make sure only used with optional            if (m_usage == REQUIRED_USAGE) {                vctx.addError("test-method can only be used with optional property");            } else {                                // look up the method information                m_testItem = cobj.getMethod(m_testName, TEST_METHOD_SIGNATURES);                if (m_testItem == null) {                    vctx.addError("Nonstatic test-method " + m_testName +                        " not found in class " + cobj.getName());                }            }                    }        if (m_getName != null) {                        // get-method means this is real (not implicit)            m_isImplicit = false;                        // look up the get method by name (no overload possible)            m_getItem = cobj.getMethod(m_getName, GET_METHOD_SIGNATURES);            if (m_getItem == null) {                vctx.addFatal("Nonstatic get-method " + m_getName +                    " not found in class " + cobj.getName());                err = true;            } else {                gtype = m_getItem.getTypeName();                if (dtype == null) {                    dtype = gtype;                }            }                        // check for only get-method supplied when both directions needed            if (vctx.isInBinding() && m_fieldName == null &&                m_setName == null) {                vctx.addError("Need field or set-method for input handling");            }        }        if (m_setName != null) {                        // set-method means this is real (not implicit)            m_isImplicit = false;                        // need to handle overloads, so generate possible signatures            ArrayList sigs = new ArrayList();            if (m_getItem != null) {                String psig = ClassUtils.getSignature(gtype);                sigs.add("(" + psig +                    "Lorg/jibx/runtime/IUnmarshallingContext;" + ")V");                sigs.add("(" + psig + ")V");            }            if (m_declaredType != null) {                String psig = ClassUtils.getSignature(m_declaredType);                sigs.add("(" + psig +                    "Lorg/jibx/runtime/IUnmarshallingContext;" + ")V");                sigs.add("(" + psig + ")V");            }            if (m_fieldItem != null) {                String psig = m_fieldItem.getSignature();                sigs.add("(" + psig +                    "Lorg/jibx/runtime/IUnmarshallingContext;" + ")V");                sigs.add("(" + psig + ")V");            }            sigs.add                ("(Ljava/lang/Object;Lorg/jibx/runtime/IUnmarshallingContext;)V");            sigs.add("(Ljava/lang/Object;)V");                        // match any of the possible signatures            m_setItem = cobj.getMethod(m_setName,                (String[])sigs.toArray(new String[0]));            if (m_setItem == null && m_declaredType == null) {                                // nothing known about signature, try anything by name                m_setItem = cobj.getMethod(m_setName, "");                if (m_setItem != null && (m_setItem.getArgumentCount() != 1 ||                    !m_setItem.getTypeName().equals("void"))) {                    m_setItem = null;                }                if (m_setItem != null) {                                        // make sure resulting type is compatible                    String type = m_setItem.getArgumentType(0);                    if (dtype != null &&                        !ClassUtils.isAssignable(type, dtype, vctx)) {                        m_setItem = null;                    } else if (gtype != null &&                        !ClassUtils.isAssignable(type, gtype, vctx)) {                        m_setItem = null;                    }                    if (m_setItem != null) {                        dtype = type;                    }                }            }                        // check set-method found            if (m_setItem == null) {                vctx.addFatal("Nonstatic set-method " + m_setName +                    " with argument of appropriate type not found in class " +                    cobj.getName());                err = true;            } else {                stype = m_setItem.getArgumentType(0);                if (dtype == null) {                    dtype = stype;                }            }                        // check for only set-method supplied when both directions needed            if (vctx.isOutBinding() && m_fieldName == null &&                m_getName == null) {                vctx.addError("Need field or get-method for output handling");            }        }                // set the property type information        String tname = m_declaredType;        if (tname == null) {            tname = dtype;            if (tname == null) {                tname = cobj.getName();            }        } else if (dtype == null) {            dtype = gtype = stype = tname;        }        m_type = vctx.getClassInfo(tname);        if (m_type == null) {            vctx.addFatal("Unable to load class " + tname);        } else if (vctx.getContextObject() instanceof CollectionElement) {                        // forbid access specifications for child of collection            if (m_fieldName != null || m_getName != null || m_setName != null) {                vctx.addWarning("Property access attributes (field, " +                    "get-method, set-method) ignored for collection item");            }                    } else if (!err && !m_isImplicit) {                        // check that type information is consistent            boolean valid = true;                        // require access specifications for child of non-collection            if (vctx.isInBinding()) {                if (stype == null) {                    vctx.addError("No way to set property value");                    stype = "java.lang.Object";                } else {                    valid = ClassUtils.isAssignable(tname, stype, vctx) ||                        ClassUtils.isAssignable(stype, tname, vctx);                }                m_setType = vctx.getClassInfo(stype);            }            if (gtype == null) {                if (vctx.isOutBinding()) {                    vctx.addError("No way to get property value");                    m_getType = vctx.getClassInfo("java.lang.Object");                }            } else {                if (valid) {                    valid = ClassUtils.isAssignable(tname, gtype, vctx) ||                        ClassUtils.isAssignable(gtype, tname, vctx);                }                m_getType = vctx.getClassInfo(gtype);            }            if (!valid) {                vctx.addError("Incompatible types used in property definition");            }        }        super.prevalidate(vctx);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -