com.webmethods.caf.faces.data
Class ContentProviderUtils

java.lang.Object
  extended by com.webmethods.caf.faces.data.ContentProviderUtils

public class ContentProviderUtils
extends Object

Utility functions for content providers. Should not be used by clients directly.


Constructor Summary
ContentProviderUtils()
           
 
Method Summary
static Object evaluateBinding(Object provider, String providerVariable, ValueBinding binding)
          Evaluates the specified binding in the context of the specified content provider, using the specified provider variable.
static Object evaluateRowBinding(ITableContentProvider table, ValueBinding binding)
          Evaluates the specified binding in the context of the specified table's current row, using the the row variable specified by ITableContentProvider.getRowVariable().
static PropertyDescriptor getPropertyDescriptor(Class c, Object propertyKey)
          Get descriptor for property specified by name.
static Object[] getPropertyKeys(Object o)
          Returns property keys for object.
static Class getType(Class c, Object propertyKey)
          Returns property type for a class.
static Class getType(Object o, Object propertyKey)
          Returns property type for object.
static Object getValue(Object o, Object propertyKey)
          Returns property value for object.
static boolean hasProperty(Class c, Object propertyKey)
          Checks if a property exists for a Class.
static boolean hasProperty(Object o, Object propertyKey)
          Checks if a property exists for object.
static boolean isReadOnly(Class c, Object propertyKey)
          Checks if a property is editable for a Class .
static boolean isReadOnly(Object o, Object propertyKey)
          Checks if a property is editable for a object.
static void setValue(Object o, Object propertyKey, Object value)
          Set value for property in an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentProviderUtils

public ContentProviderUtils()
Method Detail

getPropertyKeys

public static Object[] getPropertyKeys(Object o)
Returns property keys for object.

Parameters:
o - Object containing the properties
Returns:
Object[] of all the property keys

getType

public static Class getType(Object o,
                            Object propertyKey)
                     throws PropertyNotFoundException
Returns property type for object.

Parameters:
o - Object containing the property
propertyKey - the property key of type String or Integer
Returns:
Class of the property
Throws:
PropertyNotFoundException - if the object does not have the propertyKey

getType

public static Class getType(Class c,
                            Object propertyKey)
                     throws PropertyNotFoundException
Returns property type for a class.

Parameters:
c - Class containing the property
propertyKey - the property key of type String or Integer
Returns:
Class of the property
Throws:
PropertyNotFoundException - if the class does not have the propertyKey

getValue

public static Object getValue(Object o,
                              Object propertyKey)
                       throws EvaluationException,
                              PropertyNotFoundException
Returns property value for object.

Parameters:
o - Object containing the property
propertyKey - the property key of type String or Integer
Returns:
Object value against the property
Throws:
EvaluationException - if error during property evaluation
PropertyNotFoundException - if the object does not have the propertyKey

hasProperty

public static boolean hasProperty(Object o,
                                  Object propertyKey)
Checks if a property exists for object.

Parameters:
o - Object containing the property
propertyKey - the property key of type String or Integer
Returns:
true if the property exists, false otherwise

hasProperty

public static boolean hasProperty(Class c,
                                  Object propertyKey)
Checks if a property exists for a Class.

Parameters:
o - Class containing the property
propertyKey - the property key of type String or Integer
Returns:
true if the property exists, false otherwise

isReadOnly

public static boolean isReadOnly(Object o,
                                 Object propertyKey)
                          throws EvaluationException,
                                 PropertyNotFoundException
Checks if a property is editable for a object.

Parameters:
o - Object containing the property
propertyKey - the property key of type String or Integer
Returns:
true if the property is editable, false otherwise
Throws:
PropertyNotFoundException - if the object does not have the propertyKey
EvaluationException

isReadOnly

public static boolean isReadOnly(Class c,
                                 Object propertyKey)
                          throws PropertyNotFoundException
Checks if a property is editable for a Class .

Parameters:
o - Class containing the property
propertyKey - the property key of type String or Integer
Returns:
true if the property is editable, false otherwise
Throws:
PropertyNotFoundException - if the object does not have the propertyKey

setValue

public static void setValue(Object o,
                            Object propertyKey,
                            Object value)
                     throws EvaluationException,
                            PropertyNotFoundException
Set value for property in an object.

Parameters:
o - Object containing the property
propertyKey - the property key of type String or Integer
value - Object value against the property
Throws:
EvaluationException - if error during property evaluation
PropertyNotFoundException - if the object does not have the propertyKey

evaluateBinding

public static Object evaluateBinding(Object provider,
                                     String providerVariable,
                                     ValueBinding binding)
Evaluates the specified binding in the context of the specified content provider, using the specified provider variable.

Parameters:
provider - content provider
providerVariable - provider variable
binding - ValueBinding
Returns:
the evaluated value

evaluateRowBinding

public static Object evaluateRowBinding(ITableContentProvider table,
                                        ValueBinding binding)
Evaluates the specified binding in the context of the specified table's current row, using the the row variable specified by ITableContentProvider.getRowVariable().

Parameters:
table - ITableContentProvider
binding - ValueBinding
Returns:
the evaluated value

getPropertyDescriptor

public static PropertyDescriptor getPropertyDescriptor(Class c,
                                                       Object propertyKey)
Get descriptor for property specified by name.

Parameters:
c - Class containing the property
propertyKey - the property key of type String or Integer
Returns:
PropertyDescriptor, or null if not found.