1 /*
   2  * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.beans;
  27 
  28 import java.awt.Image;
  29 
  30 /**
  31  * Use the {@code BeanInfo} interface
  32  * to create a {@code BeanInfo} class
  33  * and provide explicit information about the methods,
  34  * properties, events, and other features of your beans.
  35  * <p>
  36  * When developing your bean, you can implement
  37  * the bean features required for your application task
  38  * omitting the rest of the {@code BeanInfo} features.
  39  * They will be obtained through the automatic analysis
  40  * by using the low-level reflection of the bean methods
  41  * and applying standard design patterns.
  42  * You have an opportunity to provide additional bean information
  43  * through various descriptor classes.
  44  * <p>
  45  * See the {@link SimpleBeanInfo} class that is
  46  * a convenient basic class for {@code BeanInfo} classes.
  47  * You can override the methods and properties of
  48  * the {@code SimpleBeanInfo} class to define specific information.
  49  * <p>
  50  * See also the {@link Introspector} class to learn more about bean behavior.
  51  */
  52 public interface BeanInfo {
  53 
  54     /**
  55      * Returns the bean descriptor
  56      * that provides overall information about the bean,
  57      * such as its display name or its customizer.
  58      *
  59      * @return  a {@link BeanDescriptor} object,
  60      *          or {@code null} if the information is to
  61      *          be obtained through the automatic analysis
  62      */
  63     BeanDescriptor getBeanDescriptor();
  64 
  65     /**
  66      * Returns the event descriptors of the bean
  67      * that define the types of events fired by this bean.
  68      *
  69      * @return  an array of {@link EventSetDescriptor} objects,
  70      *          or {@code null} if the information is to
  71      *          be obtained through the automatic analysis
  72      */
  73     EventSetDescriptor[] getEventSetDescriptors();
  74 
  75     /**
  76      * A bean may have a default event typically applied when this bean is used.
  77      *
  78      * @return  index of the default event in the {@code EventSetDescriptor} array
  79      *          returned by the {@code getEventSetDescriptors} method,
  80      *          or -1 if there is no default event
  81      */
  82     int getDefaultEventIndex();
  83 
  84     /**
  85      * Returns descriptors for all properties of the bean.
  86      * <p>
  87      * If a property is indexed, then its entry in the result array
  88      * belongs to the {@link IndexedPropertyDescriptor} subclass
  89      * of the {@link PropertyDescriptor} class.
  90      * A client of the {@code getPropertyDescriptors} method
  91      * can use the {@code instanceof} operator to check
  92      * whether a given {@code PropertyDescriptor}
  93      * is an {@code IndexedPropertyDescriptor}.
  94      *
  95      * @return  an array of {@code PropertyDescriptor} objects,
  96      *          or {@code null} if the information is to
  97      *          be obtained through the automatic analysis
  98      */
  99     PropertyDescriptor[] getPropertyDescriptors();
 100 
 101     /**
 102      * A bean may have a default property commonly updated when this bean is customized.
 103      *
 104      * @return  index of the default property in the {@code PropertyDescriptor} array
 105      *          returned by the {@code getPropertyDescriptors} method,
 106      *          or -1 if there is no default property
 107      */
 108     int getDefaultPropertyIndex();
 109 
 110     /**
 111      * Returns the method descriptors of the bean
 112      * that define the externally visible methods supported by this bean.
 113      *
 114      * @return  an array of {@link MethodDescriptor} objects,
 115      *          or {@code null} if the information is to
 116      *          be obtained through the automatic analysis
 117      */
 118     MethodDescriptor[] getMethodDescriptors();
 119 
 120     /**
 121      * This method enables the current {@code BeanInfo} object
 122      * to return an arbitrary collection of other {@code BeanInfo} objects
 123      * that provide additional information about the current bean.
 124      * <p>
 125      * If there are conflicts or overlaps between the information
 126      * provided by different {@code BeanInfo} objects,
 127      * the current {@code BeanInfo} object takes priority
 128      * over the additional {@code BeanInfo} objects.
 129      * Array elements with higher indices take priority
 130      * over the elements with lower indices.
 131      *
 132      * @return  an array of {@code BeanInfo} objects,
 133      *          or {@code null} if there are no additional {@code BeanInfo} objects
 134      */
 135     BeanInfo[] getAdditionalBeanInfo();
 136 
 137     /**
 138      * Returns an image that can be used to represent the bean in toolboxes or toolbars.
 139      * <p>
 140      * There are four possible types of icons:
 141      * 16 x 16 color, 32 x 32 color, 16 x 16 mono, and 32 x 32 mono.
 142      * If you implement a bean so that it supports a single icon,
 143      * it is recommended to use 16 x 16 color.
 144      * Another recommendation is to set a transparent background for the icons.
 145      *
 146      * @param  iconKind  the kind of icon requested
 147      * @return           an image object representing the requested icon,
 148      *                   or {@code null} if no suitable icon is available
 149      *
 150      * @see #ICON_COLOR_16x16
 151      * @see #ICON_COLOR_32x32
 152      * @see #ICON_MONO_16x16
 153      * @see #ICON_MONO_32x32
 154      */
 155     Image getIcon(int iconKind);
 156 
 157     /**
 158      * Constant to indicate a 16 x 16 color icon.
 159      */
 160     final static int ICON_COLOR_16x16 = 1;
 161 
 162     /**
 163      * Constant to indicate a 32 x 32 color icon.
 164      */
 165     final static int ICON_COLOR_32x32 = 2;
 166 
 167     /**
 168      * Constant to indicate a 16 x 16 monochrome icon.
 169      */
 170     final static int ICON_MONO_16x16 = 3;
 171 
 172     /**
 173      * Constant to indicate a 32 x 32 monochrome icon.
 174      */
 175     final static int ICON_MONO_32x32 = 4;
 176 }