Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-02


oracle.stellent.wcm.common.utils
Class BeanUtil

java.lang.Object
  extended by oracle.stellent.wcm.common.utils.BeanUtil


public abstract class BeanUtil
extends java.lang.Object

Utility methods for dealing with JavaBean objects and properties


Nested Class Summary
static class BeanUtil.PropertyType
           

 

Constructor Summary
BeanUtil()
           

 

Method Summary
static
<T> T
convertType(java.lang.String value, java.lang.Class<T> type)
          Convert the object into the given type
static java.lang.Object getBeanProperty(java.lang.Object bean, java.lang.String name, boolean ignoreCase)
          Get a bean property.
static java.util.Set<java.lang.String> getBeanPropertyNames(java.lang.Class beanClass, BeanUtil.PropertyType type)
          Get a set of the bean properties
static java.lang.Object getPrivilegedProperty(java.lang.Class clazz, java.lang.Object instance, java.lang.String propertyName)
          Retrieves a privilged property
static java.lang.Object getPrivilegedProperty(java.lang.Object instance, java.lang.String propertyName)
          Retrieves a privilged property
static
<T> T
instantiateBean(java.lang.Class<T> type, java.lang.String className, java.util.Map<java.lang.String,java.lang.Object> properties)
          Instantiate an object.
static
<T> T
instantiateBean(java.lang.ClassLoader classLoader, java.lang.Class<T> type, java.lang.String className, java.util.Map<java.lang.String,java.lang.Object> properties)
          Instantiate an object
static void populateBean(java.lang.Object bean, java.util.Map<java.lang.String,?> properties)
          Populate a bean using the JavaBean properties methods that correspond to the keys in the properties map.
static boolean setBeanProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value, boolean ignoreCase)
          Set a bean property
static void setPrivilegedProperty(java.lang.Class clazz, java.lang.Object instance, java.lang.String propertyName, java.lang.Object propertyValue)
          Sets a privilged property

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

BeanUtil

public BeanUtil()

Method Detail

setPrivilegedProperty

public static void setPrivilegedProperty(java.lang.Class clazz,
                                         java.lang.Object instance,
                                         java.lang.String propertyName,
                                         java.lang.Object propertyValue)
                                  throws java.lang.IllegalAccessException
Sets a privilged property
Throws:
java.lang.IllegalAccessException

getPrivilegedProperty

public static java.lang.Object getPrivilegedProperty(java.lang.Object instance,
                                                     java.lang.String propertyName)
                                              throws java.lang.IllegalAccessException
Retrieves a privilged property
Returns:
null if not found, the object otherwise
Throws:
java.lang.IllegalAccessException

getPrivilegedProperty

public static java.lang.Object getPrivilegedProperty(java.lang.Class clazz,
                                                     java.lang.Object instance,
                                                     java.lang.String propertyName)
                                              throws java.lang.IllegalAccessException
Retrieves a privilged property
Returns:
null if not found, the object otherwise
Throws:
java.lang.IllegalAccessException

populateBean

public static void populateBean(java.lang.Object bean,
                                java.util.Map<java.lang.String,?> properties)
                         throws java.lang.Exception
Populate a bean using the JavaBean properties methods that correspond to the keys in the properties map.
Parameters:
bean - the bean to populate
properties - a mapping of property name to property value
Throws:
java.lang.Exception - if an error occurs

instantiateBean

public static <T> T instantiateBean(java.lang.Class<T> type,
                                    java.lang.String className,
                                    java.util.Map<java.lang.String,java.lang.Object> properties)
                         throws java.lang.Exception
Instantiate an object. Note this uses the Thead.currentContextClassLoader() to load the class.
Parameters:
type - the type of object
className - the classname
properties - (optional) a mapping of bean properties to value
Returns:
the constructed bean
Throws:
java.lang.Exception

instantiateBean

public static <T> T instantiateBean(java.lang.ClassLoader classLoader,
                                    java.lang.Class<T> type,
                                    java.lang.String className,
                                    java.util.Map<java.lang.String,java.lang.Object> properties)
                         throws java.lang.Exception
Instantiate an object
Parameters:
classLoader - the classloader to use
type - the type of object
className - the classname
properties - (optional) a mapping of bean properties to value
Returns:
the constructed bean
Throws:
java.lang.Exception

convertType

public static <T> T convertType(java.lang.String value,
                                java.lang.Class<T> type)
Convert the object into the given type
Parameters:
value -
type -
Returns:

setBeanProperty

public static boolean setBeanProperty(java.lang.Object bean,
                                      java.lang.String name,
                                      java.lang.Object value,
                                      boolean ignoreCase)
                               throws java.lang.Exception
Set a bean property
Parameters:
bean - the bean object
name - the property name
value - the property value
ignoreCase - property name inspection case insensitive if true, false otherwise.
Returns:
true if successful, false if property cannot be set
Throws:
java.lang.Exception - if an error occurs during reflection

getBeanPropertyNames

public static java.util.Set<java.lang.String> getBeanPropertyNames(java.lang.Class beanClass,
                                                                   BeanUtil.PropertyType type)
                                                            throws java.lang.Exception
Get a set of the bean properties
Parameters:
beanClass - the bean class
type - the property type
Returns:
a set containing all the matching property names
Throws:
java.lang.Exception - if an error occurs during reflection

getBeanProperty

public static java.lang.Object getBeanProperty(java.lang.Object bean,
                                               java.lang.String name,
                                               boolean ignoreCase)
                                        throws java.lang.Exception
Get a bean property.
Parameters:
bean - the bean object
name - the property name
ignoreCase - property name inspection case insensitive if true, false otherwise.
Returns:
value of the property, if readable, null if not
Throws:
java.lang.Exception - if an error occurs during reflection

Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-02


Copyright © 2010, 2011, Oracle and/or its affiliates. All rights reserved.