1. /*
  2. * @(#)BeanInfo.java 1.25 00/02/02
  3. *
  4. * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.beans;
  11. /**
  12. * A bean implementor who wishes to provide explicit information about
  13. * their bean may provide a BeanInfo class that implements this BeanInfo
  14. * interface and provides explicit information about the methods,
  15. * properties, events, etc, of their bean.
  16. * <p>
  17. * A bean implementor doesn't need to provide a complete set of
  18. * explicit information. You can pick and choose which information
  19. * you want to provide and the rest will be obtained by automatic
  20. * analysis using low-level reflection of the bean classes' methods
  21. * and applying standard design patterns.
  22. * <p>
  23. * You get the opportunity to provide lots and lots of different
  24. * information as part of the various XyZDescriptor classes. But
  25. * don't panic, you only really need to provide the minimal core
  26. * information required by the various constructors.
  27. * <P>
  28. * See also the SimpleBeanInfo class which provides a convenient
  29. * "noop" base class for BeanInfo classes, which you can override
  30. * for those specific places where you want to return explicit info.
  31. * <P>
  32. * To learn about all the behaviour of a bean see the Introspector class.
  33. */
  34. public interface BeanInfo {
  35. /**
  36. * Gets the beans <code>BeanDescriptor</code>.
  37. *
  38. * @return A BeanDescriptor providing overall information about
  39. * the bean, such as its displayName, its customizer, etc. May
  40. * return null if the information should be obtained by automatic
  41. * analysis.
  42. */
  43. BeanDescriptor getBeanDescriptor();
  44. /**
  45. * Gets the beans <code>EventSetDescriptor</code>s.
  46. *
  47. * @return An array of EventSetDescriptors describing the kinds of
  48. * events fired by this bean. May return null if the information
  49. * should be obtained by automatic analysis.
  50. */
  51. EventSetDescriptor[] getEventSetDescriptors();
  52. /**
  53. * A bean may have a "default" event that is the event that will
  54. * mostly commonly be used by humans when using the bean.
  55. * @return Index of default event in the EventSetDescriptor array
  56. * returned by getEventSetDescriptors.
  57. * <P> Returns -1 if there is no default event.
  58. */
  59. int getDefaultEventIndex();
  60. /**
  61. * Gets the beans <code>PropertyDescriptor</code>s.
  62. *
  63. * @return An array of PropertyDescriptors describing the editable
  64. * properties supported by this bean. May return null if the
  65. * information should be obtained by automatic analysis.
  66. * <p>
  67. * If a property is indexed, then its entry in the result array will
  68. * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
  69. * A client of getPropertyDescriptors can use "instanceof" to check
  70. * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
  71. */
  72. PropertyDescriptor[] getPropertyDescriptors();
  73. /**
  74. * A bean may have a "default" property that is the property that will
  75. * mostly commonly be initially chosen for update by human's who are
  76. * customizing the bean.
  77. * @return Index of default property in the PropertyDescriptor array
  78. * returned by getPropertyDescriptors.
  79. * <P> Returns -1 if there is no default property.
  80. */
  81. int getDefaultPropertyIndex();
  82. /**
  83. * Gets the beans <code>MethodDescriptor</code>s.
  84. *
  85. * @return An array of MethodDescriptors describing the externally
  86. * visible methods supported by this bean. May return null if
  87. * the information should be obtained by automatic analysis.
  88. */
  89. MethodDescriptor[] getMethodDescriptors();
  90. /**
  91. * This method allows a BeanInfo object to return an arbitrary collection
  92. * of other BeanInfo objects that provide additional information on the
  93. * current bean.
  94. * <P>
  95. * If there are conflicts or overlaps between the information provided
  96. * by different BeanInfo objects, then the current BeanInfo takes precedence
  97. * over the getAdditionalBeanInfo objects, and later elements in the array
  98. * take precedence over earlier ones.
  99. *
  100. * @return an array of BeanInfo objects. May return null.
  101. */
  102. BeanInfo[] getAdditionalBeanInfo();
  103. /**
  104. * This method returns an image object that can be used to
  105. * represent the bean in toolboxes, toolbars, etc. Icon images
  106. * will typically be GIFs, but may in future include other formats.
  107. * <p>
  108. * Beans aren't required to provide icons and may return null from
  109. * this method.
  110. * <p>
  111. * There are four possible flavors of icons (16x16 color,
  112. * 32x32 color, 16x16 mono, 32x32 mono). If a bean choses to only
  113. * support a single icon we recommend supporting 16x16 color.
  114. * <p>
  115. * We recommend that icons have a "transparent" background
  116. * so they can be rendered onto an existing background.
  117. *
  118. * @param iconKind The kind of icon requested. This should be
  119. * one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
  120. * ICON_MONO_16x16, or ICON_MONO_32x32.
  121. * @return An image object representing the requested icon. May
  122. * return null if no suitable icon is available.
  123. */
  124. java.awt.Image getIcon(int iconKind);
  125. /**
  126. * Constant to indicate a 16 x 16 color icon.
  127. */
  128. final static int ICON_COLOR_16x16 = 1;
  129. /**
  130. * Constant to indicate a 32 x 32 color icon.
  131. */
  132. final static int ICON_COLOR_32x32 = 2;
  133. /**
  134. * Constant to indicate a 16 x 16 monochrome icon.
  135. */
  136. final static int ICON_MONO_16x16 = 3;
  137. /**
  138. * Constant to indicate a 32 x 32 monochrome icon.
  139. */
  140. final static int ICON_MONO_32x32 = 4;
  141. }