Java 类org.apache.commons.beanutils.expression.Resolver 实例源码

项目:NotifyTools    文件:LocaleBeanUtilsBean.java   
/**
 * Resolve any nested expression to get the actual target property.
 *
 * @param bean The bean
 * @param name The property name
 * @return The property's descriptor
 *
 * @throws IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @throws InvocationTargetException if the property accessor method
 *  throws an exception
 * @deprecated Property name expressions are now processed by
 * the configured {@link Resolver} implementation and this method
 * is no longer used by BeanUtils.
 */
@Deprecated
protected Descriptor calculate(final Object bean, String name)
        throws IllegalAccessException, InvocationTargetException {

    // Resolve any nested expression to get the actual target bean
    Object target = bean;
    final Resolver resolver = getPropertyUtils().getResolver();
    while (resolver.hasNested(name)) {
        try {
            target = getPropertyUtils().getProperty(target, resolver.next(name));
            name = resolver.remove(name);
        } catch (final NoSuchMethodException e) {
            return null; // Skip this property setter
        }
    }
    if (log.isTraceEnabled()) {
        log.trace("    Target bean = " + target);
        log.trace("    Target name = " + name);
    }

    // Declare local variables we will require
    final String propName = resolver.getProperty(name); // Simple name of target property
    final int index  = resolver.getIndex(name);         // Indexed subscript value (if any)
    final String key = resolver.getKey(name);           // Mapped key value (if any)

    return new Descriptor(target, name, propName, key, index);
}
项目:NotifyTools    文件:PropertyUtilsBean.java   
/**
 * Configure the {@link Resolver} implementation used by BeanUtils.
 * <p>
 * The {@link Resolver} handles the <i>property name</i>
 * expressions and the implementation in use effectively
 * controls the dialect of the <i>expression language</i>
 * that BeanUtils recongnises.
 * <p>
 * {@link DefaultResolver} is the default implementation used.
 *
 * @param resolver The property expression resolver.
 * @since 1.8.0
 */
public void setResolver(final Resolver resolver) {
    if (resolver == null) {
        this.resolver = new DefaultResolver();
    } else {
        this.resolver = resolver;
    }
}
项目:NotifyTools    文件:PropertyUtilsBean.java   
/**
 * Return the configured {@link Resolver} implementation used by BeanUtils.
 * <p>
 * The {@link Resolver} handles the <i>property name</i>
 * expressions and the implementation in use effectively
 * controls the dialect of the <i>expression language</i>
 * that BeanUtils recongnises.
 * <p>
 * {@link DefaultResolver} is the default implementation used.
 *
 * @return resolver The property expression resolver.
 * @since 1.8.0
 */
public Resolver getResolver() {
    return resolver;
}