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

📄 localebeanutilsbean.java

📁 apache beanutils开源项目源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     *     * @param bean Bean whose property is to be extracted     * @param name Simple property name of the property value to be extracted     * @param key Lookup key of the property value to be extracted     * @param pattern The convertion pattern     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getMappedProperty(                                    Object bean,                                    String name,                                     String key,                                     String pattern)                                        throws                                             IllegalAccessException,                                             InvocationTargetException,                                            NoSuchMethodException {        Object value = getPropertyUtils().getMappedProperty(bean, name, key);        return getLocaleConvertUtils().convert(value, pattern);    }    /**     * Return the value of the specified mapped locale-sensitive property     * of the specified bean, as a String     * The key is specified as a method parameter and must *not* be included     * in the property name expression     *     * @param bean Bean whose property is to be extracted     * @param name Simple property name of the property value to be extracted     * @param key Lookup key of the property value to be extracted     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getMappedProperty(Object bean,                                           String name, String key)            throws IllegalAccessException, InvocationTargetException,            NoSuchMethodException {        return getMappedProperty(bean, name, key, null);    }    /**     * Return the value of the specified locale-sensitive mapped property     * of the specified bean, as a String using the specified pattern.     * The String-valued key of the required value     * must be included (in parentheses) as a suffix to     * the property name, or <code>IllegalArgumentException</code> will be     * thrown.     *     * @param bean Bean whose property is to be extracted     * @param name <code>propertyname(index)</code> of the property value     *  to be extracted     * @param pattern The convertion pattern     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getMappedPropertyLocale(                                        Object bean,                                         String name,                                         String pattern)                                            throws                                                 IllegalAccessException,                                                 InvocationTargetException,                                                NoSuchMethodException {        Object value = getPropertyUtils().getMappedProperty(bean, name);        return getLocaleConvertUtils().convert(value, pattern);    }    /**     * Return the value of the specified locale-sensitive mapped property     * of the specified bean, as a String using the default     * convertion pattern of the corresponding {@link LocaleConverter}.     * The String-valued key of the required value     * must be included (in parentheses) as a suffix to     * the property name, or <code>IllegalArgumentException</code> will be     * thrown.     *     * @param bean Bean whose property is to be extracted     * @param name <code>propertyname(index)</code> of the property value     *  to be extracted     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getMappedProperty(Object bean, String name)                                    throws                                         IllegalAccessException,                                         InvocationTargetException,                                        NoSuchMethodException {        return getMappedPropertyLocale(bean, name, null);    }    /**     * Return the value of the (possibly nested) locale-sensitive property     * of the specified name, for the specified bean,     * as a String using the specified pattern.     *     * @param bean Bean whose property is to be extracted     * @param name Possibly nested name of the property to be extracted     * @param pattern The convertion pattern     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception IllegalArgumentException if a nested reference to a     *  property returns null     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getNestedProperty(                                        Object bean,                                     String name,                                     String pattern)                                        throws                                             IllegalAccessException,                                             InvocationTargetException,                                            NoSuchMethodException {        Object value = getPropertyUtils().getNestedProperty(bean, name);        return getLocaleConvertUtils().convert(value, pattern);    }    /**     * Return the value of the (possibly nested) locale-sensitive property     * of the specified name, for the specified bean, as a String using the default     * convertion pattern of the corresponding {@link LocaleConverter}.     *     * @param bean Bean whose property is to be extracted     * @param name Possibly nested name of the property to be extracted     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception IllegalArgumentException if a nested reference to a     *  property returns null     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getNestedProperty(Object bean, String name)                                    throws                                         IllegalAccessException,                                         InvocationTargetException,                                        NoSuchMethodException {        return getNestedProperty(bean, name, null);    }    /**     * Return the value of the specified locale-sensitive property     * of the specified bean, no matter which property reference     * format is used, as a String using the specified convertion pattern.     *     * @param bean Bean whose property is to be extracted     * @param name Possibly indexed and/or nested name of the property     *  to be extracted     * @param pattern The convertion pattern     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getProperty(Object bean, String name, String pattern)                                throws                                     IllegalAccessException,                                     InvocationTargetException,                                    NoSuchMethodException {        return getNestedProperty(bean, name, pattern);    }    /**     * Return the value of the specified locale-sensitive property     * of the specified bean, no matter which property reference     * format is used, as a String using the default     * convertion pattern of the corresponding {@link LocaleConverter}.     *     * @param bean Bean whose property is to be extracted     * @param name Possibly indexed and/or nested name of the property     *  to be extracted     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     * @exception NoSuchMethodException if an accessor method for this     *  propety cannot be found     */    public String getProperty(Object bean, String name)                                throws                                     IllegalAccessException,                                     InvocationTargetException,                                    NoSuchMethodException {        return getNestedProperty(bean, name);    }    /**     * Set the specified locale-sensitive property value, performing type     * conversions as required to conform to the type of the destination property     * using the default convertion pattern of the corresponding {@link LocaleConverter}.     *     * @param bean Bean on which setting is to be performed     * @param name Property name (can be nested/indexed/mapped/combo)     * @param value Value to be set     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     */    public void setProperty(Object bean, String name, Object value)                                throws                                     IllegalAccessException,                                     InvocationTargetException {        setProperty(bean, name, value, null);    }    /**     * Set the specified locale-sensitive property value, performing type     * conversions as required to conform to the type of the destination     * property using the specified convertion pattern.     *     * @param bean Bean on which setting is to be performed     * @param name Property name (can be nested/indexed/mapped/combo)     * @param value Value to be set     * @param pattern The convertion pattern     *     * @exception IllegalAccessException if the caller does not have     *  access to the property accessor method     * @exception InvocationTargetException if the property accessor method     *  throws an exception     */    public void setProperty(                            Object bean,                             String name,                             Object value,                             String pattern)                                throws                                     IllegalAccessException,                                     InvocationTargetException {        // Trace logging (if enabled)        if (log.isTraceEnabled()) {            StringBuffer sb = new StringBuffer("  setProperty(");            sb.append(bean);            sb.append(", ");            sb.append(name);            sb.append(", ");            if (value == null) {                sb.append("<NULL>");            }            else if (value instanceof String) {                sb.append((String) value);            }            else if (value instanceof String[]) {                String values[] = (String[]) value;                sb.append('[');                for (int i = 0; i < values.length; i++) {                    if (i > 0) {                        sb.append(',');                    }                    sb.append(values[i]);                }                sb.append(']');            }            else {                sb.append(value.toString());            }            sb.append(')');            log.trace(sb.toString());        }        Descriptor propInfo = calculate(bean, name);        if (propInfo != null) {            Class type = definePropertyType(propInfo.getTarget(), name, propInfo.getPropName());            if (type != null) {                Object newValue = convert(type, propInfo.getIndex(), value, pattern);                invokeSetter(propInfo.getTarget(), propInfo.getPropName(),                        propInfo.getKey(), propInfo.getIndex(), newValue);            }        }    }    /**     * Calculate the property type.     *     * @param target The bean

⌨️ 快捷键说明

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