Package org.jivesoftware.util
Class BeanUtils
java.lang.Object
org.jivesoftware.util.BeanUtils
A utility class that provides methods that are useful for dealing with
Java Beans.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The date format recognized for parsing/formatting dates. -
Method Summary
Modifier and TypeMethodDescriptiongetProperties
(Object bean) Gets the properties from a Java Bean and returns them in a Map of String name/value pairs.static PropertyDescriptor[]
getPropertyDescriptors
(Class beanClass) Returns the PropertyDescriptor array for the specified Java Bean Class.static void
setProperties
(Object bean, Map<String, String> properties) Sets the properties of a Java Bean based on the String name/value pairs in the specified Map.static void
setProperties
(Object bean, javax.servlet.http.HttpServletRequest request) Sets the properties of a Java Bean based on the request's properties.
-
Field Details
-
DATE_FORMAT
The date format recognized for parsing/formatting dates.- See Also:
-
-
Method Details
-
setProperties
Sets the properties of a Java Bean based on the String name/value pairs in the specified Map. Because this method has to know how to convert a String value into the correct type for the bean, only a few bean property types are supported. They are: String, boolean, int, long, float, double, Color, and Class.If key/value pairs exist in the Map that don't correspond to properties of the bean, they will be ignored.
- Parameters:
bean
- the JavaBean to set properties on.properties
- String name/value pairs of the properties to set.
-
setProperties
Sets the properties of a Java Bean based on the request's properties. Because this method has to know how to convert a String value into the correct type for the bean, only a few bean property types are supported. They are: String, boolean, int, long, float, double, Color, and Class.If key/value pairs exist in the Map that don't correspond to properties of the bean, they will be ignored.
- Parameters:
bean
- the JavaBean to set properties on.request
- the HTTP request.
-
getProperties
Gets the properties from a Java Bean and returns them in a Map of String name/value pairs. Because this method has to know how to convert a bean property into a String value, only a few bean property types are supported. They are: String, boolean, int, long, float, double, Color, and Class.- Parameters:
bean
- a Java Bean to get properties from.- Returns:
- a Map of all properties as String name/value pairs.
-
getPropertyDescriptors
public static PropertyDescriptor[] getPropertyDescriptors(Class beanClass) throws IntrospectionException Returns the PropertyDescriptor array for the specified Java Bean Class. The method also does a special check to see of the bean has a BeanInfo class that extends the JiveBeanInfo class. If yes, we load the PropertyDescriptor array directly from that BeanInfo class rather than through the Introspector in order to preserve the desired ordering of properties.- Parameters:
beanClass
- the Class of the JavaBean.- Returns:
- the PropertyDescriptor array for the specified Java Bean Class.
- Throws:
IntrospectionException
- if there were problems accessing the descriptor
-