001 /* java.beans.SimpleBeanInfo
002 Copyright (C) 1998, 2006, Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package java.beans;
040
041 import java.awt.Image;
042 import java.awt.Toolkit;
043 import java.net.URL;
044
045 /**
046 ** SimpleBeanInfo is a class you may extend to more easily
047 ** provide select information to the Introspector. It
048 ** implements all of the methods in BeanInfo by returning
049 ** null and forces the Introspector to behave exactly as
050 ** if there were no BeanInfo class at all (Introspecting
051 ** everything).<P>
052 **
053 ** Overriding one or two of these functions
054 ** to give explicit information on only those things you
055 ** wish to give explicit information is perfectly safe,
056 ** and even desirable.<P>
057 **
058 ** See the BeanInfo class for information on what the
059 ** various methods actually do.
060 **
061 ** @author John Keiser
062 ** @since JDK1.1
063 ** @version 1.1.0, 29 Jul 1998
064 ** @see java.beans.BeanInfo
065 **/
066
067 public class SimpleBeanInfo implements BeanInfo {
068 /** Force Introspection of the general bean info.
069 ** @return <CODE>null</CODE>.
070 **/
071 public BeanDescriptor getBeanDescriptor() {
072 return null;
073 }
074
075 /** Force Introspection of the events this Bean type
076 ** fires.
077 ** @return <CODE>null</CODE>
078 **/
079 public EventSetDescriptor[] getEventSetDescriptors() {
080 return null;
081 }
082
083 /** Say that there is no "default" event set.
084 ** @return <CODE>-1</CODE>.
085 **/
086 public int getDefaultEventIndex() {
087 return -1;
088 }
089
090 /** Force Introspection of the Bean properties.
091 ** @return <CODE>null</CODE>.
092 **/
093 public PropertyDescriptor[] getPropertyDescriptors() {
094 return null;
095 }
096
097 /** Say that there is no "default" property.
098 ** @return <CODE>-1</CODE>.
099 **/
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 }