Save This Page
Home » openjdk-7 » java » beans » [javadoc | source]
    1   /*
    2    * Copyright 1996-1998 Sun Microsystems, Inc.  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.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package java.beans;
   27   
   28   /**
   29    * This is a support class to make it easier for people to provide
   30    * BeanInfo classes.
   31    * <p>
   32    * It defaults to providing "noop" information, and can be selectively
   33    * overriden to provide more explicit information on chosen topics.
   34    * When the introspector sees the "noop" values, it will apply low
   35    * level introspection and design patterns to automatically analyze
   36    * the target bean.
   37    */
   38   
   39   public class SimpleBeanInfo implements BeanInfo {
   40   
   41       /**
   42        * Deny knowledge about the class and customizer of the bean.
   43        * You can override this if you wish to provide explicit info.
   44        */
   45       public BeanDescriptor getBeanDescriptor() {
   46           return null;
   47       }
   48   
   49       /**
   50        * Deny knowledge of properties. You can override this
   51        * if you wish to provide explicit property info.
   52        */
   53       public PropertyDescriptor[] getPropertyDescriptors() {
   54           return null;
   55       }
   56   
   57       /**
   58        * Deny knowledge of a default property. You can override this
   59        * if you wish to define a default property for the bean.
   60        */
   61       public int getDefaultPropertyIndex() {
   62           return -1;
   63       }
   64   
   65       /**
   66        * Deny knowledge of event sets. You can override this
   67        * if you wish to provide explicit event set info.
   68        */
   69       public EventSetDescriptor[] getEventSetDescriptors() {
   70           return null;
   71       }
   72   
   73       /**
   74        * Deny knowledge of a default event. You can override this
   75        * if you wish to define a default event for the bean.
   76        */
   77       public int getDefaultEventIndex() {
   78           return -1;
   79       }
   80   
   81       /**
   82        * Deny knowledge of methods. You can override this
   83        * if you wish to provide explicit method info.
   84        */
   85       public MethodDescriptor[] getMethodDescriptors() {
   86           return null;
   87       }
   88   
   89       /**
   90        * Claim there are no other relevant BeanInfo objects.  You
   91        * may override this if you want to (for example) return a
   92        * BeanInfo for a base class.
   93        */
   94       public BeanInfo[] getAdditionalBeanInfo() {
   95           return null;
   96       }
   97   
   98       /**
   99        * Claim there are no icons available.  You can override
  100        * this if you want to provide icons for your bean.
  101        */
  102       public java.awt.Image getIcon(int iconKind) {
  103           return null;
  104       }
  105   
  106       /**
  107        * This is a utility method to help in loading icon images.
  108        * It takes the name of a resource file associated with the
  109        * current object's class file and loads an image object
  110        * from that file.  Typically images will be GIFs.
  111        * <p>
  112        * @param resourceName  A pathname relative to the directory
  113        *          holding the class file of the current class.  For example,
  114        *          "wombat.gif".
  115        * @return  an image object.  May be null if the load failed.
  116        */
  117       public java.awt.Image loadImage(final String resourceName) {
  118           try {
  119               final Class c = getClass();
  120               java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer)
  121                   java.security.AccessController.doPrivileged(
  122                   new java.security.PrivilegedAction() {
  123                       public Object run() {
  124                           java.net.URL url;
  125                           if ((url = c.getResource(resourceName)) == null) {
  126                               return null;
  127                           } else {
  128                               try {
  129                                   return url.getContent();
  130                               } catch (java.io.IOException ioe) {
  131                                   return null;
  132                               }
  133                           }
  134                       }
  135               });
  136   
  137               if (ip == null)
  138                   return null;
  139               java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
  140               return tk.createImage(ip);
  141           } catch (Exception ex) {
  142               return null;
  143           }
  144       }
  145   
  146   }

Save This Page
Home » openjdk-7 » java » beans » [javadoc | source]