Class BeanInfoFactory
- java.lang.Object
-
- com.inductiveautomation.ignition.common.beans.BeanInfoFactory
-
public class BeanInfoFactory extends java.lang.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 Summary
Fields Modifier and Type Field Description static java.lang.String
CATEGORY_KEY
Well known key for a property descriptor that holds the name of the category of the property.static java.lang.String
DISPLAY_ORDER_KEY
Well known key for a property descriptor that should be an integer that represents the relative display order
-
Constructor Summary
Constructors Constructor Description BeanInfoFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addBeanInfoSearchPackage(java.lang.String pkg)
static java.lang.Object
executeMethod(java.lang.String methodName, java.lang.Object source)
Helper method which uses reflection to search for the methodName on the target with no arguments.static java.lang.Object
executeMethod(java.lang.String methodName, java.lang.Object source, java.lang.Object arg)
Helper method which uses reflection to search for the methodName on the target with a single arg type as a parameter.static java.lang.Object
executeMethod(java.lang.String methodName, java.lang.Object source, java.lang.Object arg, java.lang.Class argType)
Helper method which uses reflection to execute a method with a single argument.static java.lang.Object
getBeanAttribute(java.lang.Class type, java.lang.String attribute)
static java.beans.BeanInfo
getBeanInfo(java.lang.Class cls)
Retrieves the BeanInfo for a Classstatic java.beans.BeanInfo
getBeanInfo(java.lang.Class cls, int flags)
static java.awt.Container
getContainerDelegate(java.lang.Object obj)
Returns the container delegate for the object.static javax.swing.Icon
getIcon(java.lang.Class cls)
Retrieves the BeanInfo icon for the class.static java.beans.PropertyDescriptor
getPropertyDescriptor(java.lang.Class type, java.lang.String propertyName)
static java.awt.Component
getProxyComponent(java.lang.Object obj)
Returns the visual proxy for the object A visual proxy is a visual component which represents a non visual component.static boolean
isContainer(java.lang.Object obj)
Determines if the object is a Swing container like JScrollPanestatic void
setBeanAttribute(java.lang.Class type, java.lang.String attribute, java.lang.Object value)
static void
setPropertyAttribute(java.lang.Class type, java.lang.String property, java.lang.String attribute, java.lang.Object value)
-
-
-
Field Detail
-
DISPLAY_ORDER_KEY
public static final java.lang.String DISPLAY_ORDER_KEY
Well known key for a property descriptor that should be an integer that represents the relative display order- See Also:
- Constant Field Values
-
CATEGORY_KEY
public static final java.lang.String CATEGORY_KEY
Well known key for a property descriptor that holds the name of the category of the property.- See Also:
- Constant Field Values
-
-
Method Detail
-
addBeanInfoSearchPackage
public static void addBeanInfoSearchPackage(java.lang.String pkg)
-
executeMethod
public static java.lang.Object executeMethod(java.lang.String methodName, java.lang.Object source)
Helper method which uses reflection to search for the methodName on the target with no arguments.
-
executeMethod
public static java.lang.Object executeMethod(java.lang.String methodName, java.lang.Object source, java.lang.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 executesource
- object in which to invoke the methodarg
- 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 java.lang.Object executeMethod(java.lang.String methodName, java.lang.Object source, java.lang.Object arg, java.lang.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 executesource
- object in which to invoke the methodarg
- object which is the argumentargType
- 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 java.beans.BeanInfo getBeanInfo(java.lang.Class cls)
Retrieves the BeanInfo for a Class
-
getBeanInfo
public static java.beans.BeanInfo getBeanInfo(java.lang.Class cls, int flags)
-
setBeanAttribute
public static void setBeanAttribute(java.lang.Class type, java.lang.String attribute, java.lang.Object value)
-
getBeanAttribute
public static java.lang.Object getBeanAttribute(java.lang.Class type, java.lang.String attribute)
-
getPropertyDescriptor
public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class type, java.lang.String propertyName)
-
setPropertyAttribute
public static void setPropertyAttribute(java.lang.Class type, java.lang.String property, java.lang.String attribute, java.lang.Object value)
-
getIcon
public static javax.swing.Icon getIcon(java.lang.Class cls)
Retrieves the BeanInfo icon for the class.
-
isContainer
public static boolean isContainer(java.lang.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 java.awt.Container getContainerDelegate(java.lang.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 java.awt.Component getProxyComponent(java.lang.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.
-
-