Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.beans

Class Beans

java.lang.Object
|
+--java.beans.Beans


public class Beans

extends Object

Beans provides some helper methods that allow the basic operations of Bean-ness.

Since:Author:

Constructor Summary

Beans()

Once again, we have a java.beans class with only static methods that can be instantiated.

Method Summary

static java.lang.ObjectgetInstanceOf(java.lang.Object bean, java.lang.Class newClass)

Get the Bean as a different class type.
static java.lang.Objectinstantiate(java.lang.ClassLoader cl, java.lang.String beanName)

Allows you to instantiate a Bean.
static booleanisDesignTime()

Find out whether it is design time.
static booleanisGuiAvailable()

Find out whether the GUI is available to use.
static booleanisInstanceOf(java.lang.Object bean, java.lang.Class newBeanClass)

Determine whether the Bean can be cast to a different class type.
static voidsetDesignTime(boolean designTime)

Set whether it is design time.
static voidsetGuiAvailable(boolean guiAvailable)

Set whether the GUI is available to use.

Constructor Details

Beans

public Beans()

Once again, we have a java.beans class with only static methods that can be instantiated. When will the madness end? :)


Method Details

getInstanceOf

public static Object getInstanceOf(java.lang.Object bean, java.lang.Class newClass)

Get the Bean as a different class type. This should be used instead of casting to get a new type view of a Bean, because in the future there may be new types of Bean, even Beans spanning multiple Objects.

Parameters:

Returns:


instantiate

public static Object instantiate(java.lang.ClassLoader cl, java.lang.String beanName)

Allows you to instantiate a Bean. This method takes a ClassLoader from which to read the Bean and the name of the Bean.

The Bean name should be a dotted name, like a class. It can represent several things. Beans will search for the Bean using the name like this:

  1. Searches for a serialized instance of the Bean using getResource(), mangling the Bean name by replacing the dots with slashes and appending .ser (for example, gnu.beans.BlahDeBlah would cause Beans to search for gnu/beans/BlahDeBlah.ser using getResource()).
  2. Searches for the Bean class using the beanName, and then instantiates it with the no-arg constructor. At that point, if it is an Applet, it provides it with AppletContext and AppletStub, and then calls init().

Parameters:

Returns:


isDesignTime

public static boolean isDesignTime()

Find out whether it is design time. Design time means we are in a RAD tool. Defaults to false.

Returns:


isGuiAvailable

public static boolean isGuiAvailable()

Find out whether the GUI is available to use. Defaults to true.

Returns:


isInstanceOf

public static boolean isInstanceOf(java.lang.Object bean, java.lang.Class newBeanClass)

Determine whether the Bean can be cast to a different class type. This should be used instead of instanceof to determine a Bean's castability, because in the future there may be new types of Bean, even Beans spanning multiple Objects.

Parameters:

Returns:


setDesignTime

public static void setDesignTime(boolean designTime)

Set whether it is design time. Design time means we are in a RAD tool.

Parameters:


setGuiAvailable

public static void setGuiAvailable(boolean guiAvailable)

Set whether the GUI is available to use.

Parameters: