public class LocaleBeanUtilsBean extends BeanUtilsBean
Utility methods for populating JavaBeans properties via reflection in a locale-dependent manner.
Modifier and Type | Class and Description |
---|---|
protected class |
LocaleBeanUtilsBean.Descriptor
Deprecated.
Property name expressions are now processed by
the configured
Resolver implementation and this class
is no longer used by BeanUtils. |
Constructor and Description |
---|
LocaleBeanUtilsBean()
Construct instance with standard conversion bean
|
LocaleBeanUtilsBean(LocaleConvertUtilsBean localeConvertUtils)
Construct instance that uses given locale conversion
|
LocaleBeanUtilsBean(LocaleConvertUtilsBean localeConvertUtils,
ConvertUtilsBean convertUtilsBean,
PropertyUtilsBean propertyUtilsBean)
Construct instance that uses given locale conversion
|
Modifier and Type | Method and Description |
---|---|
protected LocaleBeanUtilsBean.Descriptor |
calculate(Object bean,
String name)
Deprecated.
Property name expressions are now processed by
the configured
Resolver implementation and this method
is no longer used by BeanUtils. |
protected Object |
convert(Class<?> type,
int index,
Object value)
Convert the specified value to the required type.
|
protected Object |
convert(Class<?> type,
int index,
Object value,
String pattern)
Convert the specified value to the required type using the
specified conversion pattern.
|
protected Class<?> |
definePropertyType(Object target,
String name,
String propName)
Calculate the property type.
|
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)
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 |
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,
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 |
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)
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 |
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 |
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 |
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 |
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 . |
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.
|
protected void |
invokeSetter(Object target,
String propName,
String key,
int index,
Object newValue)
Invoke the setter method.
|
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)
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 . |
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.
|
cloneBean, convert, copyProperties, copyProperty, describe, getArrayProperty, getConvertUtils, getInstance, getPropertyUtils, initCause, populate, setInstance
public LocaleBeanUtilsBean()
public LocaleBeanUtilsBean(LocaleConvertUtilsBean localeConvertUtils, ConvertUtilsBean convertUtilsBean, PropertyUtilsBean propertyUtilsBean)
localeConvertUtils
- use this localeConvertUtils
to perform
conversionsconvertUtilsBean
- use this for standard conversionspropertyUtilsBean
- use this for property conversionspublic LocaleBeanUtilsBean(LocaleConvertUtilsBean localeConvertUtils)
localeConvertUtils
- use this localeConvertUtils
to perform
conversionspublic static LocaleBeanUtilsBean getLocaleBeanUtilsInstance()
public static void setInstance(LocaleBeanUtilsBean newInstance)
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.newInstance
- a new singleton instancepublic LocaleConvertUtilsBean getLocaleConvertUtils()
public Locale getDefaultLocale()
public void setDefaultLocale(Locale locale)
locale
- the default localepublic boolean getApplyLocalized()
true
if pattern is localized,
otherwise false
public void setApplyLocalized(boolean newApplyLocalized)
newApplyLocalized
- true
if pattern is localized,
otherwise false
public String getIndexedProperty(Object bean, String name, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
IllegalArgumentException
will be
thrown.bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic String getIndexedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
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.getIndexedProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic String getIndexedProperty(Object bean, String name, int index, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Simple property name of the property value to be extractedindex
- Index of the property value to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic String getIndexedProperty(Object bean, String name, int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
LocaleConverter
.
The index is specified as a method parameter and
must *not* be included in the property name expressiongetIndexedProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- Simple property name of the property value to be extractedindex
- Index of the property value to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic String getSimpleProperty(Object bean, String name, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getSimpleProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
LocaleConverter
.getSimpleProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getMappedProperty(Object bean, String name, String key, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Simple property name of the property value to be extractedkey
- Lookup key of the property value to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getMappedProperty(Object bean, String name, String key) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
getMappedProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- Simple property name of the property value to be extractedkey
- Lookup key of the property value to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getMappedPropertyLocale(Object bean, String name, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
IllegalArgumentException
will be
thrown.bean
- Bean whose property is to be extractedname
- propertyname(index)
of the property value
to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getMappedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
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.getMappedProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- propertyname(index)
of the property value
to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getNestedProperty(Object bean, String name, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodIllegalArgumentException
- if a nested reference to a
property returns nullInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getNestedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
LocaleConverter
.getNestedProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodIllegalArgumentException
- if a nested reference to a
property returns nullInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getProperty(Object bean, String name, String pattern) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extractedpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic String getProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
LocaleConverter
.getProperty
in class BeanUtilsBean
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extractedIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionNoSuchMethodException
- if an accessor method for this
property cannot be foundpublic void setProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException
LocaleConverter
.setProperty
in class BeanUtilsBean
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be setIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionpublic void setProperty(Object bean, String name, Object value, String pattern) throws IllegalAccessException, InvocationTargetException
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be setpattern
- The conversion patternIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionprotected Class<?> definePropertyType(Object target, String name, String propName) throws IllegalAccessException, InvocationTargetException
target
- The beanname
- The property namepropName
- The Simple name of target propertyIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionprotected Object convert(Class<?> type, int index, Object value, String pattern)
type
- The Java type of target propertyindex
- The indexed subscript value (if any)value
- The value to be convertedpattern
- The conversion patternprotected Object convert(Class<?> type, int index, Object value)
type
- The Java type of target propertyindex
- The indexed subscript value (if any)value
- The value to be convertedprotected void invokeSetter(Object target, String propName, String key, int index, Object newValue) throws IllegalAccessException, InvocationTargetException
target
- The beanpropName
- The Simple name of target propertykey
- The Mapped key value (if any)index
- The indexed subscript value (if any)newValue
- The value to be setIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exception@Deprecated protected LocaleBeanUtilsBean.Descriptor calculate(Object bean, String name) throws IllegalAccessException, InvocationTargetException
Resolver
implementation and this method
is no longer used by BeanUtils.bean
- The beanname
- The property nameIllegalAccessException
- if the caller does not have
access to the property accessor methodInvocationTargetException
- if the property accessor method
throws an exceptionCopyright © 2000–2016 The Apache Software Foundation. All rights reserved.