Class BeanInfoFactory
java.lang.Object
com.inductiveautomation.ignition.common.beans.BeanInfoFactory
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static Object
executeMethod
(String methodName, Object source) Helper method which uses reflection to search for the methodName on the target with no arguments.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.static Object
executeMethod
(String methodName, Object source, Object arg, Class argType) Helper method which uses reflection to execute a method with a single argument.static Object
getBeanAttribute
(Class type, String attribute) static BeanInfo
getBeanInfo
(Class cls) Retrieves the BeanInfo for a Classstatic BeanInfo
getBeanInfo
(Class cls, int flags) static Container
Returns the container delegate for the object.static Icon
Retrieves the BeanInfo icon for the class.static PropertyDescriptor
getPropertyDescriptor
(Class type, String propertyName) 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.static boolean
isContainer
(Object obj) Determines if the object is a Swing container like JScrollPanestatic void
setBeanAttribute
(Class type, String attribute, Object value) static void
setPropertyAttribute
(Class type, String property, String attribute, Object value)
-
Field Details
-
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
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
-
executeMethod
Helper method which uses reflection to search for the methodName on the target with no arguments. -
executeMethod
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
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
Retrieves the BeanInfo for a Class -
getBeanInfo
-
setBeanAttribute
-
getBeanAttribute
-
getPropertyDescriptor
-
setPropertyAttribute
-
getIcon
Retrieves the BeanInfo icon for the class. -
isContainer
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
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
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.
-