java.beans
Class Beans

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.beans.Beans

public class Beans
extends Object sample code for java.lang.Object definition code for java.lang.Object

This class provides some general purpose beans control methods.


Constructor Summary
Beans sample code for java.beans.Beans.Beans() definition code for java.beans.Beans.Beans() ()
           
 
Method Summary
static Object sample code for java.lang.Object definition code for java.lang.Object getInstanceOf sample code for java.beans.Beans.getInstanceOf(java.lang.Object, java.lang.Class) definition code for java.beans.Beans.getInstanceOf(java.lang.Object, java.lang.Class) (Object sample code for java.lang.Object definition code for java.lang.Object  bean, Class sample code for java.lang.Class definition code for java.lang.Class <?> targetType)
          From a given bean, obtain an object representing a specified type view of that source object.
static Object sample code for java.lang.Object definition code for java.lang.Object instantiate sample code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String) definition code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String) (ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  cls, String sample code for java.lang.String definition code for java.lang.String  beanName)
           Instantiate a JavaBean.
static Object sample code for java.lang.Object definition code for java.lang.Object instantiate sample code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext) definition code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext) (ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  cls, String sample code for java.lang.String definition code for java.lang.String  beanName, BeanContext sample code for java.beans.beancontext.BeanContext definition code for java.beans.beancontext.BeanContext  beanContext)
           Instantiate a JavaBean.
static Object sample code for java.lang.Object definition code for java.lang.Object instantiate sample code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext, java.beans.AppletInitializer) definition code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext, java.beans.AppletInitializer) (ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  cls, String sample code for java.lang.String definition code for java.lang.String  beanName, BeanContext sample code for java.beans.beancontext.BeanContext definition code for java.beans.beancontext.BeanContext  beanContext, AppletInitializer sample code for java.beans.AppletInitializer definition code for java.beans.AppletInitializer  initializer)
          Instantiate a bean.
static boolean isDesignTime sample code for java.beans.Beans.isDesignTime() definition code for java.beans.Beans.isDesignTime() ()
          Test if we are in design-mode.
static boolean isGuiAvailable sample code for java.beans.Beans.isGuiAvailable() definition code for java.beans.Beans.isGuiAvailable() ()
          Determines whether beans can assume a GUI is available.
static boolean isInstanceOf sample code for java.beans.Beans.isInstanceOf(java.lang.Object, java.lang.Class) definition code for java.beans.Beans.isInstanceOf(java.lang.Object, java.lang.Class) (Object sample code for java.lang.Object definition code for java.lang.Object  bean, Class sample code for java.lang.Class definition code for java.lang.Class <?> targetType)
          Check if a bean can be viewed as a given target type.
static void setDesignTime sample code for java.beans.Beans.setDesignTime(boolean) definition code for java.beans.Beans.setDesignTime(boolean) (boolean isDesignTime)
          Used to indicate whether of not we are running in an application builder environment.
static void setGuiAvailable sample code for java.beans.Beans.setGuiAvailable(boolean) definition code for java.beans.Beans.setGuiAvailable(boolean) (boolean isGuiAvailable)
          Used to indicate whether of not we are running in an environment where GUI interaction is available.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

Beans sample code for java.beans.Beans() definition code for java.beans.Beans()

public Beans()
Method Detail

instantiate sample code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String) definition code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String)

public static Object sample code for java.lang.Object definition code for java.lang.Object  instantiate(ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  cls,
                                 String sample code for java.lang.String definition code for java.lang.String  beanName)
                          throws IOException sample code for java.io.IOException definition code for java.io.IOException ,
                                 ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException 

Instantiate a JavaBean.

Parameters:
cls - the class-loader from which we should create the bean. If this is null, then the system class-loader is used.
beanName - the name of the bean within the class-loader. For example "sun.beanbox.foobah"
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - if the class of a serialized object could not be found.
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs.

instantiate sample code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext) definition code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext)

public static Object sample code for java.lang.Object definition code for java.lang.Object  instantiate(ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  cls,
                                 String sample code for java.lang.String definition code for java.lang.String  beanName,
                                 BeanContext sample code for java.beans.beancontext.BeanContext definition code for java.beans.beancontext.BeanContext  beanContext)
                          throws IOException sample code for java.io.IOException definition code for java.io.IOException ,
                                 ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException 

Instantiate a JavaBean.

Parameters:
cls - the class-loader from which we should create the bean. If this is null, then the system class-loader is used.
beanName - the name of the bean within the class-loader. For example "sun.beanbox.foobah"
beanContext - The BeanContext in which to nest the new bean
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - if the class of a serialized object could not be found.
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs.

instantiate sample code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext, java.beans.AppletInitializer) definition code for java.beans.Beans.instantiate(java.lang.ClassLoader, java.lang.String, java.beans.beancontext.BeanContext, java.beans.AppletInitializer)

public static Object sample code for java.lang.Object definition code for java.lang.Object  instantiate(ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  cls,
                                 String sample code for java.lang.String definition code for java.lang.String  beanName,
                                 BeanContext sample code for java.beans.beancontext.BeanContext definition code for java.beans.beancontext.BeanContext  beanContext,
                                 AppletInitializer sample code for java.beans.AppletInitializer definition code for java.beans.AppletInitializer  initializer)
                          throws IOException sample code for java.io.IOException definition code for java.io.IOException ,
                                 ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException 
Instantiate a bean.

The bean is created based on a name relative to a class-loader. This name should be a dot-separated name such as "a.b.c".

In Beans 1.0 the given name can indicate either a serialized object or a class. Other mechanisms may be added in the future. In beans 1.0 we first try to treat the beanName as a serialized object name then as a class name.

When using the beanName as a serialized object name we convert the given beanName to a resource pathname and add a trailing ".ser" suffix. We then try to load a serialized object from that resource.

For example, given a beanName of "x.y", Beans.instantiate would first try to read a serialized object from the resource "x/y.ser" and if that failed it would try to load the class "x.y" and create an instance of that class.

If the bean is a subtype of java.applet.Applet, then it is given some special initialization. First, it is supplied with a default AppletStub and AppletContext. Second, if it was instantiated from a classname the applet's "init" method is called. (If the bean was deserialized this step is skipped.)

Note that for beans which are applets, it is the caller's responsiblity to call "start" on the applet. For correct behaviour, this should be done after the applet has been added into a visible AWT container.

Note that applets created via beans.instantiate run in a slightly different environment than applets running inside browsers. In particular, bean applets have no access to "parameters", so they may wish to provide property get/set methods to set parameter values. We advise bean-applet developers to test their bean-applets against both the JDK appletviewer (for a reference browser environment) and the BDK BeanBox (for a reference bean container).

Parameters:
cls - the class-loader from which we should create the bean. If this is null, then the system class-loader is used.
beanName - the name of the bean within the class-loader. For example "sun.beanbox.foobah"
beanContext - The BeanContext in which to nest the new bean
initializer - The AppletInitializer for the new bean
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - if the class of a serialized object could not be found.
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs.

getInstanceOf sample code for java.beans.Beans.getInstanceOf(java.lang.Object, java.lang.Class<?>) definition code for java.beans.Beans.getInstanceOf(java.lang.Object, java.lang.Class<?>)

public static Object sample code for java.lang.Object definition code for java.lang.Object  getInstanceOf(Object sample code for java.lang.Object definition code for java.lang.Object  bean,
                                   Class sample code for java.lang.Class definition code for java.lang.Class <?> targetType)
From a given bean, obtain an object representing a specified type view of that source object.

The result may be the same object or a different object. If the requested target view isn't available then the given bean is returned.

This method is provided in Beans 1.0 as a hook to allow the addition of more flexible bean behaviour in the future.

Parameters:
bean - Object from which we want to obtain a view.
targetType - The type of view we'd like to get.

isInstanceOf sample code for java.beans.Beans.isInstanceOf(java.lang.Object, java.lang.Class<?>) definition code for java.beans.Beans.isInstanceOf(java.lang.Object, java.lang.Class<?>)

public static boolean isInstanceOf(Object sample code for java.lang.Object definition code for java.lang.Object  bean,
                                   Class sample code for java.lang.Class definition code for java.lang.Class <?> targetType)
Check if a bean can be viewed as a given target type. The result will be true if the Beans.getInstanceof method can be used on the given bean to obtain an object that represents the specified targetType type view.

Parameters:
bean - Bean from which we want to obtain a view.
targetType - The type of view we'd like to get.
Returns:
"true" if the given bean supports the given targetType.

isDesignTime sample code for java.beans.Beans.isDesignTime() definition code for java.beans.Beans.isDesignTime()

public static boolean isDesignTime()
Test if we are in design-mode.

Returns:
True if we are running in an application construction environment.
See Also:
DesignMode sample code for java.beans.DesignMode definition code for java.beans.DesignMode

isGuiAvailable sample code for java.beans.Beans.isGuiAvailable() definition code for java.beans.Beans.isGuiAvailable()

public static boolean isGuiAvailable()
Determines whether beans can assume a GUI is available.

Returns:
True if we are running in an environment where beans can assume that an interactive GUI is available, so they can pop up dialog boxes, etc. This will normally return true in a windowing environment, and will normally return false in a server environment or if an application is running as part of a batch job.
See Also:
Visibility sample code for java.beans.Visibility definition code for java.beans.Visibility

setDesignTime sample code for java.beans.Beans.setDesignTime(boolean) definition code for java.beans.Beans.setDesignTime(boolean)

public static void setDesignTime(boolean isDesignTime)
                          throws SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException 
Used to indicate whether of not we are running in an application builder environment.

Note that this method is security checked and is not available to (for example) untrusted applets. More specifically, if there is a security manager, its checkPropertiesAccess method is called. This could result in a SecurityException.

Parameters:
isDesignTime - True if we're in an application builder tool.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager exists and its checkPropertiesAccess method doesn't allow setting of system properties.
See Also:
SecurityManager.checkPropertiesAccess() sample code for java.lang.SecurityManager.checkPropertiesAccess() definition code for java.lang.SecurityManager.checkPropertiesAccess()

setGuiAvailable sample code for java.beans.Beans.setGuiAvailable(boolean) definition code for java.beans.Beans.setGuiAvailable(boolean)

public static void setGuiAvailable(boolean isGuiAvailable)
                            throws SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException 
Used to indicate whether of not we are running in an environment where GUI interaction is available.

Note that this method is security checked and is not available to (for example) untrusted applets. More specifically, if there is a security manager, its checkPropertiesAccess method is called. This could result in a SecurityException.

Parameters:
isGuiAvailable - True if GUI interaction is available.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager exists and its checkPropertiesAccess method doesn't allow setting of system properties.
See Also:
SecurityManager.checkPropertiesAccess() sample code for java.lang.SecurityManager.checkPropertiesAccess() definition code for java.lang.SecurityManager.checkPropertiesAccess()