org.apache.commons.beanutils.locale
Class LocaleBeanUtils

java.lang.Object
  |
  +--org.apache.commons.beanutils.BeanUtils
        |
        +--org.apache.commons.beanutils.locale.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.

Author:
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 org.apache.commons.logging.Log log
          All logging goes through this logger
 
Fields inherited from class org.apache.commons.beanutils.BeanUtils
 
Constructor Summary
LocaleBeanUtils()
           
 
Method Summary
protected static LocaleBeanUtils.Descriptor calculate(java.lang.Object bean, java.lang.String name)
          Deprecated. moved into LocaleBeanUtilsBean
protected static java.lang.Object convert(java.lang.Class type, int index, java.lang.Object value)
          Convert the specified value to the required type.
protected static java.lang.Object convert(java.lang.Class type, int index, java.lang.Object value, java.lang.String pattern)
          Convert the specified value to the required type using the specified convertion pattern.
protected static java.lang.Class definePropertyType(java.lang.Object target, java.lang.String name, java.lang.String propName)
          Calculate the property type.
static boolean getApplyLocalized()
          Gets whether the pattern is localized or not.
static java.util.Locale getDefaultLocale()
          Gets the locale used when no locale is passed.
static java.lang.String getIndexedProperty(java.lang.Object bean, java.lang.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 java.lang.String getIndexedProperty(java.lang.Object bean, java.lang.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 java.lang.String getIndexedProperty(java.lang.Object bean, java.lang.String name, int index, java.lang.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 java.lang.String getIndexedProperty(java.lang.Object bean, java.lang.String name, java.lang.String pattern)
          Return the value of the specified locale-sensitive indexed property of the specified bean, as a String.
static java.lang.String getMappedProperty(java.lang.Object bean, java.lang.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 java.lang.String getMappedProperty(java.lang.Object bean, java.lang.String name, java.lang.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 java.lang.String getMappedProperty(java.lang.Object bean, java.lang.String name, java.lang.String key, java.lang.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 java.lang.String getMappedPropertyLocale(java.lang.Object bean, java.lang.String name, java.lang.String pattern)
          Return the value of the specified locale-sensitive mapped property of the specified bean, as a String using the specified pattern.
static java.lang.String getNestedProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the (possibly nested) locale-sensitive property of the specified name.
static java.lang.String getNestedProperty(java.lang.Object bean, java.lang.String name, java.lang.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 java.lang.String getProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the specified locale-sensitive property of the specified bean.
static java.lang.String getProperty(java.lang.Object bean, java.lang.String name, java.lang.String pattern)
          Return the value of the specified locale-sensitive property of the specified bean.
static java.lang.String getSimpleProperty(java.lang.Object bean, java.lang.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 java.lang.String getSimpleProperty(java.lang.Object bean, java.lang.String name, java.lang.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(java.lang.Object target, java.lang.String propName, java.lang.String key, int index, java.lang.Object newValue)
          Invoke the setter method.
static void setApplyLocalized(boolean newApplyLocalized)
          Sets whether the pattern is localized or not.
static void setDefaultLocale(java.util.Locale locale)
          Sets the locale used when no locale is passed.
static void setProperty(java.lang.Object bean, java.lang.String name, java.lang.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(java.lang.Object bean, java.lang.String name, java.lang.Object value, java.lang.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, populate, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
All logging goes through this logger

Constructor Detail

LocaleBeanUtils

public LocaleBeanUtils()
Method Detail

getDefaultLocale

public static java.util.Locale getDefaultLocale()

Gets the locale used when no locale is passed.

For more details see LocaleBeanUtilsBean

See Also:
LocaleBeanUtilsBean.getDefaultLocale()

setDefaultLocale

public static void setDefaultLocale(java.util.Locale locale)

Sets the locale used when no locale is passed.

For more details see LocaleBeanUtilsBean

See Also:
LocaleBeanUtilsBean.setDefaultLocale(Locale)

getApplyLocalized

public static boolean getApplyLocalized()

Gets whether the pattern is localized or not.

For more details see LocaleBeanUtilsBean

See Also:
LocaleBeanUtilsBean.getApplyLocalized()

setApplyLocalized

public static void setApplyLocalized(boolean newApplyLocalized)

Sets whether the pattern is localized or not.

For more details see LocaleBeanUtilsBean

See Also:
LocaleBeanUtilsBean.setApplyLocalized(boolean)

getIndexedProperty

public static java.lang.String getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name,
                                                  java.lang.String pattern)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.NoSuchMethodException

Return the value of the specified locale-sensitive indexed property of the specified bean, as a String.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getIndexedProperty(Object, String, String)

getIndexedProperty

public static java.lang.String getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.NoSuchMethodException
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.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getIndexedProperty(Object, String)

getIndexedProperty

public static java.lang.String getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name,
                                                  int index,
                                                  java.lang.String pattern)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getIndexedProperty(Object, String, int, String)

getIndexedProperty

public static java.lang.String getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name,
                                                  int index)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.NoSuchMethodException

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.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getIndexedProperty(Object, String, int)

getSimpleProperty

public static java.lang.String getSimpleProperty(java.lang.Object bean,
                                                 java.lang.String name,
                                                 java.lang.String pattern)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getSimpleProperty(Object, String, String)

getSimpleProperty

public static java.lang.String getSimpleProperty(java.lang.Object bean,
                                                 java.lang.String name)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

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.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getSimpleProperty(Object, String)

getMappedProperty

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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getMappedProperty(Object, String, String, String)

getMappedProperty

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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getMappedProperty(Object, String, String)

getMappedPropertyLocale

public static java.lang.String getMappedPropertyLocale(java.lang.Object bean,
                                                       java.lang.String name,
                                                       java.lang.String pattern)
                                                throws java.lang.IllegalAccessException,
                                                       java.lang.reflect.InvocationTargetException,
                                                       java.lang.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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getMappedPropertyLocale(Object, String, String)

getMappedProperty

public static java.lang.String getMappedProperty(java.lang.Object bean,
                                                 java.lang.String name)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

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.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getMappedProperty(Object, String)

getNestedProperty

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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getNestedProperty(Object, String, String)

getNestedProperty

public static java.lang.String getNestedProperty(java.lang.Object bean,
                                                 java.lang.String name)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

Return the value of the (possibly nested) locale-sensitive property of the specified name.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getNestedProperty(Object, String)

getProperty

public static java.lang.String getProperty(java.lang.Object bean,
                                           java.lang.String name,
                                           java.lang.String pattern)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.reflect.InvocationTargetException,
                                           java.lang.NoSuchMethodException

Return the value of the specified locale-sensitive property of the specified bean.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getProperty(Object, String, String)

getProperty

public static java.lang.String getProperty(java.lang.Object bean,
                                           java.lang.String name)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.reflect.InvocationTargetException,
                                           java.lang.NoSuchMethodException

Return the value of the specified locale-sensitive property of the specified bean.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
LocaleBeanUtilsBean.getProperty(Object, String)

setProperty

public static void setProperty(java.lang.Object bean,
                               java.lang.String name,
                               java.lang.Object value)
                        throws java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException

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.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
See Also:
LocaleBeanUtilsBean.setProperty(Object, String, Object)

setProperty

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

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
See Also:
LocaleBeanUtilsBean.setProperty(Object, String, Object, String)

definePropertyType

protected static java.lang.Class definePropertyType(java.lang.Object target,
                                                    java.lang.String name,
                                                    java.lang.String propName)
                                             throws java.lang.IllegalAccessException,
                                                    java.lang.reflect.InvocationTargetException

Calculate the property type.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
See Also:
LocaleBeanUtilsBean.definePropertyType(Object, String, String)

convert

protected static java.lang.Object convert(java.lang.Class type,
                                          int index,
                                          java.lang.Object value,
                                          java.lang.String pattern)

Convert the specified value to the required type using the specified convertion pattern.

For more details see LocaleBeanUtilsBean

See Also:
LocaleBeanUtilsBean.convert(Class, int, Object, String)

convert

protected static java.lang.Object convert(java.lang.Class type,
                                          int index,
                                          java.lang.Object value)

Convert the specified value to the required type.

For more details see LocaleBeanUtilsBean

See Also:
LocaleBeanUtilsBean.convert(Class, int, Object)

invokeSetter

protected static void invokeSetter(java.lang.Object target,
                                   java.lang.String propName,
                                   java.lang.String key,
                                   int index,
                                   java.lang.Object newValue)
                            throws java.lang.IllegalAccessException,
                                   java.lang.reflect.InvocationTargetException

Invoke the setter method.

For more details see LocaleBeanUtilsBean

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
See Also:
LocaleBeanUtilsBean.invokeSetter(Object, String, String, int, Object)

calculate

protected static LocaleBeanUtils.Descriptor calculate(java.lang.Object bean,
                                                      java.lang.String name)
                                               throws java.lang.IllegalAccessException,
                                                      java.lang.reflect.InvocationTargetException
Deprecated. moved into LocaleBeanUtilsBean

Resolve any nested expression to get the actual target bean.

Parameters:
bean - The bean
name - The property name
Throws:
java.lang.IllegalAccessException - if the caller does not have access to the property accessor method
java.lang.reflect.InvocationTargetException - if the property accessor method throws an exception


Copyright (c) 2001-2004 - Apache Software Foundation