KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > beans > BeanInfo


1 /*
2  * @(#)BeanInfo.java 1.28 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.beans;
9
10 /**
11  * A bean implementor who wishes to provide explicit information about
12  * their bean may provide a BeanInfo class that implements this BeanInfo
13  * interface and provides explicit information about the methods,
14  * properties, events, etc, of their bean.
15  * <p>
16  * A bean implementor doesn't need to provide a complete set of
17  * explicit information. You can pick and choose which information
18  * you want to provide and the rest will be obtained by automatic
19  * analysis using low-level reflection of the bean classes' methods
20  * and applying standard design patterns.
21  * <p>
22  * You get the opportunity to provide lots and lots of different
23  * information as part of the various XyZDescriptor classes. But
24  * don't panic, you only really need to provide the minimal core
25  * information required by the various constructors.
26  * <P>
27  * See also the SimpleBeanInfo class which provides a convenient
28  * "noop" base class for BeanInfo classes, which you can override
29  * for those specific places where you want to return explicit info.
30  * <P>
31  * To learn about all the behaviour of a bean see the Introspector class.
32  */

33
34 public interface BeanInfo {
35
36     /**
37      * Gets the beans <code>BeanDescriptor</code>.
38      *
39      * @return A BeanDescriptor providing overall information about
40      * the bean, such as its displayName, its customizer, etc. May
41      * return null if the information should be obtained by automatic
42      * analysis.
43      */

44     BeanDescriptor JavaDoc getBeanDescriptor();
45     
46     /**
47      * Gets the beans <code>EventSetDescriptor</code>s.
48      *
49      * @return An array of EventSetDescriptors describing the kinds of
50      * events fired by this bean. May return null if the information
51      * should be obtained by automatic analysis.
52      */

53     EventSetDescriptor JavaDoc[] getEventSetDescriptors();
54
55     /**
56      * A bean may have a "default" event that is the event that will
57      * mostly commonly be used by humans when using the bean.
58      * @return Index of default event in the EventSetDescriptor array
59      * returned by getEventSetDescriptors.
60      * <P> Returns -1 if there is no default event.
61      */

62     int getDefaultEventIndex();
63
64     /**
65      * Gets the beans <code>PropertyDescriptor</code>s.
66      *
67      * @return An array of PropertyDescriptors describing the editable
68      * properties supported by this bean. May return null if the
69      * information should be obtained by automatic analysis.
70      * <p>
71      * If a property is indexed, then its entry in the result array will
72      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
73      * A client of getPropertyDescriptors can use "instanceof" to check
74      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
75      */

76     PropertyDescriptor JavaDoc[] getPropertyDescriptors();
77
78     /**
79      * A bean may have a "default" property that is the property that will
80      * mostly commonly be initially chosen for update by human's who are
81      * customizing the bean.
82      * @return Index of default property in the PropertyDescriptor array
83      * returned by getPropertyDescriptors.
84      * <P> Returns -1 if there is no default property.
85      */

86     int getDefaultPropertyIndex();
87
88     /**
89      * Gets the beans <code>MethodDescriptor</code>s.
90      *
91      * @return An array of MethodDescriptors describing the externally
92      * visible methods supported by this bean. May return null if
93      * the information should be obtained by automatic analysis.
94      */

95     MethodDescriptor JavaDoc[] getMethodDescriptors();
96
97     /**
98      * This method allows a BeanInfo object to return an arbitrary collection
99      * of other BeanInfo objects that provide additional information on the
100      * current bean.
101      * <P>
102      * If there are conflicts or overlaps between the information provided
103      * by different BeanInfo objects, then the current BeanInfo takes precedence
104      * over the getAdditionalBeanInfo objects, and later elements in the array
105      * take precedence over earlier ones.
106      *
107      * @return an array of BeanInfo objects. May return null.
108      */

109     BeanInfo JavaDoc[] getAdditionalBeanInfo();
110
111     /**
112      * This method returns an image object that can be used to
113      * represent the bean in toolboxes, toolbars, etc. Icon images
114      * will typically be GIFs, but may in future include other formats.
115      * <p>
116      * Beans aren't required to provide icons and may return null from
117      * this method.
118      * <p>
119      * There are four possible flavors of icons (16x16 color,
120      * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
121      * support a single icon we recommend supporting 16x16 color.
122      * <p>
123      * We recommend that icons have a "transparent" background
124      * so they can be rendered onto an existing background.
125      *
126      * @param iconKind The kind of icon requested. This should be
127      * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
128      * ICON_MONO_16x16, or ICON_MONO_32x32.
129      * @return An image object representing the requested icon. May
130      * return null if no suitable icon is available.
131      */

132     java.awt.Image JavaDoc getIcon(int iconKind);
133      
134     /**
135      * Constant to indicate a 16 x 16 color icon.
136      */

137     final static int ICON_COLOR_16x16 = 1;
138
139     /**
140      * Constant to indicate a 32 x 32 color icon.
141      */

142     final static int ICON_COLOR_32x32 = 2;
143
144     /**
145      * Constant to indicate a 16 x 16 monochrome icon.
146      */

147     final static int ICON_MONO_16x16 = 3;
148
149     /**
150      * Constant to indicate a 32 x 32 monochrome icon.
151      */

152     final static int ICON_MONO_32x32 = 4;
153 }
154
Popular Tags