harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r449489 [2/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
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/BasicNamingEnumerator.java Sun Sep 24 14:19:38 2006
@@ -30,54 +30,33 @@
  * @author Alexei Zakharov
  * @version $Revision: 1.1.2.4 $
  */
-public class BasicNamingEnumerator implements NamingEnumeration {
+public class BasicNamingEnumerator<T> implements NamingEnumeration<T> {
     
-    private Enumeration enum1 = null;
+    private final Enumeration<T> enumeration;
     
     /**
      * Constructs new enumerator from existing <code>Enumeration</code>.
-     * @param enum1 enumeration 
+     * @param enumeration enumeration 
      */
-    public BasicNamingEnumerator(Enumeration newEnum) {
-        this.enum1 = newEnum;
+    public BasicNamingEnumerator(Enumeration<T> newEnum) {
+        this.enumeration = newEnum;
     }
 
-    /**
-     * @return next element of enumeration
-     * @see javax.naming.NamingEnumeration#next()
-     */
-    public Object next() {
-        return enum1.nextElement();
+    public T next() {
+        return enumeration.nextElement();
     }
 
-    /**
-     * @return <code>true</code> if the enumeration has more elements
-     * @see javax.naming.NamingEnumeration#hasMore()
-     */
     public boolean hasMore() {
-        return enum1.hasMoreElements();
+        return enumeration.hasMoreElements();
     }
 
-    /**
-     * Do nothing in current implementation.
-     * @see javax.naming.NamingEnumeration#close()
-     */
     public void close() throws NamingException {}
 
-    /**
-     * @return next element of enumeration
-     * @see java.util.Enumeration#nextElement()
-     */
-    public Object nextElement() {
-        return enum1.nextElement();
+    public T nextElement() {
+        return enumeration.nextElement();
     }
 
-    /**
-     * @return <code>true</code> if the enumeration has more elements
-     * @see java.util.Enumeration#hasMoreElements()
-     */
     public boolean hasMoreElements() {
-        return enum1.hasMoreElements();
+        return enumeration.hasMoreElements();
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContext.java Sun Sep 24 14:19:38 2006
@@ -51,6 +51,7 @@
 import javax.naming.directory.InvalidAttributeIdentifierException;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
 import javax.naming.spi.DirectoryManager;
 import javax.naming.spi.NamingManager;
 
@@ -79,14 +80,14 @@
             "org.apache.harmony.jndi.provider.dns.threads.max";
 
     // used in internal methods
-    private static int NAME_CLASS_SWT = 1;
-    private static int BINDING_SWT = 2;
+    private static final int NAME_CLASS_SWT = 1;
+    private static final int BINDING_SWT = 2;
     
-    private DNSNameParser nameParser = null;
-    private Hashtable environment = null;
-    private Resolver resolver = null;
+    private DNSNameParser nameParser;
+    private Hashtable<Object, Object> environment;
+    private Resolver resolver;
 
-    private DNSName contextName = null;
+    private DNSName contextName;
 
     // default values for properties that has been read from the environment
     private boolean authoritative = ProviderConstants.DEFAULT_AUTHORITATIVE;
@@ -105,19 +106,20 @@
      * will make a clone of given hash table.
      * @throws InvalidNameException something wrong with domain names given in
      * <code>java.naming.provider.url</code> property
-     * @throws ConfigurationException if some error occured during parsing of
+     * @throws ConfigurationException if some error occurred during parsing of
      * configuration parameters
-     * @throws NamingException if some parse error occured
+     * @throws NamingException if some parse error occurred
      * @throws NullPointerException if the environment is null
      *  
      */
-    DNSContext(Hashtable env) throws NamingException
+    @SuppressWarnings("unchecked")
+    DNSContext(Hashtable<?, ?> env) throws NamingException
     {
         nameParser = new DNSNameParser();
         if (env == null) {
            throw new NullPointerException("environment is null");
         }
-        this.environment = (Hashtable) env.clone();
+        this.environment = (Hashtable<Object, Object>) env.clone();
         parseBoolProp(Context.AUTHORITATIVE);
         parseLookupProp();
         if (environment.containsKey(RECURSION)) {
@@ -290,10 +292,11 @@
      * @param ancestorCtx an ancestor context to read all internal properties from
      * @param name name of newly created context in the ancestor context
      */
+    @SuppressWarnings("unchecked")
     DNSContext(DNSContext ancestorCtx, DNSName name) {
         this.contextName = (DNSName) name.clone();
         this.nameParser = ancestorCtx.nameParser;
-        this.environment = (Hashtable) ancestorCtx.environment.clone();
+        this.environment = (Hashtable<Object, Object>) ancestorCtx.environment.clone();
         this.resolver = ancestorCtx.resolver;
         this.authoritative = ancestorCtx.authoritative;
         this.lookupAttrType = ancestorCtx.lookupAttrType;
@@ -475,7 +478,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(java.lang.String, javax.naming.directory.Attributes)
      */
-    public NamingEnumeration search(String arg0, Attributes arg1)
+    public NamingEnumeration<SearchResult> search(String arg0, Attributes arg1)
             throws NamingException
     {
         Object obj = lookup(arg0);
@@ -493,7 +496,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(javax.naming.Name, javax.naming.directory.Attributes)
      */
-    public NamingEnumeration search(Name arg0, Attributes arg1)
+    public NamingEnumeration<SearchResult> search(Name arg0, Attributes arg1)
             throws NamingException
     {
         Object obj = lookup(arg0);
@@ -669,9 +672,7 @@
                     DirectoryManager.getContinuationDirContext(cpe);
 
             attrs = nnsContext.getAttributes(remainingName, attrNames);
-        } else {
-            DNSContext resolvedCtx = new DNSContext(this, nameToLookFor);
-                
+        } else {                
             // analyze given attrNames object
             if (attrNames == null) {
                 // this means that all attributes should be obtained
@@ -681,19 +682,19 @@
                 classes[0] = ProviderConstants.ANY_QCLASS;
             }
             else {
-                HashSet classesSet = new HashSet();
-                HashSet typesSet = new HashSet();
-                Iterator iter;
+                HashSet<Integer> classesSet = new HashSet<Integer>();
+                HashSet<Integer> typesSet = new HashSet<Integer>();
+                Iterator<Integer> iter;
                 int j;
 
-                for (int i = 0; i < attrNames.length; i++) {
-                    int k = attrNames[i].indexOf(' ');
+                for (String element : attrNames) {
+                    int k = element.indexOf(' ');
                     String typeStr = null;
                     int classInt;
                     int typesInt;
     
                     if (k > 0) {
-                        String classStr = attrNames[i].substring(0, k);
+                        String classStr = element.substring(0, k);
 
                         classInt =
                                 ProviderMgr.getRecordClassNumber(classStr); 
@@ -702,13 +703,13 @@
                                     "Unknown record class: " + classStr);
                         }
                         classesSet.add(new Integer(classInt));
-                        typeStr = attrNames[i].substring(k, attrNames[i].length())
+                        typeStr = element.substring(k, element.length())
                                 .trim();
                     } 
                     else {
                         classesSet.add(new Integer(
                                 ProviderConstants.IN_CLASS));
-                        typeStr = attrNames[i].trim();
+                        typeStr = element.trim();
                     }
                     typesInt = ProviderMgr.getRecordTypeNumber(typeStr);
                     if (typesInt == -1) {
@@ -722,7 +723,7 @@
                 iter = classesSet.iterator();
                 j = 0;
                 while (iter.hasNext()) {
-                    Integer n = (Integer) iter.next();
+                    Integer n = iter.next();
 
                     classes[j++] = n.intValue();
                 }
@@ -731,7 +732,7 @@
                 iter = typesSet.iterator();
                 j = 0;
                 while (iter.hasNext()) {
-                    Integer n = (Integer) iter.next();
+                    Integer n = iter.next();
 
                     types[j++] = n.intValue();
                 }
@@ -740,7 +741,7 @@
             // we should have correct nameToLookFor, classes and types at this point
             // let's look for attributes
             try {
-                Enumeration records = resolver.lookup(nameToLookFor.toString(),
+                Enumeration<ResourceRecord> records = resolver.lookup(nameToLookFor.toString(),
                         types, classes);
 
                 attrs = createAttributesFromRecords(records);
@@ -787,16 +788,15 @@
         }
         if (pair.context instanceof DirContext) {
             return ((DirContext) pair.context).createSubcontext(pair.name, arg1);
-        } else {
-            throw new NotContextException("found object is not a DirContext"); 
         }
+        throw new NotContextException("found object is not a DirContext");
     }
 
     /** 
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(java.lang.String, javax.naming.directory.Attributes, java.lang.String[])
      */
-    public NamingEnumeration search(String arg0, Attributes arg1, String[] arg2)
+    public NamingEnumeration<SearchResult> search(String arg0, Attributes arg1, String[] arg2)
             throws NamingException
     {
         Object obj = lookup(arg0);
@@ -814,7 +814,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(javax.naming.Name, javax.naming.directory.Attributes, java.lang.String[])
      */
-    public NamingEnumeration search(Name arg0, Attributes arg1, String[] arg2)
+    public NamingEnumeration<SearchResult> search(Name arg0, Attributes arg1, String[] arg2)
             throws NamingException
     {
         Object obj = lookup(arg0);
@@ -832,7 +832,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(java.lang.String, java.lang.String, javax.naming.directory.SearchControls)
      */
-    public NamingEnumeration search(String arg0, String arg1,
+    public NamingEnumeration<SearchResult> search(String arg0, String arg1,
             SearchControls arg2) throws NamingException
     {
         Object obj = lookup(arg0);
@@ -850,7 +850,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(javax.naming.Name, java.lang.String, javax.naming.directory.SearchControls)
      */
-    public NamingEnumeration search(Name arg0, String arg1, SearchControls arg2)
+    public NamingEnumeration<SearchResult> search(Name arg0, String arg1, SearchControls arg2)
             throws NamingException
     {
         Object obj = lookup(arg0);
@@ -868,7 +868,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(java.lang.String, java.lang.String, java.lang.Object[], javax.naming.directory.SearchControls)
      */
-    public NamingEnumeration search(String arg0, String arg1, Object[] arg2,
+    public NamingEnumeration<SearchResult> search(String arg0, String arg1, Object[] arg2,
             SearchControls arg3) throws NamingException
     {
         Object obj = lookup(arg0);
@@ -886,7 +886,7 @@
      * This method is not supported.
      * @see javax.naming.directory.DirContext#search(javax.naming.Name, java.lang.String, java.lang.Object[], javax.naming.directory.SearchControls)
      */
-    public NamingEnumeration search(Name arg0, String arg1, Object[] arg2,
+    public NamingEnumeration<SearchResult> search(Name arg0, String arg1, Object[] arg2,
             SearchControls arg3) throws NamingException
     {
         Object obj = lookup(arg0);
@@ -937,8 +937,8 @@
      * @return a hash table with the context's environment
      * @see javax.naming.Context#getEnvironment()
      */
-    public Hashtable getEnvironment() throws NamingException {
-        return (Hashtable) environment.clone();
+    public Hashtable<?, ?> getEnvironment() throws NamingException {
+        return (Hashtable<?, ?>) environment.clone();
     }
 
     /** 
@@ -1144,7 +1144,7 @@
         } else {
             try {
                 DNSContext resolvedCtx = new DNSContext(this, nameToLookFor);
-                Enumeration records = resolver.lookup(nameToLookFor.toString(),
+                Enumeration<ResourceRecord> records = resolver.lookup(nameToLookFor.toString(),
                         types, classes);
                 Attributes attrs = createAttributesFromRecords(records);
 
@@ -1192,6 +1192,7 @@
             
             DNSContext context = (DNSContext) resolvedCtx.clone();
             
+            @Override
             public Object getContent() {
                 return context;
             }
@@ -1238,11 +1239,11 @@
      * @param recs enumeration of resource records received from the resolver
      * @return corresponding instance of <code>Attributes</code>
      */
-    private static Attributes createAttributesFromRecords(Enumeration recs) {
+    private static Attributes createAttributesFromRecords(Enumeration<ResourceRecord> recs) {
         Attributes attrs = new BasicAttributes(true);
         
         while (recs.hasMoreElements()) {
-            ResourceRecord curRec = (ResourceRecord) recs.nextElement();
+            ResourceRecord curRec = recs.nextElement();
             String clssTypeStr = null;
             Attribute oldAttr = null;
             
@@ -1351,9 +1352,8 @@
         }
         if (pair.context instanceof Context) {
             return ((Context) pair.context).createSubcontext(pair.name);
-        } else {
-            throw new NotContextException("found object is not a Context"); 
         }
+        throw new NotContextException("found object is not a Context");
     }
 
     /** 
@@ -1444,7 +1444,7 @@
      * @throws NamingException if an error was encountered
      * @see javax.naming.Context#list(javax.naming.Name)
      */
-    public NamingEnumeration list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
         return list_common(convertNameFromStringForm(name), NAME_CLASS_SWT);
     }
 
@@ -1456,7 +1456,7 @@
      * @throws NamingException if an error was encountered
      * @see javax.naming.Context#listBindings(java.lang.String)
      */
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
         return list_common(convertNameFromStringForm(name), BINDING_SWT);
     }
 
@@ -1470,11 +1470,11 @@
      * @throws NameNotFoundException if authoritative server(s) was not found
      * @throws ServiceUnavailableException if none of found servers permits zone
      * transfers   
-     * @throws DomainProtocolException if some DNS specific error has occured
-     * @throws NamingException if other type of error has occured 
+     * @throws DomainProtocolException if some DNS specific error has occurred
+     * @throws NamingException if other type of error has occurred 
      * @see javax.naming.Context#list(javax.naming.Name)
      */
-    public NamingEnumeration list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
         return list_common(name, NAME_CLASS_SWT);
     }
 
@@ -1496,13 +1496,14 @@
      * resolver's cache since we are sure the cache is up to date and contains
      * absolutely all records from target zone
      */
-    private NamingEnumeration list_common(Name name, int contentSwt)
+    @SuppressWarnings("unchecked")
+    private <T> NamingEnumeration<T> list_common(Name name, int contentSwt)
             throws NamingException
     {
         DNSName nameToList = null;
         DNSName altName = null;
         CompositeName remainingName = null;
-        NamingEnumeration result = null;
+        NamingEnumeration<T> result = null;
 
         if (contentSwt != 1 && contentSwt != 2) {
             throw new IllegalArgumentException(
@@ -1548,17 +1549,17 @@
                     altName, remainingName);
             Context nnsContext = DirectoryManager.getContinuationContext(cpe);
 
-            result = nnsContext.list(remainingName);
+            result = (NamingEnumeration<T>)nnsContext.list(remainingName);
         } else {
             // do the job
             try {
-                Enumeration resEnum = resolver.list(nameToList.toString());
-                Hashtable entries = new Hashtable();
+                Enumeration<ResourceRecord> resEnum = resolver.list(nameToList.toString());
+                Hashtable<String, T> entries = new Hashtable<String, T>();
                 DNSContext targetCtx = new DNSContext(this, nameToList); 
                 
                 // collecting direct children
                 while (resEnum.hasMoreElements()) {
-                    ResourceRecord rr = (ResourceRecord) resEnum.nextElement();
+                    ResourceRecord rr = resEnum.nextElement();
                     // fullName is an full name of current record
                     Name curName = nameParser.parse(rr.getName());
 
@@ -1572,7 +1573,7 @@
                         // if we don't have such child yet 
                         if (!entries.containsKey(elNameStr)) {
                             Object elObj;
-                            Object objToPut = null;
+                            T objToPut = null;
                             // absolute name of direct child
                             DNSName elNameAbs = null;
                             // relative name of direct child
@@ -1584,25 +1585,25 @@
                             elNameRel.add(elNameStr);
                             elNameAbs = (DNSName) nameToList.clone();
                             elNameAbs.add(elNameStr);
-                            elCtx = new DNSContext(this, (DNSName) elNameAbs);
+                            elCtx = new DNSContext(this, elNameAbs);
                             elObj = DirectoryManager.getObjectInstance(elCtx,
                                     elNameRel, targetCtx, environment, null);
                             switch (contentSwt) {
                             case 1:
                                 // NameClassPair
-                                objToPut = new NameClassPair(elNameStr,
+                                objToPut = (T)new NameClassPair(elNameStr,
                                         elObj.getClass().getName(), true);
                                 break;
                             case 2:
                                 // Binding
-                                objToPut = new Binding(elNameStr, elObj, true);
+                                objToPut = (T)new Binding(elNameStr, elObj, true);
                                 break;
                             }
                             entries.put(elNameStr, objToPut);
                         }
                     }
                 }
-                result = new BasicNamingEnumerator(entries.elements());
+                result = new BasicNamingEnumerator<T>(entries.elements());
             } catch (SecurityException e) {
                 throw e;
             } catch (NamingException e) {
@@ -1626,7 +1627,7 @@
      * @throws NamingException if an error was encountered
      * @see javax.naming.Context#listBindings(javax.naming.Name)
      */
-    public NamingEnumeration listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
         return list_common(name, BINDING_SWT);
     }
 
@@ -1887,6 +1888,7 @@
      * Constructs the clone of this DNS context.
      * @see Object#clone()
      */
+    @Override
     public Object clone() {
         return new DNSContext(this, contextName);
     }
@@ -1899,6 +1901,7 @@
      * @return <code>true</code> if given object is equal to this one;
      *  <code>false</code> otherwise
      */
+    @Override
     public boolean equals(Object obj) {
         if (obj != null && obj instanceof DNSContext &&
                 contextName.equals(((DNSContext) obj).contextName)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContextFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContextFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSContextFactory.java Sun Sep 24 14:19:38 2006
@@ -37,7 +37,9 @@
     /**
      * Empty constructor.
      */
-    public DNSContextFactory() {}
+    public DNSContextFactory() {
+        super();
+    }
 
     /**
      * Creates a new instance of DNS context.
@@ -46,7 +48,7 @@
      * @return new instance of <code>DNSContext</code>
      * @see javax.naming.spi.InitialContextFactory#getInitialContext(java.util.Hashtable)
      */
-    public Context getInitialContext(Hashtable env) throws NamingException {
+    public Context getInitialContext(Hashtable<?, ?> env) throws NamingException {
         return new DNSContext(env);
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSName.java Sun Sep 24 14:19:38 2006
@@ -41,13 +41,14 @@
 
     private static final long serialVersionUID = -5931312723719884197L;
     
-    Vector components = null;
+    private Vector<String> components;
     
     /**
      * Constructs an empty DNS name.
      */
     public DNSName() {
-        components = new Vector();
+        super();
+        components = new Vector<String>();
     }
 
     /**
@@ -55,7 +56,7 @@
      * 
      * @param compVect the vector of name components
      */
-    DNSName(Vector compVect) {
+    DNSName(Vector<String> compVect) {
         components = compVect;
     }
 
@@ -81,7 +82,7 @@
      */
     public boolean isAbsolute() {
         if (components.size() > 0) {
-            String el0 = (String) components.get(0);
+            String el0 = components.get(0);
 
             if (el0 != null && el0.length() == 0) {
                 return true;
@@ -94,9 +95,10 @@
      * Returns clone of the current name.
      * @see java.lang.Object#clone()
      */
+    @Override
     public Object clone() {
-        Vector compClone = new Vector();
-        Enumeration compEnum = this.components.elements();
+        Vector<String> compClone = new Vector<String>();
+        Enumeration<String> compEnum = this.components.elements();
 
         while (compEnum.hasMoreElements()) {
             compClone.addElement(compEnum.nextElement());
@@ -133,8 +135,8 @@
      */
     public int compareTo(Object name) {
         DNSName nameToCompareWith = null;
-        Enumeration enum1;
-        Enumeration enum2;
+        Enumeration<String> enum1;
+        Enumeration<String> enum2;
 
         if (name == null) {
             throw new NullPointerException("The name is null");
@@ -147,14 +149,14 @@
         enum1 = this.getAll();
         enum2 = nameToCompareWith.getAll();
         while (enum1.hasMoreElements()) {
-            String comp1 = (String) enum1.nextElement();
+            String comp1 = enum1.nextElement();
             String comp2;
             int k;
 
             if (!enum2.hasMoreElements()) {
                 return 1;
             }
-            comp2 = (String) enum2.nextElement();
+            comp2 = enum2.nextElement();
             k = comp1.compareToIgnoreCase(comp2);
             if (k != 0) {
                 return k;
@@ -174,7 +176,7 @@
      * @see javax.naming.Name#get(int)
      */
     public String get(int posn) {
-        return (String) components.elementAt(posn); 
+        return components.elementAt(posn); 
     }
 
     /**
@@ -182,7 +184,7 @@
      * @return enumeration of strings
      * @see javax.naming.Name#getAll()
      */
-    public Enumeration getAll() {
+    public Enumeration<String> getAll() {
         return components.elements();
     }
 
@@ -196,7 +198,7 @@
      * @see javax.naming.Name#getPrefix(int)
      */
     public Name getPrefix(int posn) {
-        Vector prefix = new Vector();
+        Vector<String> prefix = new Vector<String>();
 
         for (int i = 0; i < posn; i++) {
             prefix.addElement(components.elementAt(i));
@@ -214,7 +216,7 @@
      * @see javax.naming.Name#getSuffix(int)
      */
     public Name getSuffix(int posn) {
-        Vector prefix = new Vector();
+        Vector<String> prefix = new Vector<String>();
 
         for (int i = posn; i < components.size(); i++) {
             prefix.addElement(components.elementAt(i));
@@ -344,7 +346,7 @@
      * @see javax.naming.Name#addAll(int, javax.naming.Name)
      */
     public Name addAll(int posn, Name name) throws InvalidNameException {
-        Vector newComps;
+        Vector<String> newComps;
 
         if (!(name instanceof DNSName)) {
             throw new InvalidNameException("Given name is not an instance of " +
@@ -364,7 +366,7 @@
      * @see javax.naming.Name#addAll(javax.naming.Name)
      */
     public Name addAll(Name name) throws InvalidNameException {
-        Vector newComps;
+        Vector<String> newComps;
 
         if (!(name instanceof DNSName)) {
             throw new InvalidNameException("Given name is not an instance of " +
@@ -379,12 +381,13 @@
      * Returns the string representation of this DNS name.
      * @return DNS name in string form
      */
+    @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
 
         
         for (int i = components.size() - 1; i >= 0; i--) {
-            String comp = (String) components.elementAt(i);
+            String comp = components.elementAt(i);
             if (sb.length() > 0 || i == 0) {
                 sb.append('.');
             }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSNameParser.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSNameParser.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSNameParser.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/DNSNameParser.java Sun Sep 24 14:19:38 2006
@@ -102,6 +102,7 @@
      * @return <code>true</code> if and only if the given object is instance of
      * class <code>DNSParser</code>; otherwise returns <code>false</code>.
      */
+    @Override
     public boolean equals(Object obj) {
         if (obj != null && obj instanceof DNSNameParser) {
             return true;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Message.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Message.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Message.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Message.java Sun Sep 24 14:19:38 2006
@@ -76,17 +76,17 @@
     /** ARCOUNT, number of records in additional section */
     private int arCount = 0;
 
-    private Vector questionRecords = null;
-    private Vector answerRRs = null;
-    private Vector authorityRRs = null;
-    private Vector additionalRRs = null;
+    private Vector<QuestionRecord> questionRecords = null;
+    private Vector<ResourceRecord> answerRRs = null;
+    private Vector<ResourceRecord> authorityRRs = null;
+    private Vector<ResourceRecord> additionalRRs = null;
 
     /** */
     public Message() {
-        questionRecords = new Vector();
-        answerRRs = new Vector();
-        authorityRRs = new Vector();
-        additionalRRs = new Vector();
+        questionRecords = new Vector<QuestionRecord>();
+        answerRRs = new Vector<ResourceRecord>();
+        authorityRRs = new Vector<ResourceRecord>();
+        additionalRRs = new Vector<ResourceRecord>();
     }
 
     /** 
@@ -131,10 +131,10 @@
         this.anCount = anCount;
         this.nsCount = nsCount;
         this.arCount = arCount;
-        questionRecords = new Vector();
-        answerRRs = new Vector();
-        authorityRRs = new Vector();
-        additionalRRs = new Vector();
+        questionRecords = new Vector<QuestionRecord>();
+        answerRRs = new Vector<ResourceRecord>();
+        authorityRRs = new Vector<ResourceRecord>();
+        additionalRRs = new Vector<ResourceRecord>();
     }
     
     /**
@@ -187,25 +187,25 @@
         idx = ProviderMgr.write16Int(arCount, buffer, idx);
         // question section
         for (int i = 0; i < questionRecords.size(); i++) {
-            QuestionRecord qr = (QuestionRecord) questionRecords.elementAt(i);
+            QuestionRecord qr = questionRecords.elementAt(i);
 
             idx = qr.writeBytes(buffer, idx);
         }
         // answer section
         for (int i = 0; i < answerRRs.size(); i++) {
-            ResourceRecord rr = (ResourceRecord) answerRRs.elementAt(i);
+            ResourceRecord rr = answerRRs.elementAt(i);
 
             idx = rr.writeBytes(buffer, idx);
         }
         // authority section
         for (int i = 0; i < authorityRRs.size(); i++) {
-            ResourceRecord rr = (ResourceRecord) answerRRs.elementAt(i);
+            ResourceRecord rr = answerRRs.elementAt(i);
 
             idx = rr.writeBytes(buffer, idx);
         }
         // additional section
         for (int i = 0; i < additionalRRs.size(); i++) {
-            ResourceRecord rr = (ResourceRecord) answerRRs.elementAt(i);
+            ResourceRecord rr = answerRRs.elementAt(i);
 
             idx = rr.writeBytes(buffer, idx);
         }
@@ -307,6 +307,7 @@
     /**
      * @return string representation of this message 
      */
+    @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
 
@@ -505,7 +506,7 @@
     /**
      * @return question records that are contained by the current message.
      */
-    public Enumeration getQuestionRecords() {
+    public Enumeration<QuestionRecord> getQuestionRecords() {
         return questionRecords.elements();
     }
     
@@ -520,7 +521,7 @@
     /**
      * @return available answer resource records
      */
-    public Enumeration getAnswerRRs() {
+    public Enumeration<ResourceRecord> getAnswerRRs() {
         return answerRRs.elements();
     }
 
@@ -535,7 +536,7 @@
     /**
      * @return available authority resource records
      */
-    public Enumeration getAuthorityRRs() {
+    public Enumeration<ResourceRecord> getAuthorityRRs() {
         return authorityRRs.elements();
     }
 
@@ -550,7 +551,7 @@
     /**
      * @return available additional resource records
      */
-    public Enumeration getAdditionalRRs() {
+    public Enumeration<ResourceRecord> getAdditionalRRs() {
         return additionalRRs.elements();
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ProviderMgr.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ProviderMgr.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ProviderMgr.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ProviderMgr.java Sun Sep 24 14:19:38 2006
@@ -145,25 +145,23 @@
                 parseName(mesBytes, namePtr, result);
                 break;
             }
-            else {
-                // plain label
-                if (n > ProviderConstants.LABEL_MAX_CHARS) {
-                    throw new DomainProtocolException("Domain label is too " +
-                            " long");
-                }
-                if (idx + n > mesBytes.length) {
-                    throw new DomainProtocolException("Truncated data while " +
-                            " parsing the domain name");
-                }
-                // append parsed label
-                if (firstTime) {
-                    firstTime = false;                
-                } else {
-                    result.append('.');
-                }
-                result.append(new String(mesBytes, idx, n));
-                idx += n;
+            // plain label
+            if (n > ProviderConstants.LABEL_MAX_CHARS) {
+                throw new DomainProtocolException("Domain label is too " +
+                        " long");
             }
+            if (idx + n > mesBytes.length) {
+                throw new DomainProtocolException("Truncated data while " +
+                        " parsing the domain name");
+            }
+            // append parsed label
+            if (firstTime) {
+                firstTime = false;                
+            } else {
+                result.append('.');
+            }
+            result.append(new String(mesBytes, idx, n));
+            idx += n;
         }
         return idx;
     }
@@ -259,7 +257,7 @@
      * @return parsed integer value
      */
     public static int parse8Int(byte[] buffer, int idx) {
-        return ((int) buffer[idx]) & 0xff;
+        return (buffer[idx]) & 0xff;
     }
 
     /**
@@ -270,8 +268,8 @@
      * @return parsed integer value
      */
     public static int parse16Int(byte[] buffer, int idx) {
-        int a = (((int) buffer[idx]) & 0xff) << 8;
-        int b = ((int) buffer[idx + 1]) & 0xff;
+        int a = ((buffer[idx]) & 0xff) << 8;
+        int b = (buffer[idx + 1]) & 0xff;
 
         return (a | b);
     }
@@ -315,8 +313,8 @@
         }
         bytes = value.getBytes();
         buffer[idx++] = (byte) bytes.length; 
-        for (int i = 0; i < bytes.length; i++) {
-            buffer[idx++] = bytes[i];
+        for (byte element : bytes) {
+            buffer[idx++] = element;
         }
         return idx;
     }
@@ -368,9 +366,8 @@
     public static boolean checkBit(int value, int mask) {
         if ((value & mask) == 0) {
             return false;
-        } else {
-            return true;
         }
+        return true;
     }
 
     /**
@@ -432,10 +429,8 @@
         if (zone == null) {
             return zone;
         }
-        else {
-            return zone.endsWith(".") ? zone.toLowerCase() :
-                    zone.toLowerCase() + ".";
-        }
+        return zone.endsWith(".") ? zone.toLowerCase() :
+                zone.toLowerCase() + ".";
     }
     
 
@@ -458,7 +453,7 @@
             if (i > 0) {
                 sb.append(".");
             }
-            sb.append("" + (((int) ip[i]) & 0xff));
+            sb.append("" + ((ip[i]) & 0xff));
         }
         return sb.toString();
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/QuestionRecord.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/QuestionRecord.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/QuestionRecord.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/QuestionRecord.java Sun Sep 24 14:19:38 2006
@@ -124,6 +124,7 @@
         return idx;
     }
    
+    @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
         String qClassStr, qTypeStr;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Resolver.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Resolver.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Resolver.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/Resolver.java Sun Sep 24 14:19:38 2006
@@ -38,6 +38,8 @@
 import javax.naming.NamingException;
 import javax.naming.ServiceUnavailableException;
 
+import org.apache.harmony.jndi.provider.dns.SList.Server;
+
 //import org.apache.harmony.util.logging.LogConst;
 
 /**
@@ -73,8 +75,6 @@
 public class Resolver implements Runnable {
     
     private static final int MSG_MAX_BYTES = 512;
-    private static final int MAX_THREADS = 5;
-
     /**
      * Entry of the resolver thread list.
      * @author Alexei Zakharov
@@ -86,7 +86,7 @@
     }
 
     
-    private static Random rndGen = new Random();
+    private static final Random rndGen = new Random();
 
     // resolver configuration
     private int initialTimeout;
@@ -97,11 +97,11 @@
     private int threadNumberLimit;
     
     // vector with currently running Resolver threads 
-    private Vector resolverThreads = new Vector();
+    private final Vector<ThreadListEntry> resolverThreads = new Vector<ThreadListEntry>();
     // the list of host names that should be resolved
-    private Vector hostnamesToResolve = new Vector();
+    private final Vector<ThreadListEntry> hostnamesToResolve = new Vector<ThreadListEntry>();
     // semaphore that controls access to both lists above
-    private Object threadListSemaphore = new Object();
+    private final Object threadListSemaphore = new Object();
     
     // <---- Constructor's section
     
@@ -232,7 +232,7 @@
      * desired name was found or all servers are dead or malfunction   
      * @throws DomainProtocolException if some DNS specific error has occured 
      */
-    public Enumeration lookup(String name, int[] types, int[] classes)
+    public Enumeration<ResourceRecord> lookup(String name, int[] types, int[] classes)
            throws SecurityException,
                   NameNotFoundException,
                   ServiceUnavailableException,
@@ -267,8 +267,8 @@
         //SList slist = SList.getInstance();
         ResolverCache cache = ResolverCache.getInstance();
         
-        Vector questions = new Vector();
-        Vector answers = new Vector(); 
+        Vector<QuestionRecord> questions = new Vector<QuestionRecord>();
+        Vector<ResourceRecord> answers = new Vector<ResourceRecord>(); 
 
         
         if (name == null) {
@@ -280,24 +280,23 @@
         if (classes == null) {
             throw new NullPointerException("classes is null");
         }
-        // construct a set of question records
-        for (int i = 0; i < classes.length; i++) {
-            for (int j = 0; j < types.length; j++) {
-                QuestionRecord quest = new QuestionRecord(name, types[j],
-                        classes[i]);
+        for (int element : classes) {
+            for (int element0 : types) {
+                QuestionRecord quest = new QuestionRecord(name, element0,
+                        element);
                 questions.addElement(quest);
             }
         }
         // iterate over question records
         for (int i = 0; i < questions.size(); i++) {
             QuestionRecord curQuestion =
-                    (QuestionRecord) questions.elementAt(i);
+                    questions.elementAt(i);
             String qName = curQuestion.getQName();
             Message mesToSend = null;
             Message receivedMes = null;
             AnalysisReport report = null;
             String workZone;
-            Hashtable visitedServers = new Hashtable();
+            Hashtable<Server, Object> visitedServers = new Hashtable<Server, Object>();
 
             //if (LogConst.DEBUG) {
             //    ProviderMgr.logger.fine("Current question: " +
@@ -307,7 +306,7 @@
             if (curQuestion.getQType() != ProviderConstants.ANY_QTYPE &&
                     curQuestion.getQClass() != ProviderConstants.ANY_QCLASS)
             {
-                Enumeration recEnum = cache.get(curQuestion);
+                Enumeration<ResourceRecord> recEnum = cache.get(curQuestion);
 
                 if (recEnum.hasMoreElements()) {
                     while (recEnum.hasMoreElements()) {
@@ -365,8 +364,7 @@
                             for (int k = 0; k < report.extraRecords.size();
                                      k++)
                             {
-                                ResourceRecord rec = (ResourceRecord)
-                                        report.extraRecords.elementAt(k);
+                                ResourceRecord rec = report.extraRecords.elementAt(k);
     
                                 cache.put(rec);
                             }
@@ -384,8 +382,7 @@
                             //          "Lookup: a complete answer was received");
                             //}
                             for (int k = 0; k < report.records.size(); k++) {
-                                ResourceRecord rec = (ResourceRecord)
-                                        report.records.elementAt(k); 
+                                ResourceRecord rec = report.records.elementAt(k); 
                                 answers.addElement(rec);
                                 // we are sure that the answer section has not
                                 // been truncated so we can put the record
@@ -419,7 +416,7 @@
                                 curQuestion.getQClass() !=
                                         ProviderConstants.ANY_QCLASS)
                             {
-                                Enumeration recEnum = cache.get(curQuestion);
+                                Enumeration<ResourceRecord> recEnum = cache.get(curQuestion);
 
                                 if (recEnum.hasMoreElements()) {
                                     while (recEnum.hasMoreElements()) {
@@ -440,7 +437,7 @@
                             else {
                                 workZone = ".";
                             }
-                            visitedServers = new Hashtable();
+                            visitedServers = new Hashtable<Server, Object>();
                             for (int k = 0; k < report.records.size(); k++) {
                                 answers.addElement(report.records.elementAt(k));
                             }
@@ -473,8 +470,7 @@
                             for (int k = 0; k < report.delegationZones.size();
                                     k++)
                             {
-                                String curZone = (String)
-                                        report.delegationZones.elementAt(k);
+                                String curZone = report.delegationZones.elementAt(k);
                                 int tmpMatchingCount = ProviderMgr.
                                         getMatchingCount(qName, curZone);
     
@@ -486,8 +482,7 @@
                             }
                             if (k17 != -1) {
                                 // better delegation was received
-                                workZone = (String)
-                                        report.delegationZones.elementAt(k17);
+                                workZone = report.delegationZones.elementAt(k17);
                                 //if (LogConst.DEBUG) {                            
                                 //    ProviderMgr.logger.fine(
                                 //         "Lookup: better delegation was found");
@@ -557,18 +552,18 @@
      * transfers   
      * @throws DomainProtocolException if some DNS specific error has occured 
      */
-    public Enumeration list(String name) throws NamingException {
+    public Enumeration<ResourceRecord> list(String name) throws NamingException {
         final int OUT_BUF_SIZE = 512;
         final int IN_BUF_SIZE = 65536;
         
-        Vector answerVect = new Vector(); 
+        Vector<ResourceRecord> answerVect = new Vector<ResourceRecord>(); 
         Message mesToSend = null;
         Message receivedMes = null;
-        Enumeration enum1;
+        Enumeration<ResourceRecord> enum1;
         //String zoneMasterServer = null;
         //Vector authoritativeServerIPs = new Vector();
-        HashSet authoritativeServers = new HashSet();
-        Iterator authServersIter;
+        HashSet<Object> authoritativeServers = new HashSet<Object>();
+        Iterator<Object> authServersIter;
         int qClassArr[] = new int[1];
         byte outBuf[] = new byte[OUT_BUF_SIZE];
         int outLen;
@@ -608,10 +603,10 @@
         outLen = mesToSend.writeBytes(outBuf, 0);
         // determine the list of zone authoritative servers
         while (enum1.hasMoreElements()) {
-            ResourceRecord rr = (ResourceRecord) enum1.nextElement();
+            ResourceRecord rr = enum1.nextElement();
 
             if (rr.getRRType() == ProviderConstants.NS_TYPE) {
-                authoritativeServers.add((String) rr.getRData());
+                authoritativeServers.add(rr.getRData());
                 // assertion: all authoritative servers should have the same
                 // DNS class
                 qClassArr[0] = rr.getRRClass();
@@ -623,8 +618,6 @@
                     authoritativeServers.add(st.nextToken());
                     qClassArr[0] = rr.getRRClass();
                     break;
-                } else {
-                    //ProviderMgr.logger.warning("Invalid SOA record");
                 }
             }
         }
@@ -633,20 +626,19 @@
       authServersLoop:
         while (authServersIter.hasNext()) {
             String authServerName = (String) authServersIter.next();
-            Enumeration addrEnum = lookup(authServerName,
+            Enumeration<ResourceRecord> addrEnum = lookup(authServerName,
                     new int[] {ProviderConstants.A_TYPE}, qClassArr);
             
             while (addrEnum.hasMoreElements()) {
-                ResourceRecord curRR = (ResourceRecord) addrEnum.nextElement();
+                ResourceRecord curRR = addrEnum.nextElement();
                 String ip = (String) curRR.getRData();
-                int n;
 
                 try {
                     //if (LogConst.DEBUG) {                            
                     //    ProviderMgr.logger.fine(
                     //            "Initiating zone transfer, IP=" + ip);
                     //}
-                    n = TransportMgr.sendReceiveTCP(ip,
+                    TransportMgr.sendReceiveTCP(ip,
                             ProviderConstants.DEFAULT_DNS_PORT,
                             outBuf, outLen, inBuf, IN_BUF_SIZE,
                             this.initialTimeout * this.timeoutRetries);
@@ -684,8 +676,7 @@
                                     break;
                                 }
                                 while (enum1.hasMoreElements()) {
-                                    ResourceRecord rr = (ResourceRecord)
-                                            enum1.nextElement();
+                                    ResourceRecord rr = enum1.nextElement();
     
                                     cache.put(rr);
                                     if (k == 0) {
@@ -727,11 +718,10 @@
         // SRV _Proto prefix support - filter all records that don't have given
         // _Proto field
         if (proto != null) {
-            Vector answerVect2 = new Vector();
+            Vector<ResourceRecord> answerVect2 = new Vector<ResourceRecord>();
 
             for (int i = 0; i < answerVect.size(); i++) {
-                ResourceRecord rr = (ResourceRecord)
-                        answerVect.elementAt(i);
+                ResourceRecord rr = answerVect.elementAt(i);
                 StringTokenizer st = new StringTokenizer(rr.getName(),
                         ".");
                 String token = null;
@@ -812,7 +802,7 @@
      *  to use sockets
      */
     Message queryServers(Message request, String workZone,
-            Hashtable visitedServers, boolean tcpOnly)
+            Hashtable<Server, Object> visitedServers, boolean tcpOnly)
             throws DomainProtocolException, SecurityException
     {
         QuestionRecord qRecord;
@@ -822,7 +812,6 @@
         byte[] outBuf = new byte[MSG_MAX_BYTES];
         int outBufLen;
         byte[] inBuf = new byte[MSG_MAX_BYTES];
-        Message mes = new Message();
         Message receivedMes = null;
         int idx = 0;
         int curTimeout = this.initialTimeout;
@@ -836,18 +825,16 @@
         if (!request.getQuestionRecords().hasMoreElements()) {
             throw new IllegalArgumentException("no question record");
         }
-        qRecord = (QuestionRecord) request.getQuestionRecords().nextElement();
+        qRecord = request.getQuestionRecords().nextElement();
         // preparing a domain protocol message
         outBufLen = request.writeBytes(outBuf, 0);
 
         // sending message and trying to receive an answer
         for (int round = 0; round < this.timeoutRetries; round++) {
-            Set queriedServers = new HashSet();
+            Set<Server> queriedServers = new HashSet<Server>();
 
             // start of round
             while (true) {
-                String srvStr = null;
-                long timeBeforeSending;
                 int responseTime = 0;
 
                 received = false;
@@ -912,9 +899,6 @@
                 // parse the message
                 if (received) {
                     try {
-                        String errMsg = "SERVER: " + srvStr + ":" +
-                                curServer.getPort() + " QNAME: " +
-                                qRecord.getQName();
                         boolean answerSectionIsTruncated = false;
 
                         receivedMes = new Message();
@@ -1016,19 +1000,18 @@
                                 //            "Return name error to user");
                                 //}
                                 break;
-                            } else {
-                                // This server is not authoritative server for
-                                // this zone. It should not answer with a 
-                                // name error. Probably it is misconfigured.
-                                slist.updateEntry(workZone, curServer,
-                                        SList.SERVER_FAILURE);
-                                visitedServers.put(curServer, new Object());
-                                //if (LogConst.DEBUG) {                            
-                                //    ProviderMgr.logger.fine(
-                                //            "Not authoritative answer. " +
-                                //            "Skip it.");
-                                //}
                             }
+                            // This server is not authoritative server for
+                            // this zone. It should not answer with a 
+                            // name error. Probably it is misconfigured.
+                            slist.updateEntry(workZone, curServer,
+                                    SList.SERVER_FAILURE);
+                            visitedServers.put(curServer, new Object());
+                            //if (LogConst.DEBUG) {                            
+                            //    ProviderMgr.logger.fine(
+                            //            "Not authoritative answer. " +
+                            //            "Skip it.");
+                            //}
                         } else if (rCode == ProviderConstants.NOT_IMPLEMENTED) {
                             //ProviderMgr.logger.warning("Not implemented. " +
                             //        errMsg);
@@ -1080,10 +1063,10 @@
     AnalysisReport analyzeAnswer(Message request, Message answer)
             throws DomainProtocolException
     {
-        Enumeration questions = request.getQuestionRecords();
-        Enumeration answerRRs = answer.getAnswerRRs();
-        Enumeration authorityRRs = answer.getAuthorityRRs();
-        Enumeration additionalRRs;
+        Enumeration<QuestionRecord> questions = request.getQuestionRecords();
+        Enumeration<ResourceRecord> answerRRs = answer.getAnswerRRs();
+        Enumeration<ResourceRecord> authorityRRs = answer.getAuthorityRRs();
+        Enumeration<ResourceRecord> additionalRRs;
         QuestionRecord question;
         Resolver.AnalysisReport report = new AnalysisReport(); 
 
@@ -1095,11 +1078,11 @@
         
         // Determine a question.
         if (questions.hasMoreElements()) {
-            question = (QuestionRecord) questions.nextElement();
+            question = questions.nextElement();
         } else {
             throw new IllegalArgumentException("no question record");
         }
-        // If name error occured - no extra processing needed.
+        // If name error occurred - no extra processing needed.
         if (answer.getRCode() == ProviderConstants.NAME_ERROR) {
             report.nameError = true;
             return report;
@@ -1110,7 +1093,7 @@
         }
         // Analyze answer section.
         while (answerRRs.hasMoreElements()) {
-            ResourceRecord curRec = (ResourceRecord) answerRRs.nextElement();
+            ResourceRecord curRec = answerRRs.nextElement();
 
             if (question.getQClass() == curRec.getRRClass() ||
                     question.getQClass() == ProviderConstants.ANY_QCLASS)
@@ -1175,8 +1158,8 @@
                     // from the SLIST with this new name.   
                     
                     // TODO this is not effective
-                    Enumeration answerRRs2 = answer.getAnswerRRs();
-                    Enumeration additionalRRs2 = answer.getAdditionalRRs();
+                    Enumeration<ResourceRecord> answerRRs2 = answer.getAnswerRRs();
+                    Enumeration<ResourceRecord> additionalRRs2 = answer.getAdditionalRRs();
                         
                     report.aliasInfoWasReceived = true;
                     report.newName = (String) curRec.getRData();
@@ -1192,8 +1175,7 @@
                         // Try to look for info about newly received name 
                         // in ANSWER section.
 
-                        ResourceRecord tmpRec = (ResourceRecord)
-                                answerRRs2.nextElement();
+                        ResourceRecord tmpRec = answerRRs2.nextElement();
 
                         //if (LogConst.DEBUG) {                            
                         //    ProviderMgr.logger.fine(
@@ -1217,8 +1199,7 @@
                         // Try to look for info about newly received name 
                         // in ADDITIONAL section.
 
-                        ResourceRecord tmpRec = (ResourceRecord)
-                                additionalRRs2.nextElement();
+                        ResourceRecord tmpRec = additionalRRs2.nextElement();
 
                         //if (LogConst.DEBUG) {                            
                         //    ProviderMgr.logger.fine("Look for an answer in " +
@@ -1276,7 +1257,7 @@
         //   section
         // TODO current implementation isn't effective
         while (authorityRRs.hasMoreElements()) {
-            ResourceRecord curRec = (ResourceRecord) authorityRRs.nextElement();
+            ResourceRecord curRec = authorityRRs.nextElement();
             SList slist = SList.getInstance();
 
             // save record for future use
@@ -1300,8 +1281,7 @@
                     // try to search additional records to obtain server's IP
                     additionalRRs = answer.getAdditionalRRs();
                     while (additionalRRs.hasMoreElements()) {
-                        ResourceRecord addRec = (ResourceRecord)
-                                additionalRRs.nextElement();
+                        ResourceRecord addRec = additionalRRs.nextElement();
 
                         if (ProviderMgr.namesAreEqual(
                                 addRec.getName(), serverName) &&
@@ -1327,8 +1307,7 @@
         // analyze additional section
         additionalRRs = answer.getAdditionalRRs();
         while (additionalRRs.hasMoreElements()) {
-            ResourceRecord addRec = (ResourceRecord)
-                    additionalRRs.nextElement();
+            ResourceRecord addRec = additionalRRs.nextElement();
 
             report.extraRecords.addElement(addRec);
             //if (LogConst.DEBUG) {                            
@@ -1344,8 +1323,8 @@
         
         // checking report.records and report.extraRecords
         for (int k = 0; k < 2; k++) {
-            Vector records = null;
-            HashSet processed = new HashSet();
+            Vector<ResourceRecord> records = null;
+            HashSet<String> processed = new HashSet<String>();
 
             switch (k) {
                 case 0:
@@ -1356,11 +1335,11 @@
                     break;
             }
             for (int i = 0; i < records.size(); i++) {
-                ResourceRecord rr = (ResourceRecord) records.elementAt(i);
+                ResourceRecord rr = records.elementAt(i);
                 String key = rr.getName() + " " + rr.getRRClass() + " " +
                         rr.getRRType();
                 long ttl = rr.getTtl();
-                Vector objToUpdateTTL = new Vector();
+                Vector<ResourceRecord> objToUpdateTTL = new Vector<ResourceRecord>();
                 
                 if (processed.contains(key)) {
                     continue;
@@ -1368,7 +1347,7 @@
                 objToUpdateTTL.addElement(rr);
                 // look forward for records with the same NAME CLASS TYPE
                 for (int j = i; j < records.size(); j++) {
-                    ResourceRecord rr2 = (ResourceRecord) records.elementAt(j);
+                    ResourceRecord rr2 = records.elementAt(j);
                     String key2 = rr2.getName() + " " + rr2.getRRClass() + " " +
                             rr2.getRRType();
                     long ttl2 = rr2.getTtl();
@@ -1385,8 +1364,7 @@
                 }
                 // update TTL if necessary
                 for (int j = 0; j < objToUpdateTTL.size(); j++) {
-                    ResourceRecord rr2 = (ResourceRecord)
-                            objToUpdateTTL.elementAt(j);
+                    ResourceRecord rr2 = objToUpdateTTL.elementAt(j);
     
                     if (rr2.getTtl() != ttl) {
                         rr2.setTtl(ttl);
@@ -1432,16 +1410,13 @@
      */
     void startResolvingThread(String hostname, int dnsClass) {
         Thread newThread;
-        Resolver newResolver;
         Resolver.ThreadListEntry newEntry;
-        int types[] = {ProviderConstants.A_TYPE};
         int classes[] = new int[1];
         
         synchronized (threadListSemaphore) {
             // check that no currently running thread looks for this hostname 
             for (int i = 0; i < resolverThreads.size(); i++) {
-                Resolver.ThreadListEntry entry = (Resolver.ThreadListEntry)
-                        resolverThreads.elementAt(i);
+                Resolver.ThreadListEntry entry = resolverThreads.elementAt(i);
                 if (ProviderMgr.namesAreEqual(hostname,
                                               entry.serverNameToResolve) &&
                     entry.dnsClass == dnsClass)
@@ -1453,8 +1428,7 @@
             }
             // check if the hostname is already scheduled for resolving
             for (int i = 0; i < hostnamesToResolve.size(); i++) {
-                Resolver.ThreadListEntry entry = (Resolver.ThreadListEntry)
-                        hostnamesToResolve.elementAt(i);
+                Resolver.ThreadListEntry entry = hostnamesToResolve.elementAt(i);
                 if (ProviderMgr.namesAreEqual(hostname,
                                               entry.serverNameToResolve) &&
                     entry.dnsClass == dnsClass)
@@ -1490,15 +1464,14 @@
      */
     public void run() {
         SList slist = SList.getInstance();
-        Enumeration foundRecords;
+        Enumeration<ResourceRecord> foundRecords;
         Resolver.ThreadListEntry entryToProcess;
         int [] classes = new int[1];
 
         // update lists
         synchronized (threadListSemaphore) {
             if (hostnamesToResolve.size() > 0) {
-                entryToProcess = (Resolver.ThreadListEntry)
-                        hostnamesToResolve.elementAt(0);
+                entryToProcess = hostnamesToResolve.elementAt(0);
                 hostnamesToResolve.remove(0);
                 entryToProcess.thread = Thread.currentThread();
                 resolverThreads.addElement(entryToProcess);
@@ -1516,8 +1489,7 @@
                     classes);
             while (foundRecords != null && foundRecords.hasMoreElements()) {
                 // we will take all A records and store all of them in SLIST
-                ResourceRecord rr = (ResourceRecord)
-                        foundRecords.nextElement();
+                ResourceRecord rr = foundRecords.nextElement();
 
                 if (rr.getRRType() == ProviderConstants.A_TYPE) {
                     slist.setServerIP(entryToProcess.serverNameToResolve,
@@ -1531,8 +1503,7 @@
         // update resolver threads list, remove info about current thread
         synchronized (threadListSemaphore) {
             for (int i = 0; i < resolverThreads.size(); i++) {
-                Resolver.ThreadListEntry entry = (Resolver.ThreadListEntry)
-                        resolverThreads.elementAt(i);
+                Resolver.ThreadListEntry entry = resolverThreads.elementAt(i);
 
                 if (ProviderMgr.namesAreEqual(
                         entryToProcess.serverNameToResolve,
@@ -1560,15 +1531,15 @@
         boolean delegationArrived = false;
         boolean aliasInfoWasReceived = false;
         boolean messageWasTruncated = false;
-        Vector records;
-        Vector delegationZones;
+        Vector<ResourceRecord> records;
+        Vector<String> delegationZones;
         String newName = null;
-        Vector extraRecords;
+        Vector<ResourceRecord> extraRecords;
 
         AnalysisReport() {
-            records = new Vector();
-            delegationZones = new Vector();
-            extraRecords = new Vector();
+            records = new Vector<ResourceRecord>();
+            delegationZones = new Vector<String>();
+            extraRecords = new Vector<ResourceRecord>();
         }
 
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResolverCache.java Sun Sep 24 14:19:38 2006
@@ -36,14 +36,14 @@
 class ResolverCache {
 
     /** keys - zone & host names; values - vectors with RRs */
-    Hashtable names = new Hashtable();
+    Hashtable<String, Vector<CacheEntry>> names = new Hashtable<String, Vector<CacheEntry>>();
 
     /** 
      * Since <code>ResolverCache</code> is singleton class its constructor
      *  should be hidden.
      */
     private ResolverCache() {
-        names = new Hashtable();
+        names = new Hashtable<String, Vector<CacheEntry>>();
     }
 
     private static ResolverCache instance = null;
@@ -65,17 +65,17 @@
      *  to get from the cache
      * @return Enumeration of found Resource Records.
      */
-    synchronized Enumeration get(QuestionRecord question)
+    synchronized Enumeration<ResourceRecord> get(QuestionRecord question)
     {
         String name = question.getQName().toLowerCase();
-        Vector vect = (Vector) names.get(name);
+        Vector<CacheEntry> vect = names.get(name);
         int qClass = question.getQClass();
         int qType = question.getQType();
-        Vector resVect = new Vector();
+        Vector<ResourceRecord> resVect = new Vector<ResourceRecord>();
 
         if (vect != null) {
             for (int i = 0; i < vect.size(); i++) {
-                CacheEntry curEntry = (CacheEntry) vect.elementAt(i);
+                CacheEntry curEntry = vect.elementAt(i);
                 ResourceRecord curRR = curEntry.getRR();
 
                 if (curEntry.getBestBefore() < System.currentTimeMillis()) {
@@ -105,12 +105,12 @@
     synchronized void put(ResourceRecord record)
     {
         String name = record.getName().toLowerCase();
-        Vector vect = (Vector) names.get(name);
+        Vector<CacheEntry> vect = names.get(name);
         long curTime = System.currentTimeMillis();
         CacheEntry entry = null;
 
         if (vect == null) {
-            vect = new Vector();
+            vect = new Vector<CacheEntry>();
             names.put(name, vect);
         }
         // TTL should be between 0 and 2^31; if greater - should be set to 0
@@ -123,7 +123,7 @@
             entry = new CacheEntry(record, curTime + record.getTtl());
             // remove old occurence if any
             for (int i = 0; i < vect.size(); i++) {
-                CacheEntry exEntry = (CacheEntry) vect.elementAt(i);
+                CacheEntry exEntry = vect.elementAt(i);
                 ResourceRecord exRec = exEntry.rr;
 
                 if (ProviderMgr.namesAreEqual(record.getName(), exRec.getName())
@@ -145,7 +145,7 @@
      * Removes all cached entries.
      */
     synchronized void clear() {
-        names = new Hashtable();
+        names = new Hashtable<String, Vector<CacheEntry>>();
     }
 
     // additional class

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/ResourceRecord.java Sun Sep 24 14:19:38 2006
@@ -126,9 +126,8 @@
 
             // RDLENGTH
             idx = ProviderMgr.write16Int(ipBytes.length, buffer, idx);
-            // RDATA
-            for (int i = 0; i < ipBytes.length; i++) {
-                buffer[idx++] = ipBytes[i];
+            for (byte element : ipBytes) {
+                buffer[idx++] = element;
             }
         }
         else if (rrType == ProviderConstants.SOA_TYPE) {
@@ -144,10 +143,10 @@
             // RDATA
             // MNAME
             token = st.nextToken();
-            idx = ProviderMgr.writeName((String) token, buffer, idx);
+            idx = ProviderMgr.writeName(token, buffer, idx);
             // RNAME
             token = st.nextToken();
-            idx = ProviderMgr.writeName((String) token, buffer, idx);
+            idx = ProviderMgr.writeName(token, buffer, idx);
             // SERIAL
             // REFRESH
             // RETRY
@@ -278,9 +277,8 @@
             bytes = (byte[]) rData;
             // RDLENGTH
             idx = ProviderMgr.write16Int(bytes.length, buffer, idx);
-            // RDATA
-            for (int i = 0; i < bytes.length; i++) {
-                buffer[idx++] = bytes[i];
+            for (byte element : bytes) {
+                buffer[idx++] = element;
             }
         }
         return idx;
@@ -442,6 +440,7 @@
         return idx;
     }
 
+    @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
         sb.append(name);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/SList.java Sun Sep 24 14:19:38 2006
@@ -44,17 +44,17 @@
     public static int UNKNOWN = 0;
 
     // Hash with vectors; one vector of server entries per zone
-    private Hashtable zones;
+    private Hashtable<String, Vector<Entry>> zones;
     
     // the array with known DNS servers information
-    private Vector servers;
+    private Vector<Server> servers;
     
     /**
      * @see #getInstance()
      */
     private SList() {
-        zones = new Hashtable();
-        servers = new Vector();
+        zones = new Hashtable<String, Vector<Entry>>();
+        servers = new Vector<Server>();
     }
 
     private static SList instance = null;
@@ -83,15 +83,15 @@
     void updateEntry(String zone, Server server, int responseTime)
     {
         String normZoneName = ProviderMgr.normalizeName(zone); 
-        Vector vect;
+        Vector<Entry> vect;
         Entry entryToAdd =
                 new Entry(normZoneName, getServerNum(server), responseTime);
 
         synchronized (zones) {
             vect =
-                (Vector) zones.get(ProviderMgr.normalizeName(normZoneName));
+                zones.get(ProviderMgr.normalizeName(normZoneName));
             if (vect == null) {
-                vect = new Vector();
+                vect = new Vector<Entry>();
                 vect.addElement(entryToAdd);
                 zones.put(normZoneName, vect);
             }
@@ -100,7 +100,7 @@
     
                 // delete previous occurrence of given server
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry curEntry = (Entry) vect.elementAt(i);
+                    Entry curEntry = vect.elementAt(i);
     
                     if (server.equals(serverAtNum(curEntry.getServerNum()))) {
                         vect.removeElementAt(i);
@@ -110,7 +110,7 @@
     
                 // and insert a new one with updated response time
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry curEntry = (Entry) vect.elementAt(i);
+                    Entry curEntry = vect.elementAt(i);
     
                     if (responseTime < curEntry.getResponseTime()) {
                         vect.insertElementAt(entryToAdd, i);
@@ -133,14 +133,14 @@
      * @return best guess - a <code>SList.Server</code> object;
      *  <code>null</code> if the information is not found
      */
-    Server getBestGuess(String zone, Hashtable serversToIgnore) {
-        Vector vect;
+    Server getBestGuess(String zone, Hashtable<Server, ?> serversToIgnore) {
+        Vector<Entry> vect;
 
         synchronized (zones) {
-            vect = (Vector) zones.get(ProviderMgr.normalizeName(zone));
+            vect = zones.get(ProviderMgr.normalizeName(zone));
             if (vect != null && vect.size() > 0) {
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry entry = (Entry) vect.elementAt(i);
+                    Entry entry = vect.elementAt(i);
     
                     if (serversToIgnore != null) {
                         if (serversToIgnore.get(
@@ -162,13 +162,13 @@
      * @param server the server to remove
      */
     void dropServer(String zone, Server server) {
-        Vector vect;
+        Vector<Entry> vect;
 
         synchronized (zones) {
-            vect = (Vector) zones.get(ProviderMgr.normalizeName(zone));
+            vect = zones.get(ProviderMgr.normalizeName(zone));
             if (vect != null) {
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry entry = (Entry) vect.elementAt(i);
+                    Entry entry = vect.elementAt(i);
     
                     if (server.equals(serverAtNum(entry.getServerNum()))) {
                         vect.removeElementAt(i);
@@ -186,13 +186,13 @@
      * server & zone combination; <code>false</code> otherwise
      */
     boolean hasServer(String zone, Server server) {
-        Vector vect;
+        Vector<Entry> vect;
 
         synchronized (zones) {
-            vect = (Vector) zones.get(ProviderMgr.normalizeName(zone));
+            vect = zones.get(ProviderMgr.normalizeName(zone));
             if (vect != null) {
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry entry = (Entry) vect.elementAt(i);
+                    Entry entry = vect.elementAt(i);
     
                     if (server.equals(serverAtNum(entry.getServerNum()))) {
                         return true;
@@ -210,13 +210,13 @@
      * @return <code>Server</code> object with specified attributes
      */
     Server getServerByName(String zone, String name, int port) {
-        Vector vect;
+        Vector<Entry> vect;
 
         synchronized (zones) {
-            vect = (Vector) zones.get(ProviderMgr.normalizeName(zone));
+            vect = zones.get(ProviderMgr.normalizeName(zone));
             if (vect != null) {
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry entry = (Entry) vect.elementAt(i);
+                    Entry entry = vect.elementAt(i);
         
                     if (ProviderMgr.namesAreEqual(name,
                             serverAtNum(entry.getServerNum()).getName())
@@ -238,13 +238,13 @@
      * @return <code>Server</code> object with specified attributes
      */
     Server getServerByIP(String zone, String ip, int port) {
-        Vector vect;
+        Vector<Entry> vect;
 
         synchronized (zones) {
-            vect = (Vector) zones.get(ProviderMgr.normalizeName(zone));
+            vect = zones.get(ProviderMgr.normalizeName(zone));
             if (vect != null) {
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry entry = (Entry) vect.elementAt(i);
+                    Entry entry = vect.elementAt(i);
     
                     if (ip.equals(serverAtNum(entry.getServerNum()).getIP()) &&
                             port == serverAtNum(entry.getServerNum()).getPort())
@@ -266,16 +266,18 @@
      * @see SList.Server#equals(SList.Server)
      */
     Server getServerByServer(String zone, Server server) {
-        Vector vect;
+        Vector<Entry> vect;
         
         synchronized (zones) {
-            vect = (Vector) zones.get(ProviderMgr.normalizeName(zone));
+            vect = zones.get(ProviderMgr.normalizeName(zone));
     
             if (vect != null) {
                 for (int i = 0; i < vect.size(); i++) {
-                    Entry entry = (Entry) vect.elementAt(i);
+                    Entry entry = vect.elementAt(i);
     
-                    if (server.equals(serverAtNum(entry.getServerNum())));
+                    if (server.equals(serverAtNum(entry.getServerNum()))) {
+                        ;
+                    }
                     {
                         return serverAtNum(entry.getServerNum());
                     }
@@ -290,7 +292,7 @@
      */
     void clear() {
         synchronized (zones) {
-            zones = new Hashtable();
+            zones = new Hashtable<String, Vector<Entry>>();
         }
     }
 
@@ -307,11 +309,9 @@
         if (servers.contains(server)) {
             return servers.indexOf(server);
         }
-        else {
-            synchronized (servers) {
-                servers.addElement(server);
-                return servers.size() - 1;
-            }
+        synchronized (servers) {
+            servers.addElement(server);
+            return servers.size() - 1;
         }
     }
 
@@ -321,11 +321,9 @@
      */
     private Server serverAtNum(int num) {
         if (num < servers.size()) {
-            return (Server) servers.elementAt(num);
-        }
-        else {
-            return null;
+            return servers.elementAt(num);
         }
+        return null;
     }
 
     /**
@@ -344,14 +342,14 @@
      * @param name hostname
      * @return found server object or <code>null</code> if not found
      */
-    Enumeration getServersByName(String name) {
-        Vector result = new Vector();
+    Enumeration<Server> getServersByName(String name) {
+        Vector<Server> result = new Vector<Server>();
         
         if (name == null) {
             throw new NullPointerException("hostname is null");
         }
         for (int i = 0; i < servers.size(); i++) {
-            Server curServ = (Server) servers.get(i);
+            Server curServ = servers.get(i);
             
             if (curServ.getName() != null &&
                     ProviderMgr.namesAreEqual(name, curServ.getName()))
@@ -372,7 +370,7 @@
         String nameNorm = ProviderMgr.normalizeName(hostname);
         
         for (int i = 0; i < servers.size(); i++) {
-            SList.Server serv = (Server) servers.elementAt(i);
+            SList.Server serv = servers.elementAt(i);
 
             if (nameNorm.equals(serv.getName()) &&
                 serv.getIP() == null)
@@ -474,6 +472,7 @@
          * @param obj a <code>Server</code> object to compare with
          * @return <code>true</code> or <code>false</code>
          */
+        @Override
         public boolean equals(Object obj) {
             SList.Server srv = null;
 
@@ -488,10 +487,9 @@
                 return ProviderMgr.namesAreEqual(
                                 this.getName(), srv.getName()) &&
                        this.getPort() == srv.getPort();
-            } else {
-                return this.getIP().equals(srv.getIP()) &&
-                       this.getPort() == srv.getPort();
             }
+            return this.getIP().equals(srv.getIP()) &&
+                   this.getPort() == srv.getPort();
         }
         
         /**
@@ -531,13 +529,12 @@
             this.serverPort = serverPort;
         }
 
+        @Override
         public String toString() {
             if (this.serverName != null) {
                 return serverName + ":" + serverPort; 
             }
-            else {
-                return serverIP + ":" + serverPort;
-            }
+            return serverIP + ":" + serverPort;
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/TransportMgr.java Sun Sep 24 14:19:38 2006
@@ -27,7 +27,6 @@
 import java.io.InputStream;
 import java.net.DatagramPacket;
 import java.net.DatagramSocket;
-import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
@@ -85,7 +84,7 @@
         }
         try {
             dSocket = new DatagramSocket();
-            srvAddr = Inet4Address.getByAddress(srvAddrArr);
+            srvAddr = InetAddress.getByAddress(srvAddrArr);
             dSocket.connect(srvAddr, serverPort);
             outPacket = new DatagramPacket(
                     outBuf, outBufLen, srvAddr, serverPort);
@@ -108,9 +107,8 @@
         }
         if (inPacket != null) {
             return inPacket.getLength();
-        } else {
-            throw new DomainProtocolException("unknown error");
         }
+        throw new DomainProtocolException("unknown error");
     }
 
     /**
@@ -160,7 +158,7 @@
                     "Unable to connect: bad IP address");
         }
         try {
-            srvAddr = Inet4Address.getByAddress(srvAddrArr);
+            srvAddr = InetAddress.getByAddress(srvAddrArr);
             socket = new Socket(srvAddr, serverPort);
             socket.setSoTimeout(timeout);
             oStream = new BufferedOutputStream(socket.getOutputStream());
@@ -207,7 +205,7 @@
         InetAddress addr = null;
 
         try {
-            addr = Inet4Address.getByName(hostname);
+            addr = InetAddress.getByName(hostname);
         } catch (UnknownHostException e) {
             // ignore it
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContext.java Sun Sep 24 14:19:38 2006
@@ -24,7 +24,9 @@
 
 import java.util.Hashtable;
 
+import javax.naming.Binding;
 import javax.naming.Context;
+import javax.naming.NameClassPair;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
@@ -43,7 +45,7 @@
      * @param env environment
      * @throws NamingException if such exception was encountered
      */
-    public dnsURLContext(Hashtable env) throws NamingException {
+    public dnsURLContext(Hashtable<?, ?> env) throws NamingException {
         super(env);
     }
 
@@ -55,6 +57,7 @@
      * @throws NullPointerException if <code>name</code> is null
      * @see DNSContext#getAttributes(String, String[])
      */
+    @Override
     public Attributes getAttributes(String name, String[] attrNames)
             throws NamingException
     {
@@ -69,6 +72,7 @@
      * @throws NullPointerException if <code>name</code> is null
      * @see DNSContext#getAttributes(String) 
      */
+    @Override
     public Attributes getAttributes(String name) throws NamingException {
         return getAttributes(name, null);
     }
@@ -80,7 +84,8 @@
      * @throws NullPointerException if <code>name</code> is null
      * @see DNSContext#list(String)
      */
-    public NamingEnumeration list(String name) throws NamingException {
+    @Override
+    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
         process(name);
         return super.list(new DNSName());
     }
@@ -92,7 +97,8 @@
      * @throws NullPointerException if <code>name</code> is null
      * @see DNSContext#listBindings(String)
      */
-    public NamingEnumeration listBindings(String name) throws NamingException {
+    @Override
+    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
         process(name);
         return super.listBindings(new DNSName());
     }
@@ -104,6 +110,7 @@
      * @throws NullPointerException if <code>name</code> is null
      * @see DNSContext#lookup(String)
      */
+    @Override
     public Object lookup(String name) throws NamingException {
         process(name);
         return super.lookup(new DNSName());
@@ -116,6 +123,7 @@
      * @throws NullPointerException if <code>name</code> is null
      * @see DNSContext#lookupLink(String)
      */
+    @Override
     public Object lookupLink(String name) throws NamingException {
         return lookup(name);
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java?view=diff&rev=449489&r1=449488&r2=449489
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/dns/dnsURLContextFactory.java Sun Sep 24 14:19:38 2006
@@ -50,18 +50,19 @@
      * @throws NamingException if such exception was encountered 
      * @see ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)
      */
+    @SuppressWarnings("unchecked")
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-            Hashtable environment) throws NamingException
+            Hashtable<?, ?> environment) throws NamingException
     {
         if (obj == null) {
             return new dnsURLContext(environment);
         } else if (obj instanceof String) {
-            Hashtable newEnv = (Hashtable) environment.clone();
+            Hashtable<Object, Object> newEnv = (Hashtable<Object, Object>) environment.clone();
 
             newEnv.put(Context.PROVIDER_URL, obj);
             return new DNSContext(newEnv);
         } else if (obj instanceof String[]) {
-            Hashtable newEnv = (Hashtable) environment.clone();
+            Hashtable<Object, Object> newEnv = (Hashtable<Object, Object>) environment.clone();
             StringBuffer sb = new StringBuffer();
             String urlArr[] = (String[]) obj;
 



Mime
View raw message