You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2007/07/18 04:29:51 UTC
svn commit: r557119 -
/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
Author: tonywu
Date: Tue Jul 17 19:29:50 2007
New Revision: 557119
URL: http://svn.apache.org/viewvc?view=rev&rev=557119
Log:
Write javadoc for java.beans.Beans, no functional change
Modified:
harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java?view=diff&rev=557119&r1=557118&r2=557119
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java Tue Jul 17 19:29:50 2007
@@ -36,26 +36,120 @@
import org.apache.harmony.beans.internal.nls.Messages;
+/**
+ * This class <code>Beans</code> provides some methods for manipulting bean
+ * controls.
+ *
+ */
+
public class Beans {
private static boolean designTime = false;
private static boolean guiAvailable = true;
+ /**
+ * Constructs a Beans instance.
+ */
public Beans() {
}
+ /**
+ * Obtains an instance of a JavaBean specified the bean name using the
+ * specified class loader.
+ * <p>
+ * If the specified class loader is null, the system class loader is used.
+ * </p>
+ *
+ * @param loader
+ * the specified class loader. It can be null.
+ * @param name
+ * the name of the JavaBean
+ * @return an isntance of the bean.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
public static Object instantiate(ClassLoader loader, String name)
throws IOException, ClassNotFoundException {
return instantiate(loader, name, null, null);
}
+ /**
+ * Obtains an instance of a JavaBean specified the bean name using the
+ * specified class loader, and adds the instance into the specified bean
+ * context.
+ *
+ * <p>
+ * If the specified class loader is null, the system class loader is used.
+ * </p>
+ *
+ * @param loader
+ * the specified class loader. It can be null.
+ * @param name
+ * the name of the JavaBean
+ * @param context
+ * the beancontext in which the bean instance will be added.
+ * @return an instance of the specified JavaBean.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
public static Object instantiate(ClassLoader cls, String beanName,
BeanContext beanContext) throws IOException, ClassNotFoundException {
return instantiate(cls, beanName, beanContext, null);
}
+ /**
+ * Obtains an instance of a JavaBean specified by the bean name using the
+ * specified class loader, and adds the instance into the specified bean
+ * context.
+ * <p>
+ * The parameter name must be a qualified name relative to the specified
+ * class loader. For example, "java.awt.Button" and "x.y.z".
+ * </p>
+ * <p>
+ * If the specified class loader is null, the system class loader is used.
+ * </p>
+ * <p>
+ * Firstly, The class <code>Beans</code> regards the bean name as a
+ * serialized object name. The class <code>Beans</code> convert bean name
+ * into pathname, append a suffix ".ser" to the pathname. then try to load
+ * the resource using the specified class loader. If <code>Beans</code>
+ * fails to load the resource, <code>Beans</code> will regard the
+ * <code>name</code> as a class name and construct a new instance of the
+ * bean class.
+ * </p>
+ * <p>
+ * For example, if the name is specified as "x.y.z", The class
+ * <code>Beans</code> will try to load the serialized object from the
+ * resource "x/y/z.ser"; If <code>Beans</code> fails to load the resource
+ * "x/y/z.ser", it will create a new instance of "x.y.z".
+ * </p>
+ * <p>
+ * If the bean is an instance of java.applet.Applet, <code>Beans</code>
+ * will do some special initialization for this applet bean. First,
+ * <code>Beans</code> will set the default AppletStub and AppletContext
+ * for the applet bean (If the specified <code>AppletInitializer</code> is
+ * not null, <code>Beans</code> will call the
+ * <code>AppletInitializer.initialize</code> to set the default AppletStub
+ * and AppletContext for the applet bean). Second, <code>Beans</code> will
+ * call the <code>init</code> method of the applet. (If the applet bean is
+ * loaded as a serialized object, the <code>init</code> method will not be
+ * called.)
+ * </p>
+ *
+ * @param loader
+ * the specified class loader. It can be null.
+ * @param name
+ * the name of the JavaBean
+ * @param context
+ * the beancontext in which the bean instance will be added.
+ * @param initializer
+ * the AppletInitializer for applet bean instance.
+ * @return Obtains an instance of the JavaBean.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
@SuppressWarnings("unchecked")
public static Object instantiate(ClassLoader cls, String beanName,
BeanContext context, AppletInitializer initializer)
@@ -110,10 +204,35 @@
return result;
}
+ /**
+ * Obtain an alternative type view of the given bean. The view type is
+ * specified by the parameter <code>type</code>.
+ * <p>
+ * If the type view cannot be obtained, the original bean object is
+ * returned.
+ * </p>
+ *
+ * @param bean
+ * the original bean object.
+ * @param type
+ * the specified view type.
+ * @return a type view of the given bean.
+ */
public static Object getInstanceOf(Object bean, Class<?> targetType) {
return bean;
}
+ /**
+ * Determine if the the specified bean object can be viewed as the specified
+ * type.
+ *
+ * @param bean
+ * the specified bean object.
+ * @param type
+ * the specifed view type.
+ * @return true if the specified bean object can be viewed as the specified
+ * type; otherwise, return false;
+ */
public static boolean isInstanceOf(Object bean, Class<?> targetType) {
if (bean == null) {
throw new NullPointerException(Messages.getString("beans.1D")); //$NON-NLS-1$
@@ -122,12 +241,31 @@
return targetType == null ? false : targetType.isInstance(bean);
}
+ /**
+ * Set whether or not a GUI is available in the bean's current environment.
+ *
+ * @param value
+ * should be <code>true</code> to signify that a GUI is
+ * available, <code>false</code> otherwise.
+ * @throws SecurityException
+ * if the caller does not have the required permission to access
+ * or modify system properties.
+ */
public static synchronized void setGuiAvailable(boolean isGuiAvailable)
throws SecurityException {
checkPropertiesAccess();
guiAvailable = isGuiAvailable;
}
-
+
+ /**
+ * Used to indicate whether of not it's in an application construction
+ * environment.
+ *
+ * @param value
+ * true to indicate that it's in application construction
+ * environment.
+ * @throws SecurityException
+ */
public static void setDesignTime(boolean isDesignTime)
throws SecurityException {
checkPropertiesAccess();
@@ -136,10 +274,22 @@
}
}
+ /**
+ * Returns a boolean indication of whether or not a GUI is available for
+ * beans.
+ *
+ * @return <code>true</code> if a GUI is available, otherwise
+ * <code>false</code>.
+ */
public static synchronized boolean isGuiAvailable() {
return guiAvailable;
}
+ /**
+ * Determine if it's in design-mode.
+ *
+ * @return true if it's in an application construction environment.
+ */
public static synchronized boolean isDesignTime() {
return designTime;
}