|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.beanutils.BeanUtils | +--org.apache.commons.beanutils.locale.LocaleBeanUtils
Utility methods for populating JavaBeans properties via reflection in a locale-dependent manner.
Nested Class Summary | |
protected static class |
LocaleBeanUtils.Descriptor
|
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)
Resolve any nested expression to get the actual target bean. |
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()
getter for applyLocalized (Indicate whether the pattern is localized or not) |
static java.util.Locale |
getDefaultLocale()
getter for defaultLocale |
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, for the specified bean, as a String using the default convertion pattern of the corresponding LocaleConverter . |
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, no matter which property reference format is used, as a String using the default convertion pattern of the corresponding LocaleConverter . |
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, no matter which property reference format is used, as a String using the specified convertion pattern. |
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)
setter for applyLocalized (Indicate whether the pattern is localized or not) |
static void |
setDefaultLocale(java.util.Locale locale)
setter for defaultLocale |
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 |
private static org.apache.commons.logging.Log log
Constructor Detail |
public LocaleBeanUtils()
Method Detail |
public static java.util.Locale getDefaultLocale()
public static void setDefaultLocale(java.util.Locale locale)
public static boolean getApplyLocalized()
public static void setApplyLocalized(boolean newApplyLocalized)
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
IllegalArgumentException
will be
thrown.
bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extractedpattern
- The convertion pattern
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
. 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.
bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extracted
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
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 convertion pattern
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
LocaleConverter
.
The index is specified as a method parameter and
must *not* be included in the property name expression
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 extracted
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedpattern
- The convertion pattern
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getSimpleProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
LocaleConverter
.
bean
- Bean whose property is to be extractedname
- Name of the property to be extracted
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
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 convertion pattern
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
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 extracted
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
IllegalArgumentException
will be
thrown.
bean
- Bean whose property is to be extractedname
- propertyname(index)
of the property value
to be extractedpattern
- The convertion pattern
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getMappedProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.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.
bean
- Bean whose property is to be extractedname
- propertyname(index)
of the property value
to be extracted
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extractedpattern
- The convertion pattern
java.lang.IllegalAccessException
- if the caller does not have
access to the property accessor method
java.lang.IllegalArgumentException
- if a nested reference to a
property returns null
java.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exception
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getNestedProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
LocaleConverter
.
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extracted
java.lang.IllegalAccessException
- if the caller does not have
access to the property accessor method
java.lang.IllegalArgumentException
- if a nested reference to a
property returns null
java.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exception
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic 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
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extractedpattern
- The convertion pattern
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
LocaleConverter
.
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extracted
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
java.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static void setProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
LocaleConverter
.
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be set
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 exceptionpublic 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
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be setpattern
- The convertion pattern
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 exceptionprotected 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
target
- The beanname
- The property namepropName
- The Simple name of target property
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 exceptionprotected static java.lang.Object convert(java.lang.Class type, int index, java.lang.Object value, java.lang.String pattern)
type
- The Java type of target propertyindex
- The indexed subscript value (if any)value
- The value to be convertedpattern
- The convertion patternprotected static java.lang.Object convert(java.lang.Class type, int index, java.lang.Object value)
type
- The Java type of target propertyindex
- The indexed subscript value (if any)value
- The value to be convertedprotected 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
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 set
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 exceptionprotected static LocaleBeanUtils.Descriptor calculate(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
bean
- The beanname
- The property name
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |