FileDocCategorySizeDatePackage
CoolerBeanInfo.javaAPI DocExample1885Wed Jun 04 00:06:12 BST 1997BeansBook.Simulator

CoolerBeanInfo.java

// This example is from the book Developing Java Beans by Robert Englander. 
// Copyright (c) 1997 O'Reilly & Associates.
// You may study, use, modify, and distribute this example for any purpose.
// This example is provided WITHOUT WARRANTY either expressed or implied.

// Chapter 9 -- The CoolerBeanInfo class

package BeansBook.Simulator;

import java.beans.*;
import java.lang.reflect.*;

public class CoolerBeanInfo extends SimpleBeanInfo
{
   // return the bean descriptor
   public BeanDescriptor getBeanDescriptor() 
   {
      // create the bean descriptor object
      BeanDescriptor bd = new BeanDescriptor(Cooler.class);
       
      // set the display name
      bd.setDisplayName("Simulated Cooler");
      
      // return the descriptor object
      return bd;
   }

   // return the property descriptos
   public PropertyDescriptor[] getPropertyDescriptors()
   {
      // for now this class defines none of its own properties,
      // but this is implemented as a place holder
      try
      {
         // create an empty array of descriptors
         PropertyDescriptor[] pda = { };
        
         // return the array
         return pda;
      }
      catch (Exception e)
      {
         return null;
      }
   }
   
   // return the additional bean info objects for the bean
   public BeanInfo[] getAdditionalBeanInfo()
   {
      try
      {
         // create a bean info array that contains one object, which is 
         // the bean info for the base TemperatureModifier class.  this
         // bean info is retrieved via the Introspector
         BeanInfo[] bia = { Introspector.getBeanInfo(TemperatureModifier.class) };
         
         // return the bean info array
         return bia;
      }
      catch (IntrospectionException e)
      {
         return null;
      }
   }
}