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