Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class BeanUtils

java.lang.Object
  extended by com.jivesoftware.util.BeanUtils

public class BeanUtils
extends java.lang.Object

A utility class that provides methods that are useful for dealing with Java Beans.


Field Summary
static java.lang.String DATE_FORMAT
          The date format recognized for parsing/formattig dates.
 
Method Summary
static java.lang.Object decode(java.lang.Class type, java.lang.String value)
          Decodes a String into an object of the specified type.
static java.beans.BeanDescriptor getBeanDescriptor(java.lang.Class beanClass)
          Returns the BeanDescriptor array for the specified Java Bean Class.
static java.util.Map getInfoBeanProperties(java.lang.Object bean)
          Gets the properties from a Java Bean and returns them in a Map of String name/value pairs.
static java.util.Map getProperties(java.lang.Object bean)
          Gets the properties from a Java Bean and returns them in a Map of String name/value pairs.
static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Class beanClass)
          Returns the PropertyDescriptor array for the specified Java Bean Class.
static void setProperties(java.lang.Object bean, java.util.Map properties)
          Sets the properties of a Java Bean based on the String name/value pairs in the specified Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
The date format recognized for parsing/formattig dates.

See Also:
Constant Field Values
Method Detail

setProperties

public static void setProperties(java.lang.Object bean,
                                 java.util.Map properties)
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.

getProperties

public static java.util.Map getProperties(java.lang.Object bean)
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.

getInfoBeanProperties

public static java.util.Map getInfoBeanProperties(java.lang.Object bean)
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 java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Class beanClass)
                                                              throws java.beans.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:
java.beans.IntrospectionException

getBeanDescriptor

public static java.beans.BeanDescriptor getBeanDescriptor(java.lang.Class beanClass)
                                                   throws java.beans.IntrospectionException
Returns the BeanDescriptor 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:
java.beans.IntrospectionException

decode

public static java.lang.Object decode(java.lang.Class type,
                                      java.lang.String value)
                               throws java.lang.Exception
Decodes a String into an object of the specified type. If the object type is not supported, null will be returned. If the type is not a String and value is null or spaces, null will be returned.

Parameters:
type - the type of the property.
value - the encode String value to decode.
Returns:
the String value decoded into the specified type.
Throws:
java.lang.Exception

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.