ObjectElementHandler.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:jdk8u-jdk 作者:
/**
 * Creates the value of this element.
 *
 * @param type  the base class
 * @param args  the array of arguments
 * @return the value of this element
 * @throws Exception if calculation is failed
 */
@Override
protected final ValueObject getValueObject(Class<?> type, Object[] args) throws Exception {
    if (this.field != null) {
        return ValueObjectImpl.create(FieldElementHandler.getFieldValue(getContextBean(), this.field));
    }
    if (this.idref != null) {
        return ValueObjectImpl.create(getVariable(this.idref));
    }
    Object bean = getContextBean();
    String name;
    if (this.index != null) {
        name = (args.length == 2)
                ? PropertyElementHandler.SETTER
                : PropertyElementHandler.GETTER;
    } else if (this.property != null) {
        name = (args.length == 1)
                ? PropertyElementHandler.SETTER
                : PropertyElementHandler.GETTER;

        if (0 < this.property.length()) {
            name += this.property.substring(0, 1).toUpperCase(ENGLISH) + this.property.substring(1);
        }
    } else {
        name = (this.method != null) && (0 < this.method.length())
                ? this.method
                : "new"; // NON-NLS: the constructor marker
    }
    Expression expression = new Expression(bean, name, args);
    return ValueObjectImpl.create(expression.getValue());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号