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
.
Modifier and Type | Class and Description |
---|---|
protected static class |
LocaleBeanUtils.Descriptor
Deprecated.
moved into
LocaleBeanUtils |
Constructor and Description |
---|
LocaleBeanUtils() |
Modifier and Type | Method and Description |
---|---|
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 conversion 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 conversion 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 conversion 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 conversion 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
conversion 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 conversion 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
conversion 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
conversion 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 conversion 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 conversion pattern.
|
cloneBean, copyProperties, copyProperty, createCache, describe, getArrayProperty, getCacheFast, getDebug, initCause, populate, setCacheFast, setDebug
public static java.util.Locale getDefaultLocale()
Gets the locale used when no locale is passed.
For more details see LocaleBeanUtilsBean
LocaleBeanUtilsBean.getDefaultLocale()
public static void setDefaultLocale(java.util.Locale locale)
Sets the locale used when no locale is passed.
For more details see LocaleBeanUtilsBean
locale
- the default localeLocaleBeanUtilsBean.setDefaultLocale(Locale)
public static boolean getApplyLocalized()
Gets whether the pattern is localized or not.
For more details see LocaleBeanUtilsBean
true
if pattern is localized,
otherwise false
LocaleBeanUtilsBean.getApplyLocalized()
public static void setApplyLocalized(boolean newApplyLocalized)
Sets whether the pattern is localized or not.
For more details see LocaleBeanUtilsBean
newApplyLocalized
- true
if pattern is localized,
otherwise false
LocaleBeanUtilsBean.setApplyLocalized(boolean)
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
bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extractedpattern
- The conversion patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getIndexedProperty(Object, String, String)
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
LocaleConverter
.
For more details see LocaleBeanUtilsBean
bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getIndexedProperty(Object, String)
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 conversion pattern.
For more details see LocaleBeanUtilsBean
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 patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getIndexedProperty(Object, String, int, String)
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 conversion pattern of
the corresponding LocaleConverter
.
For more details see LocaleBeanUtilsBean
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 extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getIndexedProperty(Object, String, int)
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 conversion pattern.
For more details see LocaleBeanUtilsBean
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedpattern
- The conversion patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getSimpleProperty(Object, String, String)
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
conversion pattern of the corresponding LocaleConverter
.
For more details see LocaleBeanUtilsBean
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getSimpleProperty(Object, String)
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 conversion pattern.
For more details see LocaleBeanUtilsBean
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 patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getMappedProperty(Object, String, String, String)
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
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 extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getMappedProperty(Object, String, String)
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
bean
- Bean whose property is to be extractedname
- propertyname(index)
of the property value
to be extractedpattern
- The conversion patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getMappedPropertyLocale(Object, String, String)
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
conversion pattern of the corresponding LocaleConverter
.
For more details see LocaleBeanUtilsBean
bean
- Bean whose property is to be extractedname
- propertyname(index)
of the property value
to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getMappedProperty(Object, String)
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
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extractedpattern
- The conversion patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getNestedProperty(Object, String, String)
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
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getNestedProperty(Object, String)
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
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extractedpattern
- The conversion patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getProperty(Object, String, String)
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
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundLocaleBeanUtilsBean.getProperty(Object, String)
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 conversion pattern of the corresponding LocaleConverter
.
For more details see LocaleBeanUtilsBean
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be setjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionLocaleBeanUtilsBean.setProperty(Object, String, Object)
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 conversion pattern.
For more details see LocaleBeanUtilsBean
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be setpattern
- The conversion patternjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionLocaleBeanUtilsBean.setProperty(Object, String, Object, String)
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
target
- The beanname
- The property namepropName
- The Simple name of target propertyjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionLocaleBeanUtilsBean.definePropertyType(Object, String, String)
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 conversion pattern.
For more details see LocaleBeanUtilsBean
type
- The Java type of target propertyindex
- The indexed subscript value (if any)value
- The value to be convertedpattern
- The conversion patternLocaleBeanUtilsBean.convert(Class, int, Object, String)
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
type
- The Java type of target propertyindex
- The indexed subscript value (if any)value
- The value to be convertedLocaleBeanUtilsBean.convert(Class, int, Object)
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
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 setjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionLocaleBeanUtilsBean.invokeSetter(Object, String, String, int, Object)
@Deprecated protected static LocaleBeanUtils.Descriptor calculate(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
LocaleBeanUtilsBean
bean
- The beanname
- The property namejava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionCopyright (c) 2000-2008 - Apache Software Foundation