Source for java.beans.SimpleBeanInfo

   1: /* java.beans.SimpleBeanInfo
   2:    Copyright (C) 1998, 2006, Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10:  
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package java.beans;
  40: 
  41: import java.awt.Image;
  42: import java.awt.Toolkit;
  43: import java.net.URL;
  44: 
  45: /**
  46:  ** SimpleBeanInfo is a class you may extend to more easily
  47:  ** provide select information to the Introspector.  It
  48:  ** implements all of the methods in BeanInfo by returning
  49:  ** null and forces the Introspector to behave exactly as
  50:  ** if there were no BeanInfo class at all (Introspecting
  51:  ** everything).<P>
  52:  **
  53:  ** Overriding one or two of these functions
  54:  ** to give explicit information on only those things you
  55:  ** wish to give explicit information is perfectly safe,
  56:  ** and even desirable.<P>
  57:  **
  58:  ** See the BeanInfo class for information on what the
  59:  ** various methods actually do.
  60:  **
  61:  ** @author John Keiser
  62:  ** @since JDK1.1
  63:  ** @version 1.1.0, 29 Jul 1998
  64:  ** @see java.beans.BeanInfo
  65:  **/
  66: 
  67: public class SimpleBeanInfo implements BeanInfo {
  68:     /** Force Introspection of the general bean info.
  69:      ** @return <CODE>null</CODE>.
  70:      **/
  71:     public BeanDescriptor getBeanDescriptor() {
  72:         return null;
  73:     }
  74: 
  75:     /** Force Introspection of the events this Bean type
  76:      ** fires.
  77:      ** @return <CODE>null</CODE>
  78:      **/
  79:     public EventSetDescriptor[] getEventSetDescriptors() {
  80:         return null;
  81:     }
  82: 
  83:     /** Say that there is no "default" event set.
  84:      ** @return <CODE>-1</CODE>.
  85:      **/
  86:     public int getDefaultEventIndex() {
  87:         return -1;
  88:     }
  89: 
  90:     /** Force Introspection of the Bean properties.
  91:      ** @return <CODE>null</CODE>.
  92:      **/
  93:     public PropertyDescriptor[] getPropertyDescriptors() {
  94:         return null;
  95:     }
  96: 
  97:     /** Say that there is no "default" property.
  98:      ** @return <CODE>-1</CODE>.
  99:      **/
 100:     public int getDefaultPropertyIndex() {
 101:         return -1;
 102:     }
 103: 
 104:     /** Force Introspection of the Bean's methods.
 105:      ** @return <CODE>null</CODE>.
 106:      **/
 107:     public MethodDescriptor[] getMethodDescriptors() {
 108:         return null;
 109:     }
 110: 
 111:     /** Tell the Introspector to go look for other BeanInfo
 112:      ** itself.
 113:      ** @return <CODE>null</CODE>.
 114:      **/
 115:     public BeanInfo[] getAdditionalBeanInfo() {
 116:         return null;
 117:     }
 118: 
 119:     /** Say that this Bean has no icons.
 120:      ** @param iconType the type of icon
 121:      ** @return <CODE>null</CODE>.
 122:      **/
 123:     public Image getIcon(int iconType) {
 124:         return null;
 125:     }
 126: 
 127:     /** Helper method to load an image using the Bean class
 128:      ** getResource() method on the BeanInfo class (using
 129:      ** getClass(), since you'll extend this class to get
 130:      ** the BeanInfo).  Basically it's assumed that the Bean
 131:      ** and its BeanInfo are both loaded by the same
 132:      ** ClassLoader, generally a reasonable assumption.
 133:      ** @param location the URL relative
 134:      ** @return the Image in question (possibly <code>null</code>).
 135:      **/
 136:     public Image loadImage(String location) 
 137:     {
 138:       if (location == null)
 139:         return null;
 140:       URL url = getClass().getResource(location);
 141:       if (url == null)
 142:         return null;
 143:       return Toolkit.getDefaultToolkit().getImage(url);
 144:     }
 145: }