harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r449489 [1/3] - in /incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java: javax/naming/directory/ javax/naming/ldap/ javax/naming/spi/ org/apache/harmony/jndi/internal/ org/apache/harmony/jndi/provider/ org/apache/harmony/jn...
Date Sun, 24 Sep 2006 21:19:40 GMT
Author: ndbeyer
Date: Sun Sep 24 14:19:38 2006
New Revision: 449489

URL: http://svn.apache.org/viewvc?view=rev&rev=449489
Log:
Code cleanup for jndi module:
* General generification
* Add braces around if/else statements
* Remove unused code
* Fix spelling errors
* Remove unnecessary javadoc
* Add annotations for Override
* Eliminate compiler warnings

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/AttributeModificationException.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/ModificationItem.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/ControlFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/NamingManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContextFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSNameParser.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Message.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ProviderMgr.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/QuestionRecord.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Resolver.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/BindingEnumeration.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/NameClassPairEnumeration.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/AttributeModificationException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/AttributeModificationException.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/AttributeModificationException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/AttributeModificationException.java Sun Sep 24 14:19:38 2006
@@ -123,6 +123,7 @@
      * 
      * @return text detailing the exception location and the failing modification.
      */
+    @Override
     public String toString() {
         return toStringImpl(false);
     }
@@ -133,6 +134,7 @@
      * @param flag Indicates if the resolved object need to be returned. 
      * @return text detailing the exception location and the failing modification.
      */
+    @Override
     public String toString(boolean flag) {
         return toStringImpl(flag);
     }
@@ -141,8 +143,8 @@
         StringBuffer sb = new StringBuffer(super.toString(flag));
         if (null != unexecs && unexecs.length > 0) {
             sb.append(". The unexecuted modification items are: \""); //$NON-NLS-1$
-            for (int i = 0; i < unexecs.length; i++) {
-                sb.append(unexecs[i].toString()).append(";"); //$NON-NLS-1$
+            for (ModificationItem element : unexecs) {
+                sb.append(element.toString()).append(";"); //$NON-NLS-1$
             }
             sb.append("\""); //$NON-NLS-1$
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttribute.java Sun Sep 24 14:19:38 2006
@@ -158,7 +158,7 @@
      * Determine whether two values belonging to the two array classes
      * respectively are possible to be equal.
      */
-    private boolean compareValueClasses(Class c1, Class c2) {
+    private boolean compareValueClasses(Class<? extends Object> c1, Class<? extends Object> c2) {
         if ((c1.getName().startsWith("[L") || c1.getName().startsWith("[[")) && //$NON-NLS-1$ //$NON-NLS-2$
             (c2.getName().startsWith("[L") || c2.getName().startsWith("[["))) { //$NON-NLS-1$ //$NON-NLS-2$
             /*
@@ -292,13 +292,15 @@
         values.clear();
     }
 
+    @SuppressWarnings("unchecked")
+    @Override
     public Object clone() {
         try {
             BasicAttribute attr = (BasicAttribute) super.clone();
             attr.values = (Vector<Object>) this.values.clone();
             return attr;
         } catch (CloneNotSupportedException e) {
-            throw new InternalError("Failed to clone object of BasicAttribute class."); //$NON-NLS-1$
+            throw new AssertionError("Failed to clone object of BasicAttribute class."); //$NON-NLS-1$
         }
     }
 
@@ -325,7 +327,7 @@
     }
 
     public NamingEnumeration<?> getAll() throws NamingException {
-        return new BasicNamingEnumeration(values.elements());
+        return new BasicNamingEnumeration<Object>(values.elements());
     }
 
     public DirContext getAttributeDefinition() throws NamingException {
@@ -406,8 +408,8 @@
     private void writeObject(ObjectOutputStream oos) throws IOException {
         oos.defaultWriteObject();
         oos.writeInt(this.values.size());
-        for (Enumeration<Object> e = this.values.elements(); e.hasMoreElements();) {
-            oos.writeObject(e.nextElement());
+        for (Object object : this.values) {
+            oos.writeObject(object);
         }
     }
 
@@ -425,6 +427,7 @@
      * @return              true if this object is equal to <code>obj</code>,
      *                      otherwise false
      */
+    @Override
     public boolean equals(Object obj) {
         if (obj instanceof BasicAttribute) {
             BasicAttribute a = (BasicAttribute) obj;
@@ -440,8 +443,8 @@
                 return false;
             } else if (this.ordered) {
                 // Otherwise, if both ordered, compare each value
-                Enumeration e1 = this.values.elements();
-                Enumeration e2 = a.values.elements();
+                Enumeration<?> e1 = this.values.elements();
+                Enumeration<?> e2 = a.values.elements();
 
                 while (e1.hasMoreElements()) {
                     if (!compareValues(e1.nextElement(), e2.nextElement())) {
@@ -479,6 +482,7 @@
      * @return              the hashcode of this <code>BasicAttribute</code>
      *                      instance
      */
+    @Override
     public int hashCode() {
         Object o;
         int i = attrID.hashCode();
@@ -501,6 +505,7 @@
      * 
      * @return              the string representation of this object
      */
+    @Override
     public String toString() {
         Enumeration<Object> e = this.values.elements();
         String s = "Attribute ID: " + this.attrID; //$NON-NLS-1$

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/BasicAttributes.java Sun Sep 24 14:19:38 2006
@@ -235,13 +235,15 @@
      *
      * @return              a deep copy of this attribute collection
      */
+    @SuppressWarnings("unchecked")
+    @Override
     public Object clone() {
         try {
             BasicAttributes c = (BasicAttributes) super.clone();
             c.attrMap = (Hashtable<String,Attribute>) this.attrMap.clone();
             return c;
         } catch (CloneNotSupportedException e) {
-            throw new InternalError("Failed to clone object of BasicAttributes class."); //$NON-NLS-1$
+            throw new AssertionError("Failed to clone object of BasicAttributes class."); //$NON-NLS-1$
         }
     }
 
@@ -256,6 +258,7 @@
      * @return              true if this object is equal to <code>obj</code>,
      *                      otherwise false
      */
+    @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof Attributes)) {
             return false;
@@ -287,6 +290,7 @@
      * @return              the hashcode of this <code>BasicAttributes</code>
      *                      instance
      */
+    @Override
     public int hashCode() {
         Enumeration<Attribute> e = attrMap.elements();
         int i = (ignoreCase ? 1 : 0);
@@ -306,6 +310,7 @@
      * 
      * @return              the string representation of this object
      */
+    @Override
     public String toString() {
         String s = null;
         Iterator<Map.Entry<String,Attribute>> it = attrMap.entrySet().iterator();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/ModificationItem.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/ModificationItem.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/ModificationItem.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/ModificationItem.java Sun Sep 24 14:19:38 2006
@@ -135,6 +135,7 @@
      * @return 				a concatenation of string values for the operation 
      * 						and the attribute
      */
+    @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
         switch (mod_op) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/directory/SearchResult.java Sun Sep 24 14:19:38 2006
@@ -214,6 +214,7 @@
      * 
      * @return 				string representation of this search result
      */
+    @Override
     public String toString() {
         return new StringBuffer(super.toString())
             .append(":") //$NON-NLS-1$

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/ControlFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/ControlFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/ControlFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/ControlFactory.java Sun Sep 24 14:19:38 2006
@@ -34,13 +34,6 @@
  * 
  */
 public abstract class ControlFactory {
-
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Constructs a <code>ControlFactory</code> instance with no parameters.
      */
@@ -48,12 +41,6 @@
     	super();
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Uses this control factory to create a particular type of <code>Control
      * </code> based on the supplied control.
@@ -98,20 +85,15 @@
         throws NamingException {
 
         // obtain control factories from hashtable and provider resource file
-        String fnames[] =
-            EnvironmentReader
-                .getFactoryNamesFromEnvironmentAndProviderResource(
-                h,
-                ctx,
-                LdapContext.CONTROL_FACTORIES);
+        String fnames[] = EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
+                h, ctx, LdapContext.CONTROL_FACTORIES);
 
-        // for each control factory
-        for (int i = 0; i < fnames.length; i++) {
+        for (String element : fnames) {
             // new factory instance by its class name
             ControlFactory factory = null;
             try {
                 factory =
-                    (ControlFactory) classForName(fnames[i]).newInstance();
+                    (ControlFactory) classForName(element).newInstance();
             } catch (Exception e) {
                 continue;
             }
@@ -131,29 +113,23 @@
      * Use the context class loader or the system class loader to load the
      * specified class, in a privileged manner.
      */
-    private static Class classForName(final String className)
+    private static Class<?> classForName(final String className)
         throws ClassNotFoundException {
 
-        Class cls =
-            (Class) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        Class<?> cls = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
+            public Class<?> run() {
                 // try thread context class loader first
                 try {
-                    return Class.forName(
-                        className,
-                        true,
-                        Thread.currentThread().getContextClassLoader());
+                    return Class.forName(className, true, Thread.currentThread()
+                            .getContextClassLoader());
                 } catch (ClassNotFoundException e) {
-                	// Ignored
+                    // Ignored
                 }
                 // try system class loader second
                 try {
-                    return Class.forName(
-                        className,
-                        true,
-                        ClassLoader.getSystemClassLoader());
-                } catch (ClassNotFoundException e1) {
-                	// Ignored
+                    return Class.forName(className, true, ClassLoader.getSystemClassLoader());
+                } catch (ClassNotFoundException e) {
+                    // Ignored
                 }
                 // return null, if fail to load class
                 return null;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/InitialLdapContext.java Sun Sep 24 14:19:38 2006
@@ -81,6 +81,7 @@
      * @param cs                the connection controls which may be null
      * @throws NamingException  If an error is encountered.
      */
+    @SuppressWarnings("unchecked")
     public InitialLdapContext(Hashtable<?, ?> h, Control[] cs)
         throws NamingException {
         super(true);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/ldap/LdapReferralException.java Sun Sep 24 14:19:38 2006
@@ -76,6 +76,7 @@
      * @throws NamingException
      * 						If cannot get referral context correctly.
      */
+    @Override
     public abstract Context getReferralContext() throws NamingException;
 
     /**
@@ -86,6 +87,7 @@
      * @throws NamingException
      * 						If cannot get referral context correctly.
      */
+    @Override
     public abstract Context getReferralContext(Hashtable<?, ?> h)
         throws NamingException;
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/DirectoryManager.java Sun Sep 24 14:19:38 2006
@@ -24,9 +24,11 @@
 import java.util.Hashtable;
 import java.util.StringTokenizer;
 
+import javax.naming.Binding;
 import javax.naming.CannotProceedException;
 import javax.naming.Context;
 import javax.naming.Name;
+import javax.naming.NameClassPair;
 import javax.naming.NameParser;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -38,6 +40,7 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
 import javax.naming.spi.DirStateFactory.Result;
 
 import org.apache.harmony.jndi.internal.EnvironmentReader;
@@ -57,25 +60,9 @@
  */
 public class DirectoryManager extends NamingManager {
 
-    /*
-     * -------------------------------------------------------------------
-     * Class variables
-     * -------------------------------------------------------------------
-     */
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
     private DirectoryManager(){//private to prevent it being instanced        
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Create an object using an object factory.
      * Returns a new <code>Object</code> or the supplied <code>Object o</code>
@@ -103,13 +90,8 @@
      * @throws NamingException if one is encountered
      * @throws Exception if any other exception is encountered
      */
-    public static Object getObjectInstance(
-        Object o,
-        Name n,
-        Context c,
-        Hashtable<?, ?> h,
-        Attributes a)
-        throws NamingException, Exception {
+    public static Object getObjectInstance(Object o, Name n, Context c, Hashtable<?, ?> h,
+            Attributes a) throws NamingException, Exception {
 
         // 1. try ObjectFactoryBuilder, if it is set
         if (null != ofb) {
@@ -151,7 +133,7 @@
         return o;
     }
 
-    /*
+    /**
      * Check the type of factory, DirObjectFactory or ObjectFactory, and
      * call getObjectInstance() on the property type.
      */
@@ -160,7 +142,7 @@
         Object o,
         Name n,
         Context c,
-        Hashtable h,
+        Hashtable<?, ?> h,
         Attributes a) throws Exception {
         if (factory instanceof DirObjectFactory) {
             return ((DirObjectFactory) factory).getObjectInstance(o, n, c, h, a);
@@ -168,25 +150,20 @@
 		return factory.getObjectInstance(o, n, c, h);
     }
 
-    private static Object getObjectInstanceByObjectFactory(
-        Object o,
-        Name n,
-        Context c,
-        Hashtable h,
-        Attributes a)
-        throws NamingException, Exception {
-        // obtain object factories from hashtable and service provider resource file
+    private static Object getObjectInstanceByObjectFactory(Object o, Name n, Context c,
+            Hashtable<?, ?> h, Attributes a) throws NamingException, Exception {
+        // obtain object factories from hashtable and service provider resource
+        // file
         String fnames[] =
             EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
                 h,
                 c,
                 Context.OBJECT_FACTORIES);
-        // for each object factory
-        for (int i = 0; i < fnames.length; i++) {
+        for (String element : fnames) {
             // new factory instance by its class name
             ObjectFactory factory = null;
             try {
-                factory = (ObjectFactory) classForName(fnames[i]).newInstance();
+                factory = (ObjectFactory) classForName(element).newInstance();
             } catch (Exception e) {
                 continue;
             }
@@ -200,12 +177,8 @@
         return null;
     }
 
-    private static Object getObjectInstanceByUrlRefAddr(
-        Name n,
-        Context c,
-        Hashtable h,
-        Reference ref)
-        throws NamingException {
+    private static Object getObjectInstanceByUrlRefAddr(Name n, Context c, Hashtable<?, ?> h,
+            Reference ref) throws NamingException {
         // obtain pkg prefixes from hashtable and service provider resource file
         String pkgPrefixes[] =
             EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
@@ -240,26 +213,19 @@
         return null;
     }
 
-    private static Object getObjectInstanceByUrlContextFactory(
-        String url,
-        Name n,
-        Context c,
-        Hashtable h,
-        String pkgPrefixes[],
-        String schema)
-        throws NamingException {
+    private static Object getObjectInstanceByUrlContextFactory(String url, Name n, Context c,
+            Hashtable<?, ?> h, String pkgPrefixes[], String schema) throws NamingException {
         // if schema is empty or null, fail, return null
         if (null == schema || 0 == schema.length()) {
             return null;
         }
 
-        // for each pkg prefix
-        for (int i = 0; i < pkgPrefixes.length; i++) {
+        for (String element : pkgPrefixes) {
             ObjectFactory factory = null;
             try {
                 // create url context factory instance
                 String clsName =
-                    pkgPrefixes[i] + "." + schema + "." + schema + "URLContextFactory"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    element + "." + schema + "." + schema + "URLContextFactory"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                 factory = (ObjectFactory) classForName(clsName).newInstance();
             } catch (Exception e) {
                 // failed to create factory, continue trying
@@ -291,14 +257,8 @@
         return null;
     }
 
-    private static Object getObjectInstanceByFactoryInReference(
-        Reference ref,
-        Object o,
-        Name n,
-        Context c,
-        Hashtable h,
-        Attributes a)
-        throws Exception {
+    private static Object getObjectInstanceByFactoryInReference(Reference ref, Object o,
+            Name n, Context c, Hashtable<?, ?> h, Attributes a) throws Exception {
         ObjectFactory factory = null;
 
         // try load the factory by its class name
@@ -392,12 +352,11 @@
                 c,
                 Context.STATE_FACTORIES);
 
-        // for each state factory
-        for (int i = 0; i < fnames.length; i++) {
+        for (String element : fnames) {
             // new factory instance by its class name
             StateFactory factory = null;
             try {
-                factory = (StateFactory) classForName(fnames[i]).newInstance();
+                factory = (StateFactory) classForName(element).newInstance();
             } catch (Exception e) {
                 continue;
             }
@@ -455,7 +414,7 @@
         if (nextContext instanceof DirContext) {
             // return as DirContext
             return (DirContext) nextContext;
-        } else if (nextContext instanceof Context) {
+        } else if (nextContext != null) {
             // in case it's Context but not DirContext, wrap it as DirContext and return
             return new Context2DirContextWrapper(nextContext, cpe);
         } else {
@@ -464,11 +423,11 @@
         }
     }
 
-    private static Class classForName(final String className)
+    private static Class<?> classForName(final String className)
         throws ClassNotFoundException {
 
-        Class cls = (Class) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        Class<?> cls = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
+            public Class<?> run() {
                 // try thread context class loader first
                 try {
                     return Class.forName(
@@ -505,21 +464,22 @@
      */
     private static class Context2DirContextWrapper implements DirContext {
         private Context ctx;
+
         private CannotProceedException cpe;
-        
+
         public Context2DirContextWrapper(Context ctx, CannotProceedException cpe) {
             this.ctx = ctx;
             this.cpe = cpe;
         }
-        
+
         private Context getContext() throws CannotProceedException {
-            if (ctx instanceof Context) {
+            if (ctx != null) {
                 return ctx;
             }
             cpe.fillInStackTrace();
             throw cpe;
         }
-        
+
         private DirContext getDirContext() throws CannotProceedException {
             if (ctx instanceof DirContext) {
                 return (DirContext) ctx;
@@ -527,65 +487,32 @@
             cpe.fillInStackTrace();
             throw cpe;
         }
-        
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration listBindings(String s) throws NamingException {
+
+        public NamingEnumeration<Binding> listBindings(String s) throws NamingException {
             return getContext().listBindings(s);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public Object removeFromEnvironment(String s) throws NamingException {
             return getContext().removeFromEnvironment(s);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public Object lookupLink(String s) throws NamingException {
             return getContext().lookupLink(s);
         }
 
-        /**
-         * @param n
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration list(Name n) throws NamingException {
+        public NamingEnumeration<NameClassPair> list(Name n) throws NamingException {
             return getContext().list(n);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public Object lookup(String s) throws NamingException {
             return getContext().lookup(s);
         }
 
-        /**
-         * @param s
-         * @param o
-         * @return
-         * @throws NamingException
-         */
         public Object addToEnvironment(String s, Object o) throws NamingException {
             return getContext().addToEnvironment(s, o);
         }
 
-        /* (non-Javadoc)
-         * @see java.lang.Object#toString()
-         */
+        @Override
         public String toString() {
             try {
                 return getContext().toString();
@@ -594,27 +521,15 @@
             }
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public Context createSubcontext(String s) throws NamingException {
             return getContext().createSubcontext(s);
         }
 
-        /**
-         * @param nOld
-         * @param nNew
-         * @throws NamingException
-         */
         public void rename(Name nOld, Name nNew) throws NamingException {
             getContext().rename(nOld, nNew);
         }
 
-        /* (non-Javadoc)
-         * @see java.lang.Object#hashCode()
-         */
+        @Override
         public int hashCode() {
             try {
                 return getContext().hashCode();
@@ -623,176 +538,83 @@
             }
         }
 
-        /**
-         * @param n
-         * @param o
-         * @throws NamingException
-         */
         public void rebind(Name n, Object o) throws NamingException {
             getContext().rebind(n, o);
         }
 
-        /**
-         * @param sOld
-         * @param sNew
-         * @throws NamingException
-         */
         public void rename(String sOld, String sNew) throws NamingException {
             getContext().rename(sOld, sNew);
         }
 
-        /**
-         * @param n
-         * @return
-         * @throws NamingException
-         */
         public Context createSubcontext(Name n) throws NamingException {
             return getContext().createSubcontext(n);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public NameParser getNameParser(String s) throws NamingException {
             return getContext().getNameParser(s);
         }
 
-        /**
-         * @param s
-         * @param o
-         * @throws NamingException
-         */
         public void rebind(String s, Object o) throws NamingException {
             getContext().rebind(s, o);
         }
 
-        /**
-         * @param n
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration listBindings(Name n) throws NamingException {
+        public NamingEnumeration<Binding> listBindings(Name n) throws NamingException {
             return getContext().listBindings(n);
         }
 
-        /**
-         * @param n
-         * @return
-         * @throws NamingException
-         */
         public NameParser getNameParser(Name n) throws NamingException {
             return getContext().getNameParser(n);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration list(String s) throws NamingException {
+        public NamingEnumeration<NameClassPair> list(String s) throws NamingException {
             return getContext().list(s);
         }
 
-        /**
-         * @return
-         * @throws NamingException
-         */
         public String getNameInNamespace() throws NamingException {
             return getContext().getNameInNamespace();
         }
 
-        /**
-         * @param n
-         * @throws NamingException
-         */
         public void unbind(Name n) throws NamingException {
             getContext().unbind(n);
         }
 
-        /**
-         * @param n
-         * @param pfx
-         * @return
-         * @throws NamingException
-         */
         public Name composeName(Name n, Name pfx) throws NamingException {
             return getContext().composeName(n, pfx);
         }
 
-        /**
-         * @param n
-         * @param o
-         * @throws NamingException
-         */
         public void bind(Name n, Object o) throws NamingException {
             getContext().bind(n, o);
         }
 
-        /**
-         * @param s
-         * @throws NamingException
-         */
         public void unbind(String s) throws NamingException {
             getContext().unbind(s);
         }
 
-        /**
-         * @throws NamingException
-         */
         public void close() throws NamingException {
             getContext().close();
         }
 
-        /**
-         * @param n
-         * @return
-         * @throws NamingException
-         */
         public Object lookupLink(Name n) throws NamingException {
             return getContext().lookupLink(n);
         }
 
-        /**
-         * @param n
-         * @throws NamingException
-         */
         public void destroySubcontext(Name n) throws NamingException {
             getContext().destroySubcontext(n);
         }
 
-        /**
-         * @param s
-         * @param pfx
-         * @return
-         * @throws NamingException
-         */
         public String composeName(String s, String pfx) throws NamingException {
             return getContext().composeName(s, pfx);
         }
 
-        /**
-         * @param s
-         * @param o
-         * @throws NamingException
-         */
         public void bind(String s, Object o) throws NamingException {
             getContext().bind(s, o);
         }
 
-        /**
-         * @param n
-         * @return
-         * @throws NamingException
-         */
         public Object lookup(Name n) throws NamingException {
             return getContext().lookup(n);
         }
 
-        /* (non-Javadoc)
-         * @see java.lang.Object#equals(java.lang.Object)
-         */
+        @Override
         public boolean equals(Object arg0) {
             try {
                 return getContext().equals(arg0);
@@ -801,316 +623,130 @@
             }
         }
 
-        /**
-         * @param s
-         * @throws NamingException
-         */
         public void destroySubcontext(String s) throws NamingException {
             getContext().destroySubcontext(s);
         }
 
-        /**
-         * @return
-         * @throws NamingException
-         */
-        public Hashtable getEnvironment() throws NamingException {
+        public Hashtable<?, ?> getEnvironment() throws NamingException {
             return getContext().getEnvironment();
         }
 
-        /**
-         * @param name
-         * @param obj
-         * @param attributes
-         * @throws NamingException
-         */
-        public void bind(Name name, Object obj, Attributes attributes)
-            throws NamingException {
+        public void bind(Name name, Object obj, Attributes attributes) throws NamingException {
             getDirContext().bind(name, obj, attributes);
         }
 
-        /**
-         * @param s
-         * @param obj
-         * @param attributes
-         * @throws NamingException
-         */
-        public void bind(String s, Object obj, Attributes attributes)
-            throws NamingException {
+        public void bind(String s, Object obj, Attributes attributes) throws NamingException {
             getDirContext().bind(s, obj, attributes);
         }
 
-        /**
-         * @param name
-         * @param attributes
-         * @return
-         * @throws NamingException
-         */
         public DirContext createSubcontext(Name name, Attributes attributes)
-            throws NamingException {
+                throws NamingException {
             return getDirContext().createSubcontext(name, attributes);
         }
 
-        /**
-         * @param s
-         * @param attributes
-         * @return
-         * @throws NamingException
-         */
         public DirContext createSubcontext(String s, Attributes attributes)
-            throws NamingException {
+                throws NamingException {
             return getDirContext().createSubcontext(s, attributes);
         }
 
-        /**
-         * @param name
-         * @return
-         * @throws NamingException
-         */
         public Attributes getAttributes(Name name) throws NamingException {
             return getDirContext().getAttributes(name);
         }
 
-        /**
-         * @param name
-         * @param as
-         * @return
-         * @throws NamingException
-         */
         public Attributes getAttributes(Name name, String[] as) throws NamingException {
             return getDirContext().getAttributes(name, as);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public Attributes getAttributes(String s) throws NamingException {
             return getDirContext().getAttributes(s);
         }
 
-        /**
-         * @param s
-         * @param as
-         * @return
-         * @throws NamingException
-         */
         public Attributes getAttributes(String s, String[] as) throws NamingException {
             return getDirContext().getAttributes(s, as);
         }
 
-        /**
-         * @param name
-         * @return
-         * @throws NamingException
-         */
         public DirContext getSchema(Name name) throws NamingException {
             return getDirContext().getSchema(name);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public DirContext getSchema(String s) throws NamingException {
             return getDirContext().getSchema(s);
         }
 
-        /**
-         * @param name
-         * @return
-         * @throws NamingException
-         */
         public DirContext getSchemaClassDefinition(Name name) throws NamingException {
             return getDirContext().getSchemaClassDefinition(name);
         }
 
-        /**
-         * @param s
-         * @return
-         * @throws NamingException
-         */
         public DirContext getSchemaClassDefinition(String s) throws NamingException {
             return getDirContext().getSchemaClassDefinition(s);
         }
 
-        /**
-         * @param name
-         * @param i
-         * @param attributes
-         * @throws NamingException
-         */
         public void modifyAttributes(Name name, int i, Attributes attributes)
-            throws NamingException {
+                throws NamingException {
             getDirContext().modifyAttributes(name, i, attributes);
         }
 
-        /**
-         * @param name
-         * @param modificationItems
-         * @throws NamingException
-         */
         public void modifyAttributes(Name name, ModificationItem[] modificationItems)
-            throws NamingException {
+                throws NamingException {
             getDirContext().modifyAttributes(name, modificationItems);
         }
 
-        /**
-         * @param s
-         * @param i
-         * @param attributes
-         * @throws NamingException
-         */
         public void modifyAttributes(String s, int i, Attributes attributes)
-            throws NamingException {
+                throws NamingException {
             getDirContext().modifyAttributes(s, i, attributes);
         }
 
-        /**
-         * @param s
-         * @param modificationItems
-         * @throws NamingException
-         */
         public void modifyAttributes(String s, ModificationItem[] modificationItems)
-            throws NamingException {
+                throws NamingException {
             getDirContext().modifyAttributes(s, modificationItems);
         }
 
-        /**
-         * @param name
-         * @param obj
-         * @param attributes
-         * @throws NamingException
-         */
-        public void rebind(Name name, Object obj, Attributes attributes)
-            throws NamingException {
+        public void rebind(Name name, Object obj, Attributes attributes) throws NamingException {
             getDirContext().rebind(name, obj, attributes);
         }
 
-        /**
-         * @param s
-         * @param obj
-         * @param attributes
-         * @throws NamingException
-         */
-        public void rebind(String s, Object obj, Attributes attributes)
-            throws NamingException {
+        public void rebind(String s, Object obj, Attributes attributes) throws NamingException {
             getDirContext().rebind(s, obj, attributes);
         }
 
-        /**
-         * @param name
-         * @param attributes
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(Name name, Attributes attributes)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(Name name, Attributes attributes)
+                throws NamingException {
             return getDirContext().search(name, attributes);
         }
 
-        /**
-         * @param name
-         * @param attributes
-         * @param as
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(Name name, Attributes attributes, String[] as)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(Name name, Attributes attributes,
+                String[] as) throws NamingException {
             return getDirContext().search(name, attributes, as);
         }
 
-        /**
-         * @param name
-         * @param filter
-         * @param objs
-         * @param searchControls
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(
-            Name name,
-            String filter,
-            Object[] objs,
-            SearchControls searchControls)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(Name name, String filter, Object[] objs,
+                SearchControls searchControls) throws NamingException {
             return getDirContext().search(name, filter, objs, searchControls);
         }
 
-        /**
-         * @param name
-         * @param filter
-         * @param searchControls
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(
-            Name name,
-            String filter,
-            SearchControls searchControls)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(Name name, String filter,
+                SearchControls searchControls) throws NamingException {
             return getDirContext().search(name, filter, searchControls);
         }
 
-        /**
-         * @param name
-         * @param attributes
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(String name, Attributes attributes)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(String name, Attributes attributes)
+                throws NamingException {
             return getDirContext().search(name, attributes);
         }
 
-        /**
-         * @param name
-         * @param attributes
-         * @param as
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(String name, Attributes attributes, String[] as)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(String name, Attributes attributes,
+                String[] as) throws NamingException {
             return getDirContext().search(name, attributes, as);
         }
 
-        /**
-         * @param name
-         * @param filter
-         * @param objs
-         * @param searchControls
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(
-            String name,
-            String filter,
-            Object[] objs,
-            SearchControls searchControls)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(String name, String filter,
+                Object[] objs, SearchControls searchControls) throws NamingException {
             return getDirContext().search(name, filter, objs, searchControls);
         }
 
-        /**
-         * @param name
-         * @param filter
-         * @param searchControls
-         * @return
-         * @throws NamingException
-         */
-        public NamingEnumeration search(
-            String name,
-            String filter,
-            SearchControls searchControls)
-            throws NamingException {
+        public NamingEnumeration<SearchResult> search(String name, String filter,
+                SearchControls searchControls) throws NamingException {
             return getDirContext().search(name, filter, searchControls);
         }
-
     }
-
 }
-
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/NamingManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/NamingManager.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/NamingManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/spi/NamingManager.java Sun Sep 24 14:19:38 2006
@@ -94,44 +94,22 @@
 
 public class NamingManager {
 
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
     /**
      * The property name of <code>CannotProceedException</code> in a context's
      * environment.
      */
     public static final String CPE = "java.naming.spi.CannotProceedException"; //$NON-NLS-1$
 
-    /*
-     * ------------------------------------------------------------------- 
-     * Class variables
-     * -------------------------------------------------------------------
-     */
-
-    static InitialContextFactoryBuilder icfb = null;
+    static InitialContextFactoryBuilder icfb;
 
-    static ObjectFactoryBuilder ofb = null;
+    static ObjectFactoryBuilder ofb;
 
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
     NamingManager() {
+        super();
         // package private to prevent it being instanced but make it can be
         // subclassed by DirectoryManager
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Install an <code>InitialContextFactoryBuilder</code>. Once this has
      * been set it cannot be reset. Attempts to do so cause an
@@ -245,7 +223,7 @@
             String factoryClassName =
                 (String) h.get(Context.INITIAL_CONTEXT_FACTORY);
             // new factory instance
-            Class factoryClass = classForName(factoryClassName);
+            Class<?> factoryClass = classForName(factoryClassName);
             InitialContextFactory factory = (InitialContextFactory) factoryClass
                     .newInstance();
             // create initial context instance using the factory
@@ -384,7 +362,7 @@
     }
 
     private static Object getObjectInstanceByObjectFactory(Object o, Name n,
-            Context c, Hashtable h) throws NamingException, Exception {
+            Context c, Hashtable<?, ?> h) throws NamingException, Exception {
         // obtain object factories from hashtable and service provider resource
         // file
         String fnames[] = EnvironmentReader
@@ -409,7 +387,7 @@
     }
 
     private static Object getObjectInstanceByUrlRefAddr(Name n, Context c,
-            Hashtable h, Reference ref) throws NamingException {
+            Hashtable<?, ?> h, Reference ref) throws NamingException {
         // obtain pkg prefixes from hashtable and service provider resource file
         String pkgPrefixes[] = EnvironmentReader
                 .getFactoryNamesFromEnvironmentAndProviderResource(h, c,
@@ -438,7 +416,7 @@
     }
 
     private static Object getObjectInstanceByUrlContextFactory(String url,
-            Name n, Context c, Hashtable h, String pkgPrefixes[], String schema)
+            Name n, Context c, Hashtable<?, ?> h, String pkgPrefixes[], String schema)
             throws NamingException {
         // if schema is empty or null, fail, return null
         if (null == schema || 0 == schema.length()) {
@@ -480,7 +458,7 @@
     }
 
     private static Object getObjectInstanceByFactoryInReference(Reference ref,
-            Object o, Name n, Context c, Hashtable h) throws Exception {
+            Object o, Name n, Context c, Hashtable<?, ?> h) throws Exception {
         ObjectFactory factory = null;
 
         // try load the factory by its class name
@@ -734,6 +712,7 @@
      *             if the resolved object is null or if a context cannot be
      *             obtained from it either directly or indirectly.
      */
+    @SuppressWarnings("unchecked")
     public static Context getContinuationContext(CannotProceedException cpe)
             throws NamingException {
 
@@ -743,8 +722,7 @@
         if (cpe.getEnvironment() == null) {
             cpe.setEnvironment(new Hashtable<String, CannotProceedException>());
         }
-        ((Hashtable<String, CannotProceedException>) cpe.getEnvironment()).put(
-                CPE, cpe);
+        ((Hashtable<String, CannotProceedException>) cpe.getEnvironment()).put(CPE, cpe);
 
         // if resolved object is null
         if (null == cpe.getResolvedObj()) {
@@ -779,12 +757,12 @@
         return ctx;
     }
 
-    private static Class classForName(final String className)
+    private static Class<?> classForName(final String className)
             throws ClassNotFoundException {
 
-        Class cls = AccessController
-                .doPrivileged(new PrivilegedAction<Class>() {
-                    public Class run() {
+        Class<?> cls = AccessController
+                .doPrivileged(new PrivilegedAction<Class<?>>() {
+                    public Class<?> run() {
                         // try thread context class loader first
                         try {
                             return Class.forName(className, true, Thread

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/internal/EnvironmentReader.java Sun Sep 24 14:19:38 2006
@@ -29,6 +29,7 @@
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Properties;
 import java.util.StringTokenizer;
 
@@ -42,25 +43,12 @@
  * 
  */
 public final class EnvironmentReader {
-
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
     // The name of application resource files
     private static final String APPLICATION_RESOURCE_FILE = "jndi.properties"; //$NON-NLS-1$
 
     // The name of provider resource file
     private static final String PROVIDER_RESOURCE_FILE = "jndiprovider.properties"; //$NON-NLS-1$
 
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
     // Not allowed to create an instance
     private EnvironmentReader() {
     	super();
@@ -74,13 +62,13 @@
      * @param valueAddToList - whether to add new values of C-type properties
      */
     public static void mergeEnvironment(
-        final Hashtable src,
-        final Hashtable dst,
+        final Hashtable<?, ?> src,
+        final Hashtable<Object, Object> dst,
         final boolean valueAddToList) {
 
         Object key = null;
         String val = null;
-        Enumeration keys = src.keys();
+        Enumeration<?> keys = src.keys();
 
         while (keys.hasMoreElements()) {
             key = keys.nextElement();
@@ -102,9 +90,9 @@
                  */
 
                 // Read the original value
-                val = (String) dst.get(key);
+                val = (String)dst.get(key);
                 // Values are combined into a single list separated by colons. 
-                val = val + ":" + (String) src.get(key); //$NON-NLS-1$
+                val = val + ":" + src.get(key); //$NON-NLS-1$
                 // The final value becomes the resulting value of that property
                 dst.put(key, val);
             } else {
@@ -122,9 +110,9 @@
      * 
      * @return a hashtable holding the required properties.
      */
-    static Hashtable filterProperties(final JNDIPropertiesSource source) {
-        final Hashtable filteredProperties = new Hashtable();
-        Object propValue = null;
+    static Hashtable<Object, Object> filterProperties(final JNDIPropertiesSource source) {
+        final Hashtable<Object, Object> filteredProperties = new Hashtable<Object, Object>();
+        String propValue = null;
 
         propValue = source.getProperty(Context.INITIAL_CONTEXT_FACTORY);
         if (null != propValue) {
@@ -171,18 +159,18 @@
      * 
      * @param existingProps - existing properties
      */
-    public static void readSystemProperties(final Hashtable existingProps) {
+    public static void readSystemProperties(final Hashtable<Object, Object> existingProps) {
         /*
          * Privileged code is used to access system properties. This is 
          * required if JNDI is run in Applet or other applications which 
          * only have limited permissions to access certain resources.
          */
-        Hashtable systemProperties =
-            (Hashtable) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return filterProperties(new SystemPropertiesSource());
-            }
-        });
+        Hashtable<Object, Object> systemProperties = AccessController
+                .doPrivileged(new PrivilegedAction<Hashtable<Object, Object>>() {
+                    public Hashtable<Object, Object> run() {
+                        return filterProperties(new SystemPropertiesSource());
+                    }
+                });
         mergeEnvironment(systemProperties, existingProps, false);
     }
 
@@ -194,9 +182,9 @@
      * @param applet - the applet object
      * @param existingProps - existing properties
      */
-    public static void readAppletParameters(Object applet, Hashtable existingProps) {
+    public static void readAppletParameters(Object applet, Hashtable<Object, Object> existingProps) {
         if (null != applet) {
-            Hashtable appletParameters =
+            Hashtable<Object, Object> appletParameters =
                 filterProperties(new AppletParametersSource((Applet) applet));
             mergeEnvironment(appletParameters, existingProps, false);
         }
@@ -211,9 +199,9 @@
      * @param existingProps - existing properties, cannot be null
      * @param filter - to filter properties
      */
-    static Hashtable readMultipleResourceFiles(
+    static Hashtable<Object, Object> readMultipleResourceFiles(
         final String name,
-        final Hashtable existingProps,
+        final Hashtable<Object, Object> existingProps,
         ClassLoader cl)
         throws NamingException {
 
@@ -221,7 +209,7 @@
             cl = ClassLoader.getSystemClassLoader();
         }
 
-        Enumeration e = null;
+        Enumeration<URL> e = null;
         try {
             // Load all resource files
             e = cl.getResources(name);
@@ -238,7 +226,7 @@
         InputStream is = null;
         final Properties p = new Properties();
         while (e.hasMoreElements()) {
-            url = (URL) e.nextElement();
+            url = e.nextElement();
             try {
                 if (null != (is = url.openStream())) {
                     p.load(is);
@@ -271,12 +259,12 @@
      * 
      * @param existingProps - existing properties, cannot be null.
      */
-    public static Hashtable readApplicationResourceFiles(final Hashtable existingProps)
+    public static Hashtable<Object, Object> readApplicationResourceFiles(final Hashtable<Object, Object> existingProps)
         throws NamingException {
         // Use privileged code to read the application resource files
         try {
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws NamingException {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
+                public Void run() throws NamingException {
                     readMultipleResourceFiles(
                         APPLICATION_RESOURCE_FILE,
                         existingProps,
@@ -305,7 +293,7 @@
      * 
      * @param existingProps - existing properties, cannot be null.
      */
-    public static Hashtable readLibraryResourceFile(final Hashtable existingProps)
+    public static Hashtable<Object, Object> readLibraryResourceFile(final Hashtable<Object, Object> existingProps)
         throws NamingException {
         final String sep = System.getProperty("file.separator"); //$NON-NLS-1$
 
@@ -322,25 +310,22 @@
         final File resFile = new File(resPath);
         final Properties p = new Properties();
         // Use privileged code to determine whether the file exists
-        Boolean resFileExists =
-            (Boolean) AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                return new Boolean(resFile.exists());
+        boolean resFileExists = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+            public Boolean run() {
+                return Boolean.valueOf(resFile.exists());
             }
-        });
-        if (resFileExists.booleanValue()) {
+        }).booleanValue();
+        if (resFileExists) {
             try {
                 // Use privileged code to read the file
-                is =
-                    (
-                        FileInputStream) AccessController
-                            .doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run() throws IOException {
-                        InputStream localInputStream = new FileInputStream(resFile);
-                        p.load(localInputStream);
-                        return localInputStream;
-                    }
-                });
+                is = AccessController
+                        .doPrivileged(new PrivilegedExceptionAction<FileInputStream>() {
+                            public FileInputStream run() throws IOException {
+                                FileInputStream localInputStream = new FileInputStream(resFile);
+                                p.load(localInputStream);
+                                return localInputStream;
+                            }
+                        });
                 mergeEnvironment(p, existingProps, true);
             } catch (PrivilegedActionException e) {
                 // Can't read "java.home"/lib/jndi.properties
@@ -367,9 +352,9 @@
      * @param context - the context
      * @param existingProps - existing properties, cannot be null.
      */
-    public static Hashtable readProviderResourceFiles(
+    public static Hashtable<Object, Object> readProviderResourceFiles(
         final Context context,
-        final Hashtable existingProps)
+        final Hashtable<Object, Object> existingProps)
         throws NamingException {
 
         String factory = context.getClass().getName();
@@ -390,8 +375,8 @@
         // Use privileged code to read the provider resource files
         try {
             final String finalResPath = resPath;
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws NamingException {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
+                public String run() throws NamingException {
                     readMultipleResourceFiles(
                         finalResPath,
                         existingProps,
@@ -407,6 +392,7 @@
                 throw (RuntimeException) rootCause;
             } else {
                 // This should not happen.
+                throw new AssertionError(rootCause);
             }
         }
         return existingProps;
@@ -424,16 +410,16 @@
      * resource files.
      */
     public static String[] getFactoryNamesFromEnvironmentAndProviderResource(
-        Hashtable envmt,
+        Hashtable<?, ?> envmt,
         Context ctx,
         String key)
         throws NamingException {
 
-        ArrayList fnames = new ArrayList();
+        List<String> fnames = new ArrayList<String>();
 
         // collect tokens from envmt with key
         if (null != envmt) {
-            String str = (String) envmt.get(key);
+            String str = (String)envmt.get(key);
             if (null != str) {
                 StringTokenizer st = new StringTokenizer(str, ":"); //$NON-NLS-1$
                 while (st.hasMoreTokens()) {
@@ -443,10 +429,10 @@
         }
         // collect tokens from ctx's provider resource file
         if (null != ctx) {
-            Hashtable h = new Hashtable();
+            Hashtable<Object, Object> h = new Hashtable<Object, Object>();
             // read provider resource file from ctx's package
             EnvironmentReader.readProviderResourceFiles(ctx, h);
-            String str = (String) h.get(key);
+            String str = (String)h.get(key);
             if (null != str) {
                 StringTokenizer st = new StringTokenizer(str, ":"); //$NON-NLS-1$
                 while (st.hasMoreTokens()) {
@@ -459,7 +445,7 @@
             fnames.add("com.sun.jndi.url"); //$NON-NLS-1$
         }
         // return factory names
-        return (String[]) fnames.toArray(new String[fnames.size()]);
+        return fnames.toArray(new String[fnames.size()]);
     }
 
     /*
@@ -467,7 +453,7 @@
      */
     private interface JNDIPropertiesSource {
         // Get a JNDI property with the specified name
-        Object getProperty(final String propName);
+        String getProperty(final String propName);
     }
 
     /*
@@ -479,7 +465,7 @@
         	super();
         }
 
-        public Object getProperty(final String propName) {
+        public String getProperty(final String propName) {
             return System.getProperty(propName);
         }
     }
@@ -495,11 +481,9 @@
             this.applet = applet;
         }
 
-        public Object getProperty(final String propName) {
+        public String getProperty(final String propName) {
             return applet.getParameter(propName);
         }
     }
 
 }
-
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContext.java Sun Sep 24 14:19:38 2006
@@ -23,16 +23,17 @@
 
 import java.util.Hashtable;
 
+import javax.naming.Binding;
 import javax.naming.CannotProceedException;
 import javax.naming.CompositeName;
 import javax.naming.Context;
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
+import javax.naming.NameClassPair;
 import javax.naming.NameParser;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.OperationNotSupportedException;
-
 import javax.naming.spi.NamingManager;
 import javax.naming.spi.ResolveResult;
 
@@ -53,7 +54,7 @@
     /**
      * Local environment.
      */
-    protected Hashtable environment;
+    protected Hashtable<Object, Object> environment;
 
     /**
      * Creates instance of this context with empty environment.
@@ -68,10 +69,14 @@
      * @param   environment
      *          Environment to copy.
      */
-    protected GenericURLContext(Hashtable environment) {
-        this.environment = ((environment != null)
-                ? (Hashtable) environment.clone()
-                : new Hashtable());
+    @SuppressWarnings("unchecked")
+    protected GenericURLContext(Hashtable<?, ?> environment) {
+        super();
+        if (environment == null) {
+            this.environment = new Hashtable<Object, Object>();
+        } else {
+            this.environment = (Hashtable<Object, Object>) environment.clone();
+        }
     }
 
     /**
@@ -85,14 +90,12 @@
 
         if (name.size() == 1) {
             return lookup(name.get(0));
-        } else {
-            Context context = getContinuationContext(name);
-
-            try {
-                return context.lookup(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        Context context = getContinuationContext(name);
+        try {
+            return context.lookup(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -121,14 +124,12 @@
 
         if (name.size() == 1) {
             return lookupLink(name.get(0));
-        } else {
-            Context context = getContinuationContext(name);
-
-            try {
-                return context.lookupLink(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        Context context = getContinuationContext(name);
+        try {
+            return context.lookupLink(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -265,14 +266,12 @@
 
         if (name.size() == 1) {
             return createSubcontext(name.get(0));
-        } else {
-            Context context = getContinuationContext(name);
-
-            try {
-                return context.createSubcontext(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        Context context = getContinuationContext(name);
+        try {
+            return context.createSubcontext(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -399,7 +398,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
         if (!(name instanceof CompositeName)) {
             throw new InvalidNameException(
                     "URL context can't accept non-composite name: " + name);
@@ -407,21 +406,20 @@
 
         if (name.size() == 1) {
             return list(name.get(0));
-        } else {
-            Context context = getContinuationContext(name);
+        }
+        Context context = getContinuationContext(name);
 
-            try {
-                return context.list(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        try {
+            return context.list(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
         ResolveResult result = getRootURLContext(name, environment);
         Context context = (Context) result.getResolvedObj();
 
@@ -435,7 +433,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
         if (!(name instanceof CompositeName)) {
             throw new InvalidNameException(
                     "URL context can't accept non-composite name: " + name);
@@ -443,21 +441,20 @@
 
         if (name.size() == 1) {
             return listBindings(name.get(0));
-        } else {
-            Context context = getContinuationContext(name);
+        }
+        Context context = getContinuationContext(name);
 
-            try {
-                return context.listBindings(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        try {
+            return context.listBindings(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
         ResolveResult result = getRootURLContext(name, environment);
         Context context = (Context) result.getResolvedObj();
 
@@ -479,14 +476,12 @@
 
         if (name.size() == 1) {
             return getNameParser(name.get(0));
-        } else {
-            Context context = getContinuationContext(name);
-
-            try {
-                return context.getNameParser(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        Context context = getContinuationContext(name);
+        try {
+            return context.getNameParser(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -530,8 +525,8 @@
     /**
      * {@inheritDoc}
      */
-    public Hashtable getEnvironment() {
-        return (Hashtable) environment.clone();
+    public Hashtable<?, ?> getEnvironment() {
+        return (Hashtable<?, ?>) environment.clone();
     }
 
     /**
@@ -630,7 +625,7 @@
      *          If some naming error occurs.
      */
     protected abstract ResolveResult getRootURLContext(
-            String url, Hashtable environment) throws NamingException;
+            String url, Hashtable<?, ?> environment) throws NamingException;
 
     /**
      * Compares two URLs for equality.

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLContextFactory.java Sun Sep 24 14:19:38 2006
@@ -46,7 +46,9 @@
     /**
      * Default constructor for subclasses.
      */
-    protected GenericURLContextFactory() {}
+    protected GenericURLContextFactory() {
+        super();
+    }
 
     /**
      * Lookups the specified object in the underlying context.
@@ -93,7 +95,7 @@
      *          If lookup attempt failed.
      */
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-            Hashtable environment) throws NamingException {
+            Hashtable<?, ?> environment) throws NamingException {
         Context context = createURLContext(environment);
 
         if (obj == null) {
@@ -118,10 +120,10 @@
 
                 NamingException exception = null;
 
-                for (int i = 0; i < strings.length; i++) {
+                for (String element : strings) {
                     try {
                         // If the valid object is found - return it.
-                        return context.lookup(strings[i]);
+                        return context.lookup(element);
                     } catch (NamingException e) {
                         // Invalid object, store the exception
                         // to throw it later if no valid object is found.
@@ -152,5 +154,5 @@
      *
      * @return  New context instance.
      */
-    protected abstract Context createURLContext(Hashtable environment);
+    protected abstract Context createURLContext(Hashtable<?, ?> environment);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContext.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContext.java Sun Sep 24 14:19:38 2006
@@ -34,6 +34,7 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
 
 import javax.naming.spi.DirectoryManager;
 import javax.naming.spi.ResolveResult;
@@ -66,7 +67,7 @@
      * @param   environment
      *          Environment to copy.
      */
-    protected GenericURLDirContext(Hashtable environment) {
+    protected GenericURLDirContext(Hashtable<?, ?> environment) {
         super(environment);
     }
 
@@ -158,14 +159,12 @@
 
         if (name.size() == 1) {
             return createSubcontext(name.get(0), attrs);
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.createSubcontext(name.getSuffix(1), attrs);
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.createSubcontext(name.getSuffix(1), attrs);
+        } finally {
+            context.close();
         }
     }
 
@@ -195,14 +194,12 @@
 
         if (name.size() == 1) {
             return getAttributes(name.get(0));
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.getAttributes(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.getAttributes(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -232,14 +229,12 @@
 
         if (name.size() == 1) {
             return getAttributes(name.get(0), attrIds);
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.getAttributes(name.getSuffix(1), attrIds);
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.getAttributes(name.getSuffix(1), attrIds);
+        } finally {
+            context.close();
         }
     }
 
@@ -345,14 +340,12 @@
 
         if (name.size() == 1) {
             return getSchema(name.get(0));
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.getSchema(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.getSchema(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -382,14 +375,12 @@
 
         if (name.size() == 1) {
             return getSchemaClassDefinition(name.get(0));
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.getSchemaClassDefinition(name.getSuffix(1));
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.getSchemaClassDefinition(name.getSuffix(1));
+        } finally {
+            context.close();
         }
     }
 
@@ -411,7 +402,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(Name name, Attributes matchingAttributes)
+    public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes)
             throws NamingException {
         if (!(name instanceof CompositeName)) {
             throw new InvalidNameException(
@@ -420,21 +411,20 @@
 
         if (name.size() == 1) {
             return search(name.get(0), matchingAttributes);
-        } else {
-            DirContext context = getContinuationDirContext(name);
+        }
+        DirContext context = getContinuationDirContext(name);
 
-            try {
-                return context.search(name.getSuffix(1), matchingAttributes);
-            } finally {
-                context.close();
-            }
+        try {
+            return context.search(name.getSuffix(1), matchingAttributes);
+        } finally {
+            context.close();
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(String name, Attributes matchingAttributes)
+    public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes)
             throws NamingException {
         ResolveResult result = getRootURLContext(name, environment);
         DirContext context = (DirContext) result.getResolvedObj();
@@ -450,7 +440,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(Name name, Attributes matchingAttributes,
+    public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes,
             String[] attributesToReturn) throws NamingException {
         if (!(name instanceof CompositeName)) {
             throw new InvalidNameException(
@@ -459,22 +449,21 @@
 
         if (name.size() == 1) {
             return search(name.get(0), matchingAttributes, attributesToReturn);
-        } else {
-            DirContext context = getContinuationDirContext(name);
+        }
+        DirContext context = getContinuationDirContext(name);
 
-            try {
-                return context.search(name.getSuffix(1),
-                        matchingAttributes, attributesToReturn);
-            } finally {
-                context.close();
-            }
+        try {
+            return context.search(name.getSuffix(1),
+                    matchingAttributes, attributesToReturn);
+        } finally {
+            context.close();
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(String name, Attributes matchingAttributes,
+    public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes,
             String[] attributesToReturn) throws NamingException {
         ResolveResult result = getRootURLContext(name, environment);
         DirContext context = (DirContext) result.getResolvedObj();
@@ -490,7 +479,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(Name name, String filter,
+    public NamingEnumeration<SearchResult> search(Name name, String filter,
             SearchControls cons) throws NamingException {
         if (!(name instanceof CompositeName)) {
             throw new InvalidNameException(
@@ -499,21 +488,19 @@
 
         if (name.size() == 1) {
             return search(name.get(0), filter, cons);
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.search(name.getSuffix(1), filter, cons);
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.search(name.getSuffix(1), filter, cons);
+        } finally {
+            context.close();
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(String name, String filter,
+    public NamingEnumeration<SearchResult> search(String name, String filter,
             SearchControls cons) throws NamingException {
         ResolveResult result = getRootURLContext(name, environment);
         DirContext context = (DirContext) result.getResolvedObj();
@@ -528,7 +515,7 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(Name name, String filterExpr,
+    public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
             Object[] filterArgs, SearchControls cons) throws NamingException {
         if (!(name instanceof CompositeName)) {
             throw new InvalidNameException(
@@ -537,22 +524,20 @@
 
         if (name.size() == 1) {
             return search(name.get(0), filterExpr, filterArgs, cons);
-        } else {
-            DirContext context = getContinuationDirContext(name);
-
-            try {
-                return context.search(name.getSuffix(1),
-                        filterExpr, filterArgs, cons);
-            } finally {
-                context.close();
-            }
+        }
+        DirContext context = getContinuationDirContext(name);
+        try {
+            return context.search(name.getSuffix(1),
+                    filterExpr, filterArgs, cons);
+        } finally {
+            context.close();
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration search(String name, String filterExpr,
+    public NamingEnumeration<SearchResult> search(String name, String filterExpr,
             Object[] filterArgs, SearchControls cons) throws NamingException {
         ResolveResult result = getRootURLContext(name, environment);
         DirContext context = (DirContext) result.getResolvedObj();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/GenericURLDirContextFactory.java Sun Sep 24 14:19:38 2006
@@ -51,7 +51,9 @@
     /**
      * Default constructor for subclasses.
      */
-    protected GenericURLDirContextFactory() {}
+    protected GenericURLDirContextFactory() {
+        super();
+    }
 
     /**
      * Lookups the specified object in the underlying context.
@@ -105,7 +107,7 @@
      *          If lookup attempt failed.
      */
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-            Hashtable environment, Attributes attrs) throws Exception {
+            Hashtable<?, ?> environment, Attributes attrs) throws Exception {
         return getObjectInstance(obj, name, nameCtx, environment);
     }
 
@@ -114,7 +116,8 @@
      *
      * This implementation just calls {@link #createURLDirContext(Hashtable)}.
      */
-    protected final Context createURLContext(Hashtable environment) {
+    @Override
+    protected final Context createURLContext(Hashtable<?, ?> environment) {
         return createURLDirContext(environment);
     }
 
@@ -130,5 +133,5 @@
      *
      * @return  New context instance.
      */
-    protected abstract DirContext createURLDirContext(Hashtable environment);
+    protected abstract DirContext createURLDirContext(Hashtable<?, ?> environment);
 }



Mime
View raw message