Class BeanInfoFactory

java.lang.Object
com.inductiveautomation.ignition.common.beans.BeanInfoFactory

public class BeanInfoFactory extends Object
A wrapper for the Introspector to return instances of BeanInfos.

This class also contains some convenience methods for getting access to BeanInfo specfic values for keys like "isContainer", "containerDelegate" and "proxyComponent"

Also contains some utility methods for using reflection to invoke methods.

  • Field Details

    • DISPLAY_ORDER_KEY

      public static final String DISPLAY_ORDER_KEY
      Well known key for a property descriptor that should be an integer that represents the relative display order
      See Also:
    • CATEGORY_KEY

      public static final String CATEGORY_KEY
      Well known key for a property descriptor that holds the name of the category of the property.
      See Also:
  • Constructor Details

    • BeanInfoFactory

      public BeanInfoFactory()
  • Method Details

    • addBeanInfoSearchPackage

      public static void addBeanInfoSearchPackage(String pkg)
    • executeMethod

      public static Object executeMethod(String methodName, Object source)
      Helper method which uses reflection to search for the methodName on the target with no arguments.
    • executeMethod

      public static Object executeMethod(String methodName, Object source, Object arg)
      Helper method which uses reflection to search for the methodName on the target with a single arg type as a parameter. The Class hierarchy of the arg is traversed until the method is found.

      For example, we wish to execute Container.add(Component). The source object would be a Container instance, the argument would be an instance of a Component and the method name would be "add". If a JButton is used the component, the hierarchy will be walked: JButton to JComponent to Container to Component until the add method on Container is found.

      Parameters:
      methodName - name of the method to execute
      source - object in which to invoke the method
      arg - object which is the argument
      Returns:
      the result of invocation or null if it hasn't been invoked or if the invocation produces a null result
    • executeMethod

      public static Object executeMethod(String methodName, Object source, Object arg, Class argType)
      Helper method which uses reflection to execute a method with a single argument. Once the method is found which satisfies the parameter, that method is stored in a cache.
      Parameters:
      methodName - name of the method to execute
      source - object in which to invoke the method
      arg - object which is the argument
      argType - type of the argument object.
      Returns:
      the result of invocation or null if it hasn't been invoked or if the invocation produces a null result
    • getBeanInfo

      public static BeanInfo getBeanInfo(Class cls)
      Retrieves the BeanInfo for a Class
    • getBeanInfo

      public static BeanInfo getBeanInfo(Class cls, int flags)
    • setBeanAttribute

      public static void setBeanAttribute(Class type, String attribute, Object value)
    • getBeanAttribute

      public static Object getBeanAttribute(Class type, String attribute)
    • getPropertyDescriptor

      public static PropertyDescriptor getPropertyDescriptor(Class type, String propertyName)
    • setPropertyAttribute

      public static void setPropertyAttribute(Class type, String property, String attribute, Object value)
    • getIcon

      public static Icon getIcon(Class cls)
      Retrieves the BeanInfo icon for the class.
    • isContainer

      public static boolean isContainer(Object obj)
      Determines if the object is a Swing container like JScrollPane
      Parameters:
      obj - Object to test.
      Returns:
      true if the object is a Swing container.
    • getContainerDelegate

      public static Container getContainerDelegate(Object obj)
      Returns the container delegate for the object. The container delegate is the actual container for which objects are added to for Swing containers. For example, The JViewport is the container delegate for the JScrollPane.
      Returns:
      container delegate or null if there is no container delegate.
    • getProxyComponent

      public static Component getProxyComponent(Object obj)
      Returns the visual proxy for the object A visual proxy is a visual component which represents a non visual component.
      Returns:
      an instance of the visual proxy component or null if a proxy doesn't exist.