org.apache.commons.beanutils.locale

Class LocaleBeanUtils


public class LocaleBeanUtils
extends BeanUtils

Utility methods for populating JavaBeans properties via reflection in a locale-dependent manner.

The implementations for these methods are provided by LocaleBeanUtilsBean. For more details see LocaleBeanUtilsBean.

Authors:
Craig R. McClanahan
Ralph Schaer
Chris Audley
Rey Fran?ois
Gregor Ra?man
Yauheny Mikulski

Nested Class Summary

protected static class
LocaleBeanUtils.Descriptor
Deprecated. moved into LocaleBeanUtils

Field Summary

private static Log
log
All logging goes through this logger

Fields inherited from class org.apache.commons.beanutils.BeanUtils

debug, dummy

Method Summary

protected static LocaleBeanUtils.Descriptor
calculate(Object bean, String name)
Deprecated. moved into LocaleBeanUtilsBean
protected static Object
convert(Class type, int index, Object value)
Convert the specified value to the required type.
protected static Object
convert(Class type, int index, Object value, String pattern)
Convert the specified value to the required type using the specified convertion pattern.
protected static Class
definePropertyType(Object target, String name, String propName)
Calculate the property type.
static boolean
getApplyLocalized()
Gets whether the pattern is localized or not.
static Locale
getDefaultLocale()
Gets the locale used when no locale is passed.
static String
getIndexedProperty(Object bean, String name)
Return the value of the specified locale-sensitive indexed property of the specified bean, as a String using the default convertion pattern of the corresponding LocaleConverter.
static String
getIndexedProperty(Object bean, String name, String pattern)
Return the value of the specified locale-sensitive indexed property of the specified bean, as a String.
static String
getIndexedProperty(Object bean, String name, int index)
Return the value of the specified locale-sensetive indexed property of the specified bean, as a String using the default convertion pattern of the corresponding LocaleConverter.
static String
getIndexedProperty(Object bean, String name, int index, String pattern)
Return the value of the specified locale-sensetive indexed property of the specified bean, as a String using the specified convertion pattern.
static String
getMappedProperty(Object bean, String name)
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 LocaleConverter.
static String
getMappedProperty(Object bean, String name, String key)
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.
static String
getMappedProperty(Object bean, String name, String key, String pattern)
Return the value of the specified mapped locale-sensitive property of the specified bean, as a String using the specified convertion pattern.
static String
getMappedPropertyLocale(Object bean, String name, String pattern)
Return the value of the specified locale-sensitive mapped property of the specified bean, as a String using the specified pattern.
static String
getNestedProperty(Object bean, String name)
Return the value of the (possibly nested) locale-sensitive property of the specified name.
static String
getNestedProperty(Object bean, String name, String pattern)
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.
static String
getProperty(Object bean, String name)
Return the value of the specified locale-sensitive property of the specified bean.
static String
getProperty(Object bean, String name, String pattern)
Return the value of the specified locale-sensitive property of the specified bean.
static String
getSimpleProperty(Object bean, String name)
Return the value of the specified simple locale-sensitive property of the specified bean, converted to a String using the default convertion pattern of the corresponding LocaleConverter.
static String
getSimpleProperty(Object bean, String name, String pattern)
Return the value of the specified simple locale-sensitive property of the specified bean, converted to a String using the specified convertion pattern.
protected static void
invokeSetter(Object target, String propName, String key, int index, Object newValue)
Invoke the setter method.
static void
setApplyLocalized(boolean newApplyLocalized)
Sets whether the pattern is localized or not.
static void
setDefaultLocale(Locale locale)
Sets the locale used when no locale is passed.
static void
setProperty(Object bean, String name, Object value)
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 LocaleConverter.
static void
setProperty(Object bean, String name, Object value, String pattern)
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.

Methods inherited from class org.apache.commons.beanutils.BeanUtils

cloneBean, copyProperties, copyProperty, describe, getArrayProperty, getDebug, getIndexedProperty, getIndexedProperty, getMappedProperty, getMappedProperty, getNestedProperty, getProperty, getSimpleProperty, populate, setDebug, setProperty

Field Details

log

private static Log log
All logging goes through this logger

Method Details

calculate

protected static LocaleBeanUtils.Descriptor calculate(Object bean,
                                                      String name)
            throws IllegalAccessException,
                   InvocationTargetException

Deprecated. moved into LocaleBeanUtilsBean

Resolve any nested expression to get the actual target bean.
Parameters:
bean - The bean
name - The property name

convert

protected static Object convert(Class type,
                                int index,
                                Object value)
Convert the specified value to the required type.

For more details see LocaleBeanUtilsBean


convert

protected static Object convert(Class type,
                                int index,
                                Object value,
                                String pattern)
Convert the specified value to the required type using the specified convertion pattern.

For more details see LocaleBeanUtilsBean


definePropertyType

protected static Class definePropertyType(Object target,
                                          String name,
                                          String propName)
            throws IllegalAccessException,
                   InvocationTargetException
Calculate the property type.

For more details see LocaleBeanUtilsBean


getApplyLocalized

public static boolean getApplyLocalized()
Gets whether the pattern is localized or not.

For more details see LocaleBeanUtilsBean


getDefaultLocale

public static Locale getDefaultLocale()
Gets the locale used when no locale is passed.

For more details see LocaleBeanUtilsBean


getIndexedProperty

public static String getIndexedProperty(Object bean,
                                        String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Overrides:
getIndexedProperty in interface BeanUtils

getIndexedProperty

public static String getIndexedProperty(Object bean,
                                        String name,
                                        String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified locale-sensitive indexed property of the specified bean, as a String.

For more details see LocaleBeanUtilsBean


getIndexedProperty

public static String getIndexedProperty(Object bean,
                                        String name,
                                        int index)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Overrides:
getIndexedProperty in interface BeanUtils

getIndexedProperty

public static String getIndexedProperty(Object bean,
                                        String name,
                                        int index,
                                        String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified locale-sensetive indexed property of the specified bean, as a String using the specified convertion pattern.

For more details see LocaleBeanUtilsBean


getMappedProperty

public static String getMappedProperty(Object bean,
                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Overrides:
getMappedProperty in interface BeanUtils

getMappedProperty

public static String getMappedProperty(Object bean,
                                       String name,
                                       String key)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
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.

For more details see LocaleBeanUtilsBean

Overrides:
getMappedProperty in interface BeanUtils

getMappedProperty

public static String getMappedProperty(Object bean,
                                       String name,
                                       String key,
                                       String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified mapped locale-sensitive property of the specified bean, as a String using the specified convertion pattern.

For more details see LocaleBeanUtilsBean


getMappedPropertyLocale

public static String getMappedPropertyLocale(Object bean,
                                             String name,
                                             String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified locale-sensitive mapped property of the specified bean, as a String using the specified pattern.

For more details see LocaleBeanUtilsBean


getNestedProperty

public static String getNestedProperty(Object bean,
                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the (possibly nested) locale-sensitive property of the specified name.

For more details see LocaleBeanUtilsBean

Overrides:
getNestedProperty in interface BeanUtils

getNestedProperty

public static String getNestedProperty(Object bean,
                                       String name,
                                       String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
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.

For more details see LocaleBeanUtilsBean


getProperty

public static String getProperty(Object bean,
                                 String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified locale-sensitive property of the specified bean.

For more details see LocaleBeanUtilsBean

Overrides:
getProperty in interface BeanUtils

getProperty

public static String getProperty(Object bean,
                                 String name,
                                 String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified locale-sensitive property of the specified bean.

For more details see LocaleBeanUtilsBean


getSimpleProperty

public static String getSimpleProperty(Object bean,
                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Overrides:
getSimpleProperty in interface BeanUtils

getSimpleProperty

public static String getSimpleProperty(Object bean,
                                       String name,
                                       String pattern)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified simple locale-sensitive property of the specified bean, converted to a String using the specified convertion pattern.

For more details see LocaleBeanUtilsBean


invokeSetter

protected static void invokeSetter(Object target,
                                   String propName,
                                   String key,
                                   int index,
                                   Object newValue)
            throws IllegalAccessException,
                   InvocationTargetException
Invoke the setter method.

For more details see LocaleBeanUtilsBean


setApplyLocalized

public static void setApplyLocalized(boolean newApplyLocalized)
Sets whether the pattern is localized or not.

For more details see LocaleBeanUtilsBean


setDefaultLocale

public static void setDefaultLocale(Locale locale)
Sets the locale used when no locale is passed.

For more details see LocaleBeanUtilsBean


setProperty

public static void setProperty(Object bean,
                               String name,
                               Object value)
            throws IllegalAccessException,
                   InvocationTargetException
Overrides:
setProperty in interface BeanUtils

setProperty

public static void setProperty(Object bean,
                               String name,
                               Object value,
                               String pattern)
            throws IllegalAccessException,
                   InvocationTargetException
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.

For more details see LocaleBeanUtilsBean


Copyright (c) 2001-2004 - Apache Software Foundation