1. /*
  2. * @(#)SimpleBeanInfo.java 1.24 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. * This is a support class to make it easier for people to provide
  13. * BeanInfo classes.
  14. * <p>
  15. * It defaults to providing "noop" information, and can be selectively
  16. * overriden to provide more explicit information on chosen topics.
  17. * When the introspector sees the "noop" values, it will apply low
  18. * level introspection and design patterns to automatically analyze
  19. * the target bean.
  20. */
  21. public class SimpleBeanInfo implements BeanInfo {
  22. /**
  23. * Deny knowledge about the class and customizer of the bean.
  24. * You can override this if you wish to provide explicit info.
  25. */
  26. public BeanDescriptor getBeanDescriptor() {
  27. return null;
  28. }
  29. /**
  30. * Deny knowledge of properties. You can override this
  31. * if you wish to provide explicit property info.
  32. */
  33. public PropertyDescriptor[] getPropertyDescriptors() {
  34. return null;
  35. }
  36. /**
  37. * Deny knowledge of a default property. You can override this
  38. * if you wish to define a default property for the bean.
  39. */
  40. public int getDefaultPropertyIndex() {
  41. return -1;
  42. }
  43. /**
  44. * Deny knowledge of event sets. You can override this
  45. * if you wish to provide explicit event set info.
  46. */
  47. public EventSetDescriptor[] getEventSetDescriptors() {
  48. return null;
  49. }
  50. /**
  51. * Deny knowledge of a default event. You can override this
  52. * if you wish to define a default event for the bean.
  53. */
  54. public int getDefaultEventIndex() {
  55. return -1;
  56. }
  57. /**
  58. * Deny knowledge of methods. You can override this
  59. * if you wish to provide explicit method info.
  60. */
  61. public MethodDescriptor[] getMethodDescriptors() {
  62. return null;
  63. }
  64. /**
  65. * Claim there are no other relevant BeanInfo objects. You
  66. * may override this if you want to (for example) return a
  67. * BeanInfo for a base class.
  68. */
  69. public BeanInfo[] getAdditionalBeanInfo() {
  70. return null;
  71. }
  72. /**
  73. * Claim there are no icons available. You can override
  74. * this if you want to provide icons for your bean.
  75. */
  76. public java.awt.Image getIcon(int iconKind) {
  77. return null;
  78. }
  79. /**
  80. * This is a utility method to help in loading icon images.
  81. * It takes the name of a resource file associated with the
  82. * current object's class file and loads an image object
  83. * from that file. Typically images will be GIFs.
  84. * <p>
  85. * @param resourceName A pathname relative to the directory
  86. * holding the class file of the current class. For example,
  87. * "wombat.gif".
  88. * @return an image object. May be null if the load failed.
  89. */
  90. public java.awt.Image loadImage(final String resourceName) {
  91. try {
  92. final Class c = getClass();
  93. java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer)
  94. java.security.AccessController.doPrivileged(
  95. new java.security.PrivilegedAction() {
  96. public Object run() {
  97. java.net.URL url;
  98. if ((url = c.getResource(resourceName)) == null) {
  99. return null;
  100. } else {
  101. try {
  102. return url.getContent();
  103. } catch (java.io.IOException ioe) {
  104. return null;
  105. }
  106. }
  107. }
  108. });
  109. if (ip == null)
  110. return null;
  111. java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
  112. return tk.createImage(ip);
  113. } catch (Exception ex) {
  114. return null;
  115. }
  116. }
  117. }