home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / beans / BeanInfo.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  6.0 KB  |  161 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)BeanInfo.java    1.22 98/09/21
  3.  *
  4.  * Copyright 1996-1998 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 bean implementor who wishes to provide explicit information about
  19.  * their bean may provide a BeanInfo class that implements this BeanInfo
  20.  * interface and provides explicit information about the methods,
  21.  * properties, events, etc, of their  bean.
  22.  * <p>
  23.  * A bean implementor doesn't need to provide a complete set of
  24.  * explicit information.  You can pick and choose which information
  25.  * you want to provide and the rest will be obtained by automatic
  26.  * analysis using low-level reflection of the bean classes' methods
  27.  * and applying standard design patterns.
  28.  * <p>
  29.  * You get the opportunity to provide lots and lots of different
  30.  * information as part of the various XyZDescriptor classes.  But
  31.  * don't panic, you only really need to provide the minimal core
  32.  * information required by the various constructors.
  33.  * <P>
  34.  * See also the SimpleBeanInfo class which provides a convenient
  35.  * "noop" base class for BeanInfo classes, which you can override
  36.  * for those specific places where you want to return explicit info.
  37.  * <P>
  38.  * To learn about all the behaviour of a bean see the Introspector class.
  39.  */
  40.  
  41. public interface BeanInfo {
  42.  
  43.     /**
  44.      * Gets the beans <code>BeanDescriptor</code>.
  45.      * 
  46.      * @return  A BeanDescriptor providing overall information about
  47.      * the bean, such as its displayName, its customizer, etc.  May
  48.      * return null if the information should be obtained by automatic
  49.      * analysis.
  50.      */
  51.     BeanDescriptor getBeanDescriptor();
  52.     
  53.     /**
  54.      * Gets the beans <code>EventSetDescriptor</code>s.
  55.      * 
  56.      * @return  An array of EventSetDescriptors describing the kinds of 
  57.      * events fired by this bean.  May return null if the information
  58.      * should be obtained by automatic analysis.
  59.      */
  60.     EventSetDescriptor[] getEventSetDescriptors();
  61.  
  62.     /**
  63.      * A bean may have a "default" event that is the event that will
  64.      * mostly commonly be used by human's when using the bean. 
  65.      * @return Index of default event in the EventSetDescriptor array
  66.      *        returned by getEventSetDescriptors.
  67.      * <P>    Returns -1 if there is no default event.
  68.      */
  69.     int getDefaultEventIndex();
  70.  
  71.     /**
  72.      * Gets the beans <code>PropertyDescriptor</code>s.
  73.      * 
  74.      * @return An array of PropertyDescriptors describing the editable
  75.      * properties supported by this bean.  May return null if the
  76.      * information should be obtained by automatic analysis.
  77.      * <p>
  78.      * If a property is indexed, then its entry in the result array will
  79.      * belong to the IndexedPropertyDescriptor subclass of PropertyDescriptor.
  80.      * A client of getPropertyDescriptors can use "instanceof" to check
  81.      * if a given PropertyDescriptor is an IndexedPropertyDescriptor.
  82.      */
  83.     PropertyDescriptor[] getPropertyDescriptors();
  84.  
  85.     /**
  86.      * A bean may have a "default" property that is the property that will
  87.      * mostly commonly be initially chosen for update by human's who are 
  88.      * customizing the bean.
  89.      * @return  Index of default property in the PropertyDescriptor array
  90.      *         returned by getPropertyDescriptors.
  91.      * <P>    Returns -1 if there is no default property.
  92.      */
  93.     int getDefaultPropertyIndex();
  94.  
  95.     /**
  96.      * Gets the beans <code>MethodDescriptor</code>s.
  97.      * 
  98.      * @return An array of MethodDescriptors describing the externally
  99.      * visible methods supported by this bean.  May return null if
  100.      * the information should be obtained by automatic analysis.
  101.      */
  102.     MethodDescriptor[] getMethodDescriptors();
  103.  
  104.     /**
  105.      * This method allows a BeanInfo object to return an arbitrary collection
  106.      * of other BeanInfo objects that provide additional information on the
  107.      * current bean.
  108.      * <P>
  109.      * If there are conflicts or overlaps between the information provided
  110.      * by different BeanInfo objects, then the current BeanInfo takes precedence
  111.      * over the getAdditionalBeanInfo objects, and later elements in the array
  112.      * take precedence over earlier ones.
  113.      *
  114.      * @return an array of BeanInfo objects.  May return null.
  115.      */
  116.     BeanInfo[] getAdditionalBeanInfo();
  117.  
  118.     /**
  119.      * This method returns an image object that can be used to
  120.      * represent the bean in toolboxes, toolbars, etc.   Icon images
  121.      * will typically be GIFs, but may in future include other formats.
  122.      * <p>
  123.      * Beans aren't required to provide icons and may return null from
  124.      * this method.
  125.      * <p>
  126.      * There are four possible flavors of icons (16x16 color,
  127.      * 32x32 color, 16x16 mono, 32x32 mono).  If a bean choses to only
  128.      * support a single icon we recommend supporting 16x16 color.
  129.      * <p>
  130.      * We recommend that icons have a "transparent" background
  131.      * so they can be rendered onto an existing background.
  132.      *
  133.      * @param  iconKind  The kind of icon requested.  This should be
  134.      *    one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32, 
  135.      *    ICON_MONO_16x16, or ICON_MONO_32x32.
  136.      * @return  An image object representing the requested icon.  May
  137.      *    return null if no suitable icon is available.
  138.      */
  139.     java.awt.Image getIcon(int iconKind);
  140.      
  141.     /**
  142.      * Constant to indicate a 16 x 16 color icon.
  143.      */
  144.     final static int ICON_COLOR_16x16 = 1;
  145.  
  146.     /**
  147.      * Constant to indicate a 32 x 32 color icon.
  148.      */
  149.     final static int ICON_COLOR_32x32 = 2;
  150.  
  151.     /**
  152.      * Constant to indicate a 16 x 16 monochrome icon.
  153.      */
  154.     final static int ICON_MONO_16x16 = 3;
  155.  
  156.     /**
  157.      * Constant to indicate a 32 x 32 monochrome icon.
  158.      */
  159.     final static int ICON_MONO_32x32 = 4;
  160. }
  161.