public class

LocaleBeanUtilsBean

extends BeanUtilsBean
java.lang.Object
   ↳ org.apache.commons.beanutils.BeanUtilsBean
     ↳ org.apache.commons.beanutils.locale.LocaleBeanUtilsBean

Class Overview

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

Summary

Nested Classes
class LocaleBeanUtilsBean.Descriptor This class is deprecated. Property name expressions are now processed by the configured Resolver implementation and this class is no longer used by BeanUtils.  
Public Constructors
LocaleBeanUtilsBean()
Construct instance with standard conversion bean
LocaleBeanUtilsBean(LocaleConvertUtilsBean localeConvertUtils, ConvertUtilsBean convertUtilsBean, PropertyUtilsBean propertyUtilsBean)
Construct instance that uses given locale conversion
LocaleBeanUtilsBean(LocaleConvertUtilsBean localeConvertUtils)
Construct instance that uses given locale conversion
Public Methods
boolean getApplyLocalized()
Is the pattern to be applied localized (Indicate whether the pattern is localized or not)
Locale getDefaultLocale()
Gets the default Locale
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 conversion pattern of the corresponding LocaleConverter.
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 conversion pattern of the corresponding LocaleConverter.
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 conversion pattern.
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 LocaleBeanUtilsBean getLocaleBeanUtilsInstance()
Gets singleton instance
LocaleConvertUtilsBean getLocaleConvertUtils()
Gets the bean instance used for conversions
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 conversion pattern.
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
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 conversion pattern of the corresponding LocaleConverter.
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.
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.
String getNestedProperty(Object bean, String name)
Return the value of the (possibly nested) locale-sensitive property of the specified name, for the specified bean, as a String using the default conversion pattern of the corresponding LocaleConverter.
String getProperty(Object bean, String name, String 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 specified conversion pattern.
String getProperty(Object bean, String name)
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 conversion pattern of the corresponding LocaleConverter.
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 conversion pattern.
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 conversion pattern of the corresponding LocaleConverter.
void setApplyLocalized(boolean newApplyLocalized)
Sets whether the pattern is applied localized (Indicate whether the pattern is localized or not)
void setDefaultLocale(Locale locale)
Sets the default Locale.
static void setInstance(LocaleBeanUtilsBean newInstance)
Sets the instance which provides the functionality for LocaleBeanUtils.
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 conversion pattern.
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 conversion pattern of the corresponding LocaleConverter.
Protected Methods
LocaleBeanUtilsBean.Descriptor calculate(Object bean, String name)
This method is deprecated. Property name expressions are now processed by the configured Resolver implementation and this method is no longer used by BeanUtils.
Object convert(Class type, int index, Object value, String pattern)
Convert the specified value to the required type using the specified conversion pattern.
Object convert(Class type, int index, Object value)
Convert the specified value to the required type.
Class definePropertyType(Object target, String name, String propName)
Calculate the property type.
void invokeSetter(Object target, String propName, String key, int index, Object newValue)
Invoke the setter method.
[Expand]
Inherited Methods
From class org.apache.commons.beanutils.BeanUtilsBean
From class java.lang.Object

Public Constructors

public LocaleBeanUtilsBean ()

Construct instance with standard conversion bean

public LocaleBeanUtilsBean (LocaleConvertUtilsBean localeConvertUtils, ConvertUtilsBean convertUtilsBean, PropertyUtilsBean propertyUtilsBean)

Construct instance that uses given locale conversion

Parameters
localeConvertUtils use this localeConvertUtils to perform conversions
convertUtilsBean use this for standard conversions
propertyUtilsBean use this for property conversions

public LocaleBeanUtilsBean (LocaleConvertUtilsBean localeConvertUtils)

Construct instance that uses given locale conversion

Parameters
localeConvertUtils use this localeConvertUtils to perform conversions

Public Methods

public boolean getApplyLocalized ()

Is the pattern to be applied localized (Indicate whether the pattern is localized or not)

Returns
  • true if pattern is localized, otherwise false

public Locale getDefaultLocale ()

Gets the default Locale

Returns
  • the default locale

public 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 conversion pattern of the corresponding LocaleConverter. The zero-relative index of the required value must be included (in square brackets) as a suffix to the property name, or IllegalArgumentException will be thrown.

Parameters
bean Bean whose property is to be extracted
name propertyname[index] of the property value to be extracted
Returns
  • The indexed property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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 conversion pattern of the corresponding LocaleConverter. The index is specified as a method parameter and must *not* be included in the property name expression

Parameters
bean Bean whose property is to be extracted
name Simple property name of the property value to be extracted
index Index of the property value to be extracted
Returns
  • The indexed property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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 conversion pattern. The index is specified as a method parameter and must *not* be included in the property name expression

Parameters
bean Bean whose property is to be extracted
name Simple property name of the property value to be extracted
index Index of the property value to be extracted
pattern The conversion pattern
Returns
  • The indexed property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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. The zero-relative index of the required value must be included (in square brackets) as a suffix to the property name, or IllegalArgumentException will be thrown.

Parameters
bean Bean whose property is to be extracted
name propertyname[index] of the property value to be extracted
pattern The conversion pattern
Returns
  • The indexed property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public static LocaleBeanUtilsBean getLocaleBeanUtilsInstance ()

Gets singleton instance

Returns
  • the singleton instance

public LocaleConvertUtilsBean getLocaleConvertUtils ()

Gets the bean instance used for conversions

Returns
  • the locale converter bean instance

public 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 conversion pattern. The key is specified as a method parameter and must *not* be included in the property name expression.

Parameters
bean Bean whose property is to be extracted
name Simple property name of the property value to be extracted
key Lookup key of the property value to be extracted
pattern The conversion pattern
Returns
  • The mapped property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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

Parameters
bean Bean whose property is to be extracted
name Simple property name of the property value to be extracted
key Lookup key of the property value to be extracted
Returns
  • The mapped property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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 conversion pattern of the corresponding LocaleConverter. The String-valued key of the required value must be included (in parentheses) as a suffix to the property name, or IllegalArgumentException will be thrown.

Parameters
bean Bean whose property is to be extracted
name propertyname(index) of the property value to be extracted
Returns
  • The mapped property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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. The String-valued key of the required value must be included (in parentheses) as a suffix to the property name, or IllegalArgumentException will be thrown.

Parameters
bean Bean whose property is to be extracted
name propertyname(index) of the property value to be extracted
pattern The conversion pattern
Returns
  • The mapped property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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.

Parameters
bean Bean whose property is to be extracted
name Possibly nested name of the property to be extracted
pattern The conversion pattern
Returns
  • The nested property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
IllegalArgumentException if a nested reference to a property returns null
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public String getNestedProperty (Object bean, String name)

Return the value of the (possibly nested) locale-sensitive property of the specified name, for the specified bean, as a String using the default conversion pattern of the corresponding LocaleConverter.

Parameters
bean Bean whose property is to be extracted
name Possibly nested name of the property to be extracted
Returns
  • The nested property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
IllegalArgumentException if a nested reference to a property returns null
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public String getProperty (Object bean, String name, String 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 specified conversion pattern.

Parameters
bean Bean whose property is to be extracted
name Possibly indexed and/or nested name of the property to be extracted
pattern The conversion pattern
Returns
  • The nested property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public String getProperty (Object bean, String name)

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 conversion pattern of the corresponding LocaleConverter.

Parameters
bean Bean whose property is to be extracted
name Possibly indexed and/or nested name of the property to be extracted
Returns
  • The property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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 conversion pattern.

Parameters
bean Bean whose property is to be extracted
name Name of the property to be extracted
pattern The conversion pattern
Returns
  • The property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public 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 conversion pattern of the corresponding LocaleConverter.

Parameters
bean Bean whose property is to be extracted
name Name of the property to be extracted
Returns
  • The property's value, converted to a String
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception
NoSuchMethodException if an accessor method for this propety cannot be found

public void setApplyLocalized (boolean newApplyLocalized)

Sets whether the pattern is applied localized (Indicate whether the pattern is localized or not)

Parameters
newApplyLocalized true if pattern is localized, otherwise false

public void setDefaultLocale (Locale locale)

Sets the default Locale.

Parameters
locale the default locale

public static void setInstance (LocaleBeanUtilsBean newInstance)

Sets the instance which provides the functionality for LocaleBeanUtils. This is a pseudo-singleton - an single instance is provided per (thread) context classloader. This mechanism provides isolation for web apps deployed in the same container.

Parameters
newInstance a new singleton instance

public 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 conversion pattern.

Parameters
bean Bean on which setting is to be performed
name Property name (can be nested/indexed/mapped/combo)
value Value to be set
pattern The conversion pattern
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception

public 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 conversion pattern of the corresponding LocaleConverter.

Parameters
bean Bean on which setting is to be performed
name Property name (can be nested/indexed/mapped/combo)
value Value to be set
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception

Protected Methods

protected LocaleBeanUtilsBean.Descriptor calculate (Object bean, String name)

This method is deprecated.
Property name expressions are now processed by the configured Resolver implementation and this method is no longer used by BeanUtils.

Resolve any nested expression to get the actual target property.

Parameters
bean The bean
name The property name
Returns
  • The property's descriptor
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception

protected Object convert (Class type, int index, Object value, String pattern)

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

Parameters
type The Java type of target property
index The indexed subscript value (if any)
value The value to be converted
pattern The conversion pattern
Returns
  • The converted value

protected Object convert (Class type, int index, Object value)

Convert the specified value to the required type.

Parameters
type The Java type of target property
index The indexed subscript value (if any)
value The value to be converted
Returns
  • The converted value

protected Class definePropertyType (Object target, String name, String propName)

Calculate the property type.

Parameters
target The bean
name The property name
propName The Simple name of target property
Returns
  • The property's type
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception

protected void invokeSetter (Object target, String propName, String key, int index, Object newValue)

Invoke the setter method.

Parameters
target The bean
propName The Simple name of target property
key The Mapped key value (if any)
index The indexed subscript value (if any)
newValue The value to be set
Throws
IllegalAccessException if the caller does not have access to the property accessor method
InvocationTargetException if the property accessor method throws an exception