You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/06/13 07:14:23 UTC

svn commit: r413811 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans: make/common/ src/main/java/java/beans/ src/test/java/org/apache/harmony/beans/tests/java/beans/

Author: ndbeyer
Date: Mon Jun 12 22:14:22 2006
New Revision: 413811

URL: http://svn.apache.org/viewvc?rev=413811&view=rev
Log:
Rework to match specification and enable more tests.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanDescriptor.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/MethodDescriptor.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/make/common/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/make/common/build.xml?rev=413811&r1=413810&r2=413811&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/make/common/build.xml Mon Jun 12 22:14:22 2006
@@ -158,7 +158,6 @@
                 <fileset dir="${hy.beans.src.test.java}">
                     <include name="**/*Test.java"/>
                     <exclude name="org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java" />
-                    <exclude name="org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/BeansTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/CustomizedPersistenceDelegateTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/DefaultPersistenceDelegateTest.java" />
@@ -166,10 +165,10 @@
                     <exclude name="org/apache/harmony/beans/tests/java/beans/EventHandlerTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/ExpressionTest.java" />
-                    <exclude name="org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java" />
+
                     <exclude name="org/apache/harmony/beans/tests/java/beans/IndexedPropertyDescriptorTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java" />
-                    <exclude name="org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java" />
+
                     <exclude name="org/apache/harmony/beans/tests/java/beans/PersistenceDelegateTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/PropertyChangeSupportTest.java" />
                     <exclude name="org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java" />

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanDescriptor.java?rev=413811&r1=413810&r2=413811&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanDescriptor.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/BeanDescriptor.java Mon Jun 12 22:14:22 2006
@@ -1,41 +1,44 @@
 /*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Copyright 2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
  */
 
-/**
- * @author Maxim V. Berkultsev
- * @version $Revision: 1.4.6.3 $
- */
 package java.beans;
 
 /**
+ * Describes a bean's global information.
+ * 
  * @author Maxim V. Berkultsev
- * @version $Revision: 1.4.6.3 $
  */
-
 public class BeanDescriptor extends FeatureDescriptor {
-	
-    private Class beanClass;
-    private Class customizerClass;
+    private Class<?> beanClass;
+
+    private Class<?> customizerClass;
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Constructs an instance with the bean's {@link Class} and a customizer
+     * {@link Class}. The descriptor's {@link #getName()} is set as the
+     * unqualified name of the <code>beanClass</code>.
+     * </p>
+     * 
+     * @param beanClass The bean's Class.
+     * @param customizerClass The bean's customizer Class.
      */
     public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) {
         super();
-
         if (beanClass == null) {
             throw new NullPointerException();
         }
@@ -45,7 +48,13 @@
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Constructs an instance with the bean's {@link Class}. The descriptor's
+     * {@link #getName()} is set as the unqualified name of the
+     * <code>beanClass</code>.
+     * </p>
+     * 
+     * @param beanClass The bean's Class.
      */
     public BeanDescriptor(Class<?> beanClass) {
         super();
@@ -58,29 +67,45 @@
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the bean's customizer {@link Class}/
+     * </p>
+     * 
+     * @return A {@link Class} instance or <code>null</code>.
      */
     public Class<?> getCustomizerClass() {
         return customizerClass;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the bean's {@link Class}.
+     * </p>
+     * 
+     * @return A {@link Class} instance.
      */
     public Class<?> getBeanClass() {
         return beanClass;
     }
-    
-    private String getShortClassName(Class beanClass) {
+
+    /**
+     * <p>
+     * Utility method for getting the unqualified name of a {@link Class}.
+     * </p>
+     * 
+     * @param beanClass The Class to get the name from.
+     * @return A String instance or <code>null</code>.
+     */
+    private String getShortClassName(Class<?> beanClass) {
         String result = null;
-        
-        if(beanClass != null) {
+
+        if (beanClass != null) {
             String beanClassName = beanClass.getName();
             int idx = beanClassName.lastIndexOf(".");
-            result = (idx == -1) ? beanClassName : beanClassName.substring(idx
-                    + 1);
+            result = (idx == -1) ? beanClassName : beanClassName
+                    .substring(idx + 1);
         }
-        
+
         return result;
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/FeatureDescriptor.java?rev=413811&r1=413810&r2=413811&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/FeatureDescriptor.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/FeatureDescriptor.java Mon Jun 12 22:14:22 2006
@@ -1,62 +1,73 @@
 /*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
- * @author Maxim V. Berkultsev
- * @version $Revision: 1.4.6.3 $
+ * Copyright 2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
  */
 package java.beans;
 
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Vector;
+import java.util.Map;
 
 /**
+ * Common base class for Descriptors.
+ * 
  * @author Maxim V. Berkultsev
- * @version $Revision: 1.4.6.3 $
  */
-
 public class FeatureDescriptor {
-    
-    private HashMap<String, Object> values = new HashMap<String, Object>();
+
+    private Map<String, Object> values;
+
     boolean preferred, hidden, expert;
-    String shortDescription = null;
-    String name = null;
-    String displayName = null;
+
+    String shortDescription;
+
+    String name;
+
+    String displayName;
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Constructs an instance.
+     * </p>
      */
     public FeatureDescriptor() {
-        this.preferred = false;
-        this.hidden = false;
-        this.expert = false;
+        this.values = new HashMap<String, Object>();
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the value for the named attribute.
+     * </p>
+     * 
+     * @param attributeName The name of the attribute to set a value with.
+     * @param value The value to set.
      */
     public void setValue(String attributeName, Object value) {
-        if ((attributeName != null) && (value != null)) {
-            values.put(attributeName, value);
-        }
+        if (attributeName == null || value == null)
+            throw new NullPointerException();
+        values.put(attributeName, value);
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the value associated with the named attribute.
+     * </p>
+     * 
+     * @param attributeName The name of the attribute to get a value for.
+     * @return The attribute's value.
      */
     public Object getValue(String attributeName) {
         Object result = null;
@@ -67,93 +78,146 @@
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Enumerates the attribute names.
+     * </p>
+     * 
+     * @return An instance of {@link Enumeration}.
      */
     public Enumeration<String> attributeNames() {
-        Vector<String> attribNames = new Vector<String>(values.size());
-        attribNames.addAll(values.keySet());
-        return attribNames.elements();
+        return Collections.enumeration(values.keySet());
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the short description.
+     * </p>
+     * 
+     * @param text The description to set.
      */
     public void setShortDescription(String text) {
         this.shortDescription = text;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the name.
+     * </p>
+     * 
+     * @param name The name to set.
      */
     public void setName(String name) {
         this.name = name;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the display name.
+     * </p>
+     * 
+     * @param displayName The display name to set.
      */
     public void setDisplayName(String displayName) {
         this.displayName = displayName;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the short description or {@link #getDisplayName()} if not set.
+     * </p>
+     * 
+     * @return The description.
      */
     public String getShortDescription() {
-        return shortDescription;
+        return shortDescription == null ? getDisplayName() : shortDescription;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the name.
+     * </p>
+     * 
+     * @return The name.
      */
     public String getName() {
         return name;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the display name or {@link #getName()} if not set.
+     * </p>
+     * 
+     * @return The display name.
      */
     public String getDisplayName() {
-        return displayName;
+        return displayName == null ? getName() : displayName;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the preferred indicator.
+     * </p>
+     * 
+     * @param preferred <code>true</code> if preferred, <code>false</code>
+     *        otherwise.
      */
     public void setPreferred(boolean preferred) {
         this.preferred = preferred;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the hidden indicator.
+     * </p>
+     * 
+     * @param hidden <code>true</code> if hidden, <code>false</code>
+     *        otherwise.
      */
     public void setHidden(boolean hidden) {
         this.hidden = hidden;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Sets the expert indicator.
+     * </p>
+     * 
+     * @param expert <code>true</code> if expert, <code>false</code>
+     *        otherwise.
      */
     public void setExpert(boolean expert) {
         this.expert = expert;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Indicates if this feature is preferred.
+     * </p>
+     * 
+     * @return <code>true</code> if preferred, <code>false</code> otherwise.
      */
     public boolean isPreferred() {
         return preferred;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Indicates if this feature is hidden.
+     * </p>
+     * 
+     * @return <code>true</code> if hidden, <code>false</code> otherwise.
      */
     public boolean isHidden() {
         return hidden;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Indicates if this feature is an expert feature.
+     * </p>
+     * 
+     * @return <code>true</code> if hidden, <code>false</code> otherwise.
      */
     public boolean isExpert() {
         return expert;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/MethodDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/MethodDescriptor.java?rev=413811&r1=413810&r2=413811&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/MethodDescriptor.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/MethodDescriptor.java Mon Jun 12 22:14:22 2006
@@ -1,44 +1,49 @@
 /*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Copyright 2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
  */
 
-/**
- * @author Maxim V. Berkultsev
- * @version $Revision: 1.5.4.3 $
- */
 package java.beans;
 
 import java.lang.reflect.Method;
 
 /**
+ * Describes a bean's method.
+ * 
  * @author Maxim V. Berkultsev
- * @version $Revision: 1.5.4.3 $
  */
-
 public class MethodDescriptor extends FeatureDescriptor {
-    
+
     private Method method;
+
     private ParameterDescriptor[] parameterDescriptors;
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Constructs an instance with the given {@link Method} and
+     * {@link ParameterDescriptor}s. The {@link #getName()} is set as the name
+     * of the <code>method</code> passed.
+     * </p>
+     * 
+     * @param method The Method to set.
+     * @param parameterDescriptors An array of parameter descriptors.
      */
     public MethodDescriptor(Method method,
             ParameterDescriptor[] parameterDescriptors) {
         super();
-        
+
         if (method == null) {
             throw new NullPointerException();
         }
@@ -46,34 +51,46 @@
         this.parameterDescriptors = parameterDescriptors;
 
         setName(method.getName());
-        setDisplayName(method.getName());
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Constructs an instance with the given {@link Method}. The
+     * {@link #getName()} is set as the name of the <code>method</code>
+     * passed.
+     * </p>
+     * 
+     * @param method The Method to set.
      */
     public MethodDescriptor(Method method) {
         super();
-        
+
         if (method == null) {
             throw new NullPointerException();
         }
         this.method = method;
-        this.parameterDescriptors = new ParameterDescriptor[0];
 
         setName(method.getName());
-        setDisplayName(method.getName());
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the method.
+     * </p>
+     * 
+     * @return A {@link Method} instance.
      */
     public Method getMethod() {
         return method;
     }
 
     /**
-     * @com.intel.drl.spec_ref
+     * <p>
+     * Gets the parameter descriptors.
+     * </p>
+     * 
+     * @return An array of {@link ParameterDescriptor} instance or
+     *         <code>null</code>.
      */
     public ParameterDescriptor[] getParameterDescriptors() {
         return parameterDescriptors;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java?rev=413811&r1=413810&r2=413811&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/FeatureDescriptorTest.java Mon Jun 12 22:14:22 2006
@@ -264,8 +264,8 @@
 		for (int i = 0; i < attributeNames.length; i++) {
 			fd.setValue(attributeNames[i], values[i]);
 		}
-		Enumeration names = fd.attributeNames();
-		Hashtable table = new Hashtable();
+		Enumeration<String> names = fd.attributeNames();
+		Hashtable<String, Object> table = new Hashtable<String, Object>();
 		while (names.hasMoreElements()) {
 			String name = (String) names.nextElement();
 			table.put(name, fd.getValue(name));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java?rev=413811&r1=413810&r2=413811&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java Mon Jun 12 22:14:22 2006
@@ -67,7 +67,7 @@
     public void testMethodDescriptorMethod_Null() {
         Method method = null;
         try {
-            MethodDescriptor md = new MethodDescriptor(method);
+            new MethodDescriptor(method);
             fail("Should throw NullPointerException.");
         } catch (NullPointerException e) {
         }
@@ -109,7 +109,7 @@
         ParameterDescriptor[] pds = new ParameterDescriptor[1];
         pds[0] = new ParameterDescriptor();
         try {
-            MethodDescriptor md = new MethodDescriptor(method, pds);
+            new MethodDescriptor(method, pds);
             fail("Should throw NullPointerException.");
         } catch (NullPointerException e) {
         }