KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > beans > BeanDescriptor


1 /*
2  * @(#)BeanDescriptor.java 1.23 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.beans;
9
10 import java.lang.ref.Reference JavaDoc;
11
12 /**
13  * A BeanDescriptor provides global information about a "bean",
14  * including its Java class, its displayName, etc.
15  * <p>
16  * This is one of the kinds of descriptor returned by a BeanInfo object,
17  * which also returns descriptors for properties, method, and events.
18  */

19
20 public class BeanDescriptor extends FeatureDescriptor JavaDoc {
21
22     private Reference JavaDoc beanClassRef;
23     private Reference JavaDoc customizerClassRef;
24
25     /**
26      * Create a BeanDescriptor for a bean that doesn't have 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      */

31     public BeanDescriptor(Class JavaDoc<?> beanClass) {
32     this(beanClass, null);
33     }
34
35     /**
36      * Create a BeanDescriptor for a bean that has a customizer.
37      *
38      * @param beanClass The Class object of the Java class that implements
39      * the bean. For example sun.beans.OurButton.class.
40      * @param customizerClass The Class object of the Java class that implements
41      * the bean's Customizer. For example sun.beans.OurButtonCustomizer.class.
42      */

43     public BeanDescriptor(Class JavaDoc<?> beanClass, Class JavaDoc<?> customizerClass) {
44     beanClassRef = createReference(beanClass);
45     customizerClassRef = createReference(customizerClass);
46
47     String JavaDoc name = beanClass.getName();
48     while (name.indexOf('.') >= 0) {
49         name = name.substring(name.indexOf('.')+1);
50     }
51     setName(name);
52     }
53
54     /**
55      * Gets the bean's Class object.
56      *
57      * @return The Class object for the bean.
58      */

59     public Class JavaDoc<?> getBeanClass() {
60     return (Class JavaDoc)getObject(beanClassRef);
61     }
62
63     /**
64      * Gets the Class object for the bean's customizer.
65      *
66      * @return The Class object for the bean's customizer. This may
67      * be null if the bean doesn't have a customizer.
68      */

69     public Class JavaDoc<?> getCustomizerClass() {
70     return (Class JavaDoc)getObject(customizerClassRef);
71     }
72
73     /*
74      * Package-private dup constructor
75      * This must isolate the new object from any changes to the old object.
76      */

77     BeanDescriptor(BeanDescriptor JavaDoc old) {
78     super(old);
79     beanClassRef = old.beanClassRef;
80     customizerClassRef = old.customizerClassRef;
81     }
82 }
83
Popular Tags