1. /*
  2. * @(#)BeanDescriptor.java 1.17 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 BeanDescriptor provides global information about a "bean",
  13. * including its Java class, its displayName, etc.
  14. * <p>
  15. * This is one of the kinds of descriptor returned by a BeanInfo object,
  16. * which also returns descriptors for properties, method, and events.
  17. */
  18. public class BeanDescriptor extends FeatureDescriptor {
  19. /**
  20. * Create a BeanDescriptor for a bean that doesn't have a customizer.
  21. *
  22. * @param beanClass The Class object of the Java class that implements
  23. * the bean. For example sun.beans.OurButton.class.
  24. */
  25. public BeanDescriptor(Class beanClass) {
  26. this(beanClass, null);
  27. }
  28. /**
  29. * Create a BeanDescriptor for a bean that has a customizer.
  30. *
  31. * @param beanClass The Class object of the Java class that implements
  32. * the bean. For example sun.beans.OurButton.class.
  33. * @param customizerClass The Class object of the Java class that implements
  34. * the bean's Customizer. For example sun.beans.OurButtonCustomizer.class.
  35. */
  36. public BeanDescriptor(Class beanClass, Class customizerClass) {
  37. this.beanClass = beanClass;
  38. this.customizerClass = customizerClass;
  39. String name = beanClass.getName();
  40. while (name.indexOf('.') >= 0) {
  41. name = name.substring(name.indexOf('.')+1);
  42. }
  43. setName(name);
  44. }
  45. /**
  46. * Gets the bean's Class object.
  47. *
  48. * @return The Class object for the bean.
  49. */
  50. public Class getBeanClass() {
  51. return beanClass;
  52. }
  53. /**
  54. * Gets the Class object for the bean's customizer.
  55. *
  56. * @return The Class object for the bean's customizer. This may
  57. * be null if the bean doesn't have a customizer.
  58. */
  59. public Class getCustomizerClass() {
  60. return customizerClass;
  61. }
  62. /*
  63. * Package-private dup constructor
  64. * This must isolate the new object from any changes to the old object.
  65. */
  66. BeanDescriptor(BeanDescriptor old) {
  67. super(old);
  68. beanClass = old.beanClass;
  69. customizerClass = old.customizerClass;
  70. }
  71. private Class beanClass;
  72. private Class customizerClass;
  73. }