BeanInfo.java 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* java.beans.BeanInfo
  2. Copyright (C) 1998 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.beans;
  32. /**
  33. ** BeanInfo can be implemented in order to provide explicit information to the Introspector.
  34. **
  35. ** When you write a BeanInfo class, you implement this interface
  36. ** and provide explicit information by returning a non-null
  37. ** value from the appropriate method. If you wish the
  38. ** Introspector to determine certain information in the normal
  39. ** way, just return null (or in the case of int methods, return
  40. ** -1). There is a class called SimpleBeanInfo which returns
  41. ** null from all methods, which you may extend and only
  42. ** override the methods you wish to override.<P>
  43. **
  44. ** When you have written the class, give it the name
  45. ** <CODE>&lt;Bean Class Name&gt;BeanInfo</CODE> and place it in
  46. ** the same package as the Bean, or in the bean info search path
  47. ** (see Introspector for information on search paths).<P>
  48. **
  49. ** A simple note about the way the Introspector interacts with
  50. ** BeanInfo. Introspectors look at a Bean class and determine
  51. ** if there is a BeanInfo class with it. If there is not a
  52. ** BeanInfo class, it will behave as if the BeanInfo class
  53. ** provided was a SimpleBeanInfo class (i.e. it will determine
  54. ** all information automatically).<P>If there is a BeanInfo
  55. ** class, then any methods that do *not* return null are
  56. ** regarded as providing definitive information about the class
  57. ** and all of its superclasses for those information types.
  58. ** Even if a parent BeanInfo class explicitly returns that
  59. ** information, it will not be used.
  60. **
  61. ** @author John Keiser
  62. ** @since JDK1.1
  63. ** @version 1.1.0, 28 Jul 1998
  64. **/
  65. public interface BeanInfo {
  66. /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
  67. int ICON_COLOR_16x16 = 1;
  68. /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
  69. int ICON_COLOR_32x32 = 2;
  70. /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
  71. int ICON_MONO_16x16 = 3;
  72. /** Use this as a parameter for the getIcon() command to retrieve a certain type of icon. **/
  73. int ICON_MONO_32x32 = 4;
  74. /** Get the general description of this Bean type.
  75. ** @return the BeanDescriptor for the Bean, or null if
  76. ** the BeanDescriptor should be obtained by
  77. ** Introspection.
  78. **/
  79. BeanDescriptor getBeanDescriptor();
  80. /** Get the events this Bean type fires.
  81. ** @return the EventDescriptors representing events this
  82. ** Bean fires. Returns <CODE>null</CODE> if the
  83. ** events are to be acquired by Introspection.
  84. **/
  85. EventSetDescriptor[] getEventSetDescriptors();
  86. /** Get the "default" event, basically the one a RAD tool
  87. ** user is most likely to select.
  88. ** @return the index into the getEventSetDescriptors()
  89. ** that the user is most likely to use. Returns
  90. ** <CODE>-1</CODE> if there is no default event.
  91. **/
  92. int getDefaultEventIndex();
  93. /** Get the properties (get/set method pairs) this Bean
  94. ** type supports.
  95. ** @return the PropertyDescriptors representing the
  96. ** properties this Bean type supports.
  97. ** Returns <CODE>null</CODE> if the properties
  98. ** are to be obtained by Introspection.
  99. **/
  100. PropertyDescriptor[] getPropertyDescriptors();
  101. /** Get the "default" property, basically the one a RAD
  102. ** tool user is most likely to select.
  103. ** @return the index into the getPropertyDescriptors()
  104. ** that the user is most likely to use. Returns
  105. ** <CODE>-1</CODE> if there is no default event.
  106. **/
  107. int getDefaultPropertyIndex();
  108. /** Get the methods this Bean type supports.
  109. ** @return the MethodDescriptors representing the
  110. ** methods this Bean type supports. Returns
  111. ** <CODE>null</CODE> if the methods are to be
  112. ** obtained by Introspection.
  113. **/
  114. MethodDescriptor[] getMethodDescriptors();
  115. /** Get additional BeanInfos representing this Bean.
  116. ** In this version of JavaBeans, this method is used so
  117. ** that space and time can be saved by reading a BeanInfo
  118. ** for each class in the hierarchy (super, super(super),
  119. ** and so on).<P>
  120. **
  121. ** The order of precedence when two pieces of BeanInfo
  122. ** conflict (such as two PropertyDescriptors that have
  123. ** the same name), in order from highest precedence to
  124. ** lowest, is:
  125. ** <OL>
  126. ** <LI>This BeanInfo object.</LI>
  127. ** <LI><CODE>getAdditionalBeanInfo()[getAdditionalBeanInfo().length]</CODE></LI>
  128. ** <LI> ... </LI>
  129. ** <LI><CODE>getAdditionalBeanInfo()[1]</CODE></LI>
  130. ** <LI><CODE>getAdditionalBeanInfo()[0]</CODE></LI>
  131. ** </OL><P>
  132. **
  133. ** <STRONG>Spec Note:</STRONG> It is possible that
  134. ** returning <CODE>null</CODE> from this method could
  135. ** stop Introspection in its tracks, but it is unclear
  136. ** from the spec whether this is the case.
  137. **
  138. ** @return additional BeanInfos representing this Bean.
  139. ** <CODE>null</CODE> may be returned (see Spec
  140. ** Note, above).
  141. **/
  142. BeanInfo[] getAdditionalBeanInfo();
  143. /** Get a visual icon for this Bean.
  144. ** A Bean does not have to support icons, and if it does
  145. ** support icons, it does not have to support every single
  146. ** type. Sun recommends that if you only support one
  147. ** type, you support 16x16 color. Sun also notes that you
  148. ** should try to use a type (like GIF) that allows for
  149. ** transparent pixels, so that the background of the RAD
  150. ** tool can show through.<P>
  151. **
  152. ** <STRONG>Spec Note:</STRONG> If you do not support the
  153. ** type of icon that is being asked for, but you do
  154. ** support another type, it is unclear whether you should
  155. ** return the other type or not. I would presume not.
  156. **
  157. ** @param iconType the type of icon to get (see the
  158. ** ICON_* constants in this class).
  159. ** @return the icon, or null if that type of icon is
  160. ** unsupported by this Bean.
  161. **/
  162. java.awt.Image getIcon(int iconType);
  163. }