|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cc.framework.util.Util
Utility class to compare/sort objects
Constructor Summary | |
private |
Util()
Constructor |
Method Summary | |
static void |
check(java.lang.Object bean,
java.lang.String property,
boolean checked)
checks a property |
static java.lang.Object |
getProperty(java.lang.Object bean,
java.lang.String name)
Return the value of the specified property of the specified bean, no matter which property reference format is used, as a String. |
static java.lang.Class |
getPropertyType(java.lang.Object bean,
java.lang.String name)
Return the Java Class representing the property type of the specified property, or null if there is no such property for the
specified bean. |
static java.lang.Object |
getSafeProperty(java.lang.Object bean,
java.lang.String name)
Return the value of the specified property of the specified bean, no matter which property reference format is used, as a String. |
static boolean |
isValidProperty(java.lang.Object bean,
java.lang.String name)
Checks if the current iteration element has the given property |
static java.lang.Object |
max(java.lang.Comparable a,
java.lang.Comparable b)
Compares to objects for order |
static java.lang.Object |
min(java.lang.Comparable a,
java.lang.Comparable b)
Compares two objects for order |
static java.lang.Object |
min(java.lang.Comparable a,
java.lang.Comparable b,
java.lang.Comparable c)
Compares three objects for order |
static void |
setProperty(java.lang.Object bean,
java.lang.String name,
java.lang.Object value)
Set the specified property value, performing type conversions as required to conform to the type of the destination property. |
static java.lang.Boolean |
toBoolean(java.lang.Object obj)
Converts an object to a boolean if possible |
static java.lang.Boolean |
toBoolean(java.lang.String str)
Parses a string an returns a boolean value. |
static void |
uncheck(java.lang.Object bean,
java.lang.String property)
Unchecks a checked property |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
private Util()
Method Detail |
public static java.lang.Object max(java.lang.Comparable a, java.lang.Comparable b)
a
- the Object1 to be compared.b
- the Object2 to be compared.
public static java.lang.Object min(java.lang.Comparable a, java.lang.Comparable b)
a
- the Object1 to be compared.b
- the Object2 to be compared.
public static java.lang.Object min(java.lang.Comparable a, java.lang.Comparable b, java.lang.Comparable c)
a
- the Object1 to be compared.b
- the Object2 to be compared.c
- the Object3 to be compared.
public static java.lang.Boolean toBoolean(java.lang.Object obj)
obj
- The object to convert
public static java.lang.Boolean toBoolean(java.lang.String str)
str
- The string to parse
public static void uncheck(java.lang.Object bean, java.lang.String property) throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
bean
- the beanproperty
- The check property
java.lang.IllegalAccessException
- Property Setter is not accessible
java.lang.NoSuchMethodException
- Property Setter is not available
java.lang.reflect.InvocationTargetException
- Property Setter could not be calledpublic static void check(java.lang.Object bean, java.lang.String property, boolean checked) throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
bean
- the beanproperty
- The check propertychecked
- check state
java.lang.IllegalAccessException
- Property Setter is not accessible
java.lang.NoSuchMethodException
- Property Setter is not available
java.lang.reflect.InvocationTargetException
- Property Setter could not be calledpublic static java.lang.Class getPropertyType(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
null
if there is no such property for the
specified bean. This method follows the same name resolution rules used
by getPropertyDescriptor()
, so if the last element of a
name reference is indexed, the type of the property itself will be
returned. If the last (or only) element has no property with the
specified name, null
is returned.
bean
- Bean for which a property descriptor is requestedname
- Possibly indexed and/or nested name of the property for which
a property descriptor is requested
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 property cannot be foundpublic static java.lang.Object getProperty(java.lang.Object bean, java.lang.String name) 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
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 property cannot be foundpublic static boolean isValidProperty(java.lang.Object bean, java.lang.String name)
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property to be
extracted
true
if the current bean possesses a matching
propertypublic static java.lang.Object getSafeProperty(java.lang.Object bean, java.lang.String name)
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property to be
extracted
null
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 property value, performing type conversions as required to conform to the type of the destination property.
If the property is read only then the method returns without throwing an exception.
If null
is passed into a property expecting a primitive
value, then this will be converted as if it were a null
string.
WARNING - The logic of this method is customized to
meet the needs of populate()
, and is probably not what
you want for general property copying with type conversion. For that
purpose, check out the copyProperty()
method instead.
WARNING - PLEASE do not modify the behavior of this method without consulting with the Struts developer community. There are some subtleties to its functionality that are not documented in the Javadoc description above, yet are vital to the way that Struts utilizes this method.
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 exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |