com.ibm.commerce.component.bod

Class MethodInvocationUtil

  • java.lang.Object
    • com.ibm.commerce.component.bod.MethodInvocationUtil


  • public class MethodInvocationUtil
    extends java.lang.Object
    Provides utility methods that invoke a Java methods by reflection
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String CLASS_NAME
      Name of this class
      static java.lang.String COPYRIGHT
      IBM Copyright
      static java.lang.String GETTER_METHOD_HEADER
      getters start with this string
      static java.lang.String SETTER_METHOD_HEADER
      setters start with this string
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.reflect.Method findMethod(java.lang.Class klass, java.lang.String methodName, java.lang.Class[] parameters)
      Returns the first found Method object that is a public member method of the class or interface represented by this Class object, if any.
      static java.lang.Class getClass(java.lang.String shortName)
      Returns the Class that is represents by the given class name.
      static java.lang.String getClassFullName(java.lang.String shortName)
      Returns the full name of a class that has the given short name
      static java.lang.Package getPackage(java.lang.String name)
      Returns the package that contains a registered class
      static java.lang.String getPackageName(java.lang.String name)
      Returns the package name of a registered class
      static java.lang.Object getProperty(java.lang.Object target, java.lang.String propertyName)
      Gets the value of a property.
      static java.lang.reflect.Method getReadMethod(java.lang.Object obj, java.lang.String property)
      Gets the getter of a property in a given object following JavaBean spec.
      static java.lang.reflect.Method getWriteMethod(java.lang.Object obj, java.lang.String property)
      Gets the setter of a property in a given object following JavaBean spec.
      static void registerClass(java.lang.Class aClass)
      Associate a class's name with the class's package
      static boolean setProperty(java.lang.Object target, java.lang.String propertyName, java.lang.Object propertyValue)
      Sets a property value to a property in a given object.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • GETTER_METHOD_HEADER

        public static final java.lang.String GETTER_METHOD_HEADER
        getters start with this string
        See Also:
        Constant Field Values
      • SETTER_METHOD_HEADER

        public static final java.lang.String SETTER_METHOD_HEADER
        setters start with this string
        See Also:
        Constant Field Values
      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM Copyright
        See Also:
        Constant Field Values
      • CLASS_NAME

        public static final java.lang.String CLASS_NAME
        Name of this class
    • Constructor Detail

      • MethodInvocationUtil

        public MethodInvocationUtil()
    • Method Detail

      • getClass

        public static java.lang.Class getClass(java.lang.String shortName)
        Returns the Class that is represents by the given class name. Only the registered classes will be retrieved.
        Parameters:
        shortName - the short name of a class
        Returns:
        the class that has the given short name, if it is registered. Otherwise, null.
        See Also:
        registerClass(Class)
      • registerClass

        public static void registerClass(java.lang.Class aClass)
        Associate a class's name with the class's package
        Parameters:
        aClass - the name of it will be associated with its package
        See Also:
        getPackage
      • getPackage

        public static java.lang.Package getPackage(java.lang.String name)
        Returns the package that contains a registered class
        Parameters:
        name - the name of a class
        Returns:
        the package name of the indicated class
        See Also:
        registerClass(Class)
      • getPackageName

        public static java.lang.String getPackageName(java.lang.String name)
        Returns the package name of a registered class
        Parameters:
        name - the name of a class
        Returns:
        the package name of the indicated class
        See Also:
        registerClass(Class)
      • getClassFullName

        public static java.lang.String getClassFullName(java.lang.String shortName)
        Returns the full name of a class that has the given short name
        Parameters:
        shortName - short name of a class
        Returns:
        the full name of the indicated class, if it is registered.
      • setProperty

        public static boolean setProperty(java.lang.Object target,
                                          java.lang.String propertyName,
                                          java.lang.Object propertyValue)
        Sets a property value to a property in a given object.
        Parameters:
        target - the object whose property is to be set.
        propertyName - the name of the property
        propertyValue - the value for the given property
        Returns:
        true if the value is successfully set. False otherwise.
      • getReadMethod

        public static java.lang.reflect.Method getReadMethod(java.lang.Object obj,
                                                             java.lang.String property)
        Gets the getter of a property in a given object following JavaBean spec.
        Parameters:
        obj - the object to be analyzed
        property - the property that is associated with the getter
        Returns:
        the getter method. If no such method is found, it will return null.
      • getWriteMethod

        public static java.lang.reflect.Method getWriteMethod(java.lang.Object obj,
                                                              java.lang.String property)
        Gets the setter of a property in a given object following JavaBean spec.
        Parameters:
        obj - the object to be analyzed
        property - the property that is associated with the setter
        Returns:
        the setter method. If no such method is found, it will return null.
      • findMethod

        public static java.lang.reflect.Method findMethod(java.lang.Class klass,
                                                          java.lang.String methodName,
                                                          java.lang.Class[] parameters)
        Returns the first found Method object that is a public member method of the class or interface represented by this Class object, if any. If this Class object does not contain the method, its parent class or parent interface will be searched. The search continues until the method is found or there is no class or interface to search.
        Parameters:
        klass - The Class object where the search starts
        methodName - the name of the method
        parameters - the parameter list of the method to search
        Returns:
        the first found Method object. If no method is found, it will return null.
      • getProperty

        public static java.lang.Object getProperty(java.lang.Object target,
                                                   java.lang.String propertyName)
        Gets the value of a property.
        Parameters:
        target - the object whose property will be accessed
        propertyName - the getter of the property will be called
        Returns:
        This method returns the value of the property if the property is found. Otherwise, NullObject.VALUE