com.ge.research.acuity.utils
Class IntrospectionUtils

java.lang.Object
  extended bycom.ge.research.utils.IntrospectionUtils
      extended bycom.ge.research.acuity.utils.IntrospectionUtils

public class IntrospectionUtils
extends IntrospectionUtils

Introspection utilities for acuity ui models, with specific convienence methods for getting and setting presentation object attribute values without explicit knowledge of the attribute meaning or presentation object sub-type. These tools help us achieve a very generic methodology by which we handle the creation and reading of presentation objects.

Version:
$Revision: 1.1 $ $Date: 2006/08/11 00:17:35 $
Author:
garbiras

Constructor Summary
IntrospectionUtils()
           
 
Method Summary
static boolean equalsPOParamValue(PresentationObject po, java.lang.String param, java.lang.Object value)
          Convienence method for testing equality of the supplied value to the current value of a presentation object attribute without knowing the explicit method signature, but just knowing the parameter name.
static ControllerInterface getNewControllerInterface(java.lang.String classname, AcuityController controller)
          Convienence method for instanciating a ControllerInterface once the specific implementation class is identified.
static ControllerInterface getNewControllerInterface(java.lang.String classname, java.lang.String controllerClassname, java.lang.String policyFile, java.lang.String instanceFile, java.lang.String instanceURI, java.lang.String user, java.lang.String pwd, int traceLevel)
          Convienence method for instanciating a ControllerInterface once the specific implementation class is identified.
static GraphRenderer getNewGraphRenderer(java.lang.String classname)
          Convienence method for instanciating a GraphRenderer once the specific implementation class is identified.
static java.lang.Object getPOParamValue(PresentationObject po, java.lang.reflect.Field f)
          Convienence method for getting the current value of a presentation object attribute without knowing the explicit method signature, but just knowing the class field.
static java.lang.Object getPOParamValue(PresentationObject po, java.lang.String param)
          Convienence method for getting the current value of a presentation object attribute without knowing the explicit method signature, but just knowing the parameter name.
static void setPOAttribute(PresentationObject po, PresentationParameterMap ppm, java.util.Map poSetterMethodMap, java.lang.String parameter, java.lang.Object value)
          This method looks at the type of data contained in the value parameter and creates an Object[] array and inserts into it values from the value parameter and then invokes the setter method with the new values
static void setPODefaultValue(PresentationObject po, java.lang.String defaultValue)
          Invokes the setDefaultValue(s) method on the presentation object (depending on its type) using the value of defaultValue as the argument
static void setSelectionPOChoices(SelectionPO po, java.util.Map choices)
          Invokes the SelectionPO.addChoice(java.lang.Object, java.lang.Object) method on the po argument using the information contained in the choices map.
static java.util.Map setupPOSetterMethodMap(PresentationObject po)
          Gets a list of the accessible methods for the presentation object (including methods defined in super classes) and determines which of those are simple "setters" and complex "setters" or "adders".
 
Methods inherited from class com.ge.research.utils.IntrospectionUtils
getAllInheritedClasses, getAllInheritedClasses, getAllMembers, getMember, getMemberType, getMemberValue, getMemberValue, getMethod, getMethod, getNewInstance, getNewInstance, getNewInstance, getNewInstance, getPrimitiveClass, invokeMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntrospectionUtils

public IntrospectionUtils()
Method Detail

equalsPOParamValue

public static final boolean equalsPOParamValue(PresentationObject po,
                                               java.lang.String param,
                                               java.lang.Object value)
Convienence method for testing equality of the supplied value to the current value of a presentation object attribute without knowing the explicit method signature, but just knowing the parameter name.

Parameters:
po - the presentation object to use
param - the parameter name to get the value for
value - The value of the parameter to test against the value of the parameter of the presentation object
Returns:
true if the argument value and the presentation object's parameter value are the same; false otherwise;
See Also:
getPOParamValue(com.ge.research.acuity.ui.PresentationObject, java.lang.String)

getNewControllerInterface

public static final ControllerInterface getNewControllerInterface(java.lang.String classname,
                                                                  java.lang.String controllerClassname,
                                                                  java.lang.String policyFile,
                                                                  java.lang.String instanceFile,
                                                                  java.lang.String instanceURI,
                                                                  java.lang.String user,
                                                                  java.lang.String pwd,
                                                                  int traceLevel)
                                                           throws AcuityException,
                                                                  java.lang.IllegalArgumentException
Convienence method for instanciating a ControllerInterface once the specific implementation class is identified.

Parameters:
classname - the ControllerInterface class to instantiate
Returns:
The instantiated ControllerInterface
Throws:
AcuityException - If an error occurs creating an instance of the AcuityController
java.lang.IllegalArgumentException

getNewControllerInterface

public static final ControllerInterface getNewControllerInterface(java.lang.String classname,
                                                                  AcuityController controller)
                                                           throws java.lang.IllegalArgumentException
Convienence method for instanciating a ControllerInterface once the specific implementation class is identified.

Parameters:
classname - the ControllerInterface class to instantiate
Returns:
The instantiated ControllerInterface
Throws:
java.lang.IllegalArgumentException

getNewGraphRenderer

public static final GraphRenderer getNewGraphRenderer(java.lang.String classname)
Convienence method for instanciating a GraphRenderer once the specific implementation class is identified.

Parameters:
classname - the GraphRenderer class to instantiate
Returns:
The instantiated GraphRenderer

getPOParamValue

public static final java.lang.Object getPOParamValue(PresentationObject po,
                                                     java.lang.reflect.Field f)
Convienence method for getting the current value of a presentation object attribute without knowing the explicit method signature, but just knowing the class field.

Parameters:
po - the presentation object to use
f - the field to get the value for
Returns:
The value of the field in the presentation object; null if the value is null or if some error occurs trying to obtain the current value
See Also:
IntrospectionUtils.getMethod(java.lang.Class, java.lang.String, java.lang.Class[]), com.ge.research.utils.IntrospectionUtils#invokeMethod(java.lang.reflect.Method, java.lang.Object, javba.lang.Object[])

getPOParamValue

public static final java.lang.Object getPOParamValue(PresentationObject po,
                                                     java.lang.String param)
Convienence method for getting the current value of a presentation object attribute without knowing the explicit method signature, but just knowing the parameter name.

Parameters:
po - the presentation object to use
param - the parameter name to get the value for
Returns:
The value of the parameter in the presentation object; null if the value is null or if some error occurs trying to obtain the current value
See Also:
IntrospectionUtils.getMemberType(java.lang.Object, java.lang.String), IntrospectionUtils.getMethod(java.lang.Class, java.lang.String, java.lang.Class[]), IntrospectionUtils.invokeMethod(java.lang.reflect.Method, java.lang.Object, java.lang.Object[])

setupPOSetterMethodMap

public static final java.util.Map setupPOSetterMethodMap(PresentationObject po)
                                                  throws java.lang.SecurityException
Gets a list of the accessible methods for the presentation object (including methods defined in super classes) and determines which of those are simple "setters" and complex "setters" or "adders". Those methods are then put into a map whose key value is the attribute name, derived from the method name, for whom the setter is defined.

Parameters:
po - the presentation object to introspect and find attribute setting methods for
Returns:
A map of presentation object attribute names to their setting Method
Throws:
java.lang.SecurityException - If the presentation object is not accessible

setPOAttribute

public static final void setPOAttribute(PresentationObject po,
                                        PresentationParameterMap ppm,
                                        java.util.Map poSetterMethodMap,
                                        java.lang.String parameter,
                                        java.lang.Object value)
This method looks at the type of data contained in the value parameter and creates an Object[] array and inserts into it values from the value parameter and then invokes the setter method with the new values

Parameters:
po - the presentation object to act on
ppm - the presentation parameter map with desired attribute values, from the ontology
poSetterMethodMap - a map of the presentation objects settable attributes to their setter Methods
parameter - the current parameter/attribute to be set
value - the current value for the parameter/attribute to be set to

setPODefaultValue

public static final void setPODefaultValue(PresentationObject po,
                                           java.lang.String defaultValue)
Invokes the setDefaultValue(s) method on the presentation object (depending on its type) using the value of defaultValue as the argument

Parameters:
po - the presentation object to use
defaultValue - the value to use for the setDefaultValue(s) method

setSelectionPOChoices

public static final void setSelectionPOChoices(SelectionPO po,
                                               java.util.Map choices)
Invokes the SelectionPO.addChoice(java.lang.Object, java.lang.Object) method on the po argument using the information contained in the choices map. The contents of the map are iterated over and the addChoice method is invoked for each entry found.

Parameters:
po - the presentation object to use
choices - map of choice "values" to choice "display strings"