SimpleBeanInfo.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* java.beans.SimpleBeanInfo
  2. Copyright (C) 1998, 2006, 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. import java.awt.Image;
  33. import java.awt.Toolkit;
  34. import java.net.URL;
  35. /**
  36. ** SimpleBeanInfo is a class you may extend to more easily
  37. ** provide select information to the Introspector. It
  38. ** implements all of the methods in BeanInfo by returning
  39. ** null and forces the Introspector to behave exactly as
  40. ** if there were no BeanInfo class at all (Introspecting
  41. ** everything).<P>
  42. **
  43. ** Overriding one or two of these functions
  44. ** to give explicit information on only those things you
  45. ** wish to give explicit information is perfectly safe,
  46. ** and even desirable.<P>
  47. **
  48. ** See the BeanInfo class for information on what the
  49. ** various methods actually do.
  50. **
  51. ** @author John Keiser
  52. ** @since JDK1.1
  53. ** @version 1.1.0, 29 Jul 1998
  54. ** @see java.beans.BeanInfo
  55. **/
  56. public class SimpleBeanInfo implements BeanInfo {
  57. /** Force Introspection of the general bean info.
  58. ** @return <CODE>null</CODE>.
  59. **/
  60. public BeanDescriptor getBeanDescriptor() {
  61. return null;
  62. }
  63. /** Force Introspection of the events this Bean type
  64. ** fires.
  65. ** @return <CODE>null</CODE>
  66. **/
  67. public EventSetDescriptor[] getEventSetDescriptors() {
  68. return null;
  69. }
  70. /** Say that there is no "default" event set.
  71. ** @return <CODE>-1</CODE>.
  72. **/
  73. public int getDefaultEventIndex() {
  74. return -1;
  75. }
  76. /** Force Introspection of the Bean properties.
  77. ** @return <CODE>null</CODE>.
  78. **/
  79. public PropertyDescriptor[] getPropertyDescriptors() {
  80. return null;
  81. }
  82. /** Say that there is no "default" property.
  83. ** @return <CODE>-1</CODE>.
  84. **/
  85. public int getDefaultPropertyIndex() {
  86. return -1;
  87. }
  88. /** Force Introspection of the Bean's methods.
  89. ** @return <CODE>null</CODE>.
  90. **/
  91. public MethodDescriptor[] getMethodDescriptors() {
  92. return null;
  93. }
  94. /** Tell the Introspector to go look for other BeanInfo
  95. ** itself.
  96. ** @return <CODE>null</CODE>.
  97. **/
  98. public BeanInfo[] getAdditionalBeanInfo() {
  99. return null;
  100. }
  101. /** Say that this Bean has no icons.
  102. ** @param iconType the type of icon
  103. ** @return <CODE>null</CODE>.
  104. **/
  105. public Image getIcon(int iconType) {
  106. return null;
  107. }
  108. /** Helper method to load an image using the Bean class
  109. ** getResource() method on the BeanInfo class (using
  110. ** getClass(), since you'll extend this class to get
  111. ** the BeanInfo). Basically it's assumed that the Bean
  112. ** and its BeanInfo are both loaded by the same
  113. ** ClassLoader, generally a reasonable assumption.
  114. ** @param location the URL relative
  115. ** @return the Image in question (possibly <code>null</code>).
  116. **/
  117. public Image loadImage(String location)
  118. {
  119. if (location == null)
  120. return null;
  121. URL url = getClass().getResource(location);
  122. if (url == null)
  123. return null;
  124. return Toolkit.getDefaultToolkit().getImage(url);
  125. }
  126. }