home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / beans / BeanDescriptor.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.4 KB  |  82 lines

  1. /*
  2.  * @(#)BeanDescriptor.java    1.13 98/03/18
  3.  *
  4.  * Copyright 1996, 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.beans;
  16.  
  17. /**
  18.  * A BeanDescriptor provides global information about a "bean",
  19.  * including its Java class, its displayName, etc.
  20.  * <p>
  21.  * This is one of the kinds of descriptor returned by a BeanInfo object,
  22.  * which also returns descriptors for properties, method, and events.
  23.  */
  24.  
  25. public class BeanDescriptor extends FeatureDescriptor {
  26.  
  27.     /**
  28.      * Create a BeanDescriptor for a bean that doesn't have a customizer.
  29.      * @param beanClass  The Class object of the Java class that implements
  30.      *        the bean.  For example sun.beans.OurButton.class.
  31.      */
  32.     public BeanDescriptor(Class beanClass) {
  33.     this(beanClass, null);
  34.     }
  35.  
  36.     /**
  37.      * Create a BeanDescriptor for a bean that has a customizer.
  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 beanClass, Class customizerClass) {
  44.     this.beanClass = beanClass;
  45.     this.customizerClass = customizerClass;
  46.     String name = beanClass.getName();
  47.     while (name.indexOf('.') >= 0) {
  48.         name = name.substring(name.indexOf('.')+1);
  49.     }
  50.     setName(name);
  51.     }
  52.  
  53.     /**
  54.      * @return The Class object for the bean.
  55.      */
  56.     public Class getBeanClass() {
  57.     return beanClass;
  58.     }
  59.  
  60.     /**
  61.      * @return The Class object for the bean's customizer.  This may
  62.      * be null if the bean doesn't have a customizer.
  63.      */
  64.     public Class getCustomizerClass() {
  65.     return customizerClass;
  66.     }
  67.  
  68.     /*
  69.      * Package-private dup constructor
  70.      * This must isolate the new object from any changes to the old object.
  71.      */
  72.     BeanDescriptor(BeanDescriptor old) {
  73.     super(old);
  74.     beanClass = old.beanClass;
  75.     customizerClass = old.customizerClass;
  76.     }
  77.  
  78.     private Class beanClass;
  79.     private Class customizerClass;
  80.  
  81. }
  82.