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