harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r448441 - /incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/
Date Thu, 21 Sep 2006 03:06:43 GMT
Author: ndbeyer
Date: Wed Sep 20 20:06:42 2006
New Revision: 448441

URL: http://svn.apache.org/viewvc?view=rev&rev=448441
Log:
Code cleanup; remove compiler warnings, simplify code paths, remove unnecessary bits

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/BinaryRefAddr.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Binding.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompositeName.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/StringRefAddr.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/BinaryRefAddr.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/BinaryRefAddr.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/BinaryRefAddr.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/BinaryRefAddr.java Wed Sep 20 20:06:42 2006
@@ -13,36 +13,17 @@
  * limitations under the License.
  */
 
-
 package javax.naming;
 
 import java.util.Arrays;
 
 /**
  * A <code>BinaryRefAddr</code> refers to an address which is represented by a
- * binary address. 
- *
- * 
+ * binary address.
  */
 public class BinaryRefAddr extends RefAddr {
 
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
-    /*
-     * This constant is used during deserialization to check the J2SE version
-     * which created the serialized object.
-     */
-    static final long serialVersionUID = -3415254970957330361L; //J2SE 1.4.2
-
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
+    private static final long serialVersionUID = -3415254970957330361L;
 
     /**
      * The buffer for the binary address itself.
@@ -51,41 +32,33 @@
      */
     private byte[] buf;
 
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
     /**
-     * Constructs a <code>BinaryRefAddr</code> using the specified address type
-     * and the full details of the supplied byte array.
+     * Constructs a <code>BinaryRefAddr</code> using the specified address
+     * type and the full details of the supplied byte array.
      * 
-     * @param type     the address type which cannot be null
-     * @param address  the address itself which cannot be null
+     * @param type the address type which cannot be null
+     * @param address the address itself which cannot be null
      */
     public BinaryRefAddr(String type, byte[] address) {
         this(type, address, 0, address.length);
     }
 
     /**
-     * Constructs a <code>BinaryRefAddr</code> using the specified address type
-     * and part of the supplied byte array.
-     * The number of bytes to be taken is specified by <code>size</code>. 
-     * Additionally these bytes are taken from a starting point specified by 
-     * <code>index</code>.  
-     *
-     * @param type      the address type. It cannot be null.
-     * @param address   the address itself. It cannot be null.
-     * @param index     the starting point to copy bytes from. It must be 
-     *                  greater than or equal to zero and must be less than or 
-     *                  equal to the size of the byte array.
-     * @param size      the number of bytes to copy. It must be greater than or 
-     *                  equal to zero and must be less than or equal to the 
-     *                  size of the byte array less the starting position.
-     * @throws ArrayIndexOutOfBoundsException
-     *                  If <code>size</code> or <code>index</code> does not meet
-     *                  the constraints.
+     * Constructs a <code>BinaryRefAddr</code> using the specified address
+     * type and part of the supplied byte array. The number of bytes to be taken
+     * is specified by <code>size</code>. Additionally these bytes are taken
+     * from a starting point specified by <code>index</code>.
+     * 
+     * @param type the address type. It cannot be null.
+     * @param address the address itself. It cannot be null.
+     * @param index the starting point to copy bytes from. It must be greater
+     *        than or equal to zero and must be less than or equal to the size
+     *        of the byte array.
+     * @param size the number of bytes to copy. It must be greater than or equal
+     *        to zero and must be less than or equal to the size of the byte
+     *        array less the starting position.
+     * @throws ArrayIndexOutOfBoundsException If <code>size</code> or
+     *         <code>index</code> does not meet the constraints.
      */
     public BinaryRefAddr(String type, byte[] address, int index, int size) {
         super(type);
@@ -93,75 +66,62 @@
         System.arraycopy(address, index, this.buf, 0, size);
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods override parent class RefAddr
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Gets the content of this address.
      * 
-     * @return          an array of bytes containing the address. 
-     *                  It cannot be null.
+     * @return an array of bytes containing the address. It cannot be null.
      */
+    @Override
     public Object getContent() {
         return buf;
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods override parent class Object
-     * -------------------------------------------------------------------
-     */
-
     /**
-     * Returns true if this address is equal to the supplied object 
-     * <code>o</code>.
-     * They are considered equal if the address types are equal and the data in
-     * the buffers is of the same length and contains the same bytes.
-     *
-     * @param o         the object to compare with
-     * @return          true if this address is equal to <code>o</code>,
-     *                  otherwise false
+     * Returns true if this address is equal to the supplied object
+     * <code>o</code>. They are considered equal if the address types are
+     * equal and the data in the buffers is of the same length and contains the
+     * same bytes.
+     * 
+     * @param o the object to compare with
+     * @return true if this address is equal to <code>o</code>, otherwise
+     *         false
      */
+    @Override
     public boolean equals(Object o) {
         if (o instanceof BinaryRefAddr) {
             BinaryRefAddr a = (BinaryRefAddr) o;
-            return this.addrType.equals(a.addrType)
-                && Arrays.equals(this.buf, a.buf);
+            return this.addrType.equals(a.addrType) && Arrays.equals(this.buf, a.buf);
         }
         return false;
     }
 
     /**
-     * Returns the hashcode of this address.
-     * The result is the hashcode of the address type added to each byte 
-     * from the data buffer.
+     * Returns the hashcode of this address. The result is the hashcode of the
+     * address type added to each byte from the data buffer.
      * 
-     * @return          the hashcode of this address
+     * @return the hashcode of this address
      */
+    @Override
     public int hashCode() {
         int i = this.addrType.hashCode();
 
-        for (int j = 0; j < this.buf.length; j++) {
-            i += this.buf[j];
+        for (byte element : this.buf) {
+            i += element;
         }
         return i;
     }
 
     /**
-     * Returns the string representation of this address. 
-     * The string includes the address type and a maximum of 128 bytes address
-     * content expressed in hexical form. 
+     * Returns the string representation of this address. The string includes
+     * the address type and a maximum of 128 bytes address content expressed in
+     * hexadecimal form.
      * 
-     * @return          the string representation of this address
+     * @return the string representation of this address
      */
+    @Override
     public String toString() {
-        String s =
-            "The type of the address is: " //$NON-NLS-1$
-                + this.addrType
-                + "\nThe content of the address is: "; //$NON-NLS-1$
+        String s = "The type of the address is: " //$NON-NLS-1$
+                + this.addrType + "\nThe content of the address is: "; //$NON-NLS-1$
         int max = this.buf.length > 128 ? 128 : this.buf.length;
 
         for (int i = 0; i < max; i++) {
@@ -171,7 +131,4 @@
 
         return s;
     }
-
 }
-
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Binding.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Binding.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Binding.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Binding.java Wed Sep 20 20:06:42 2006
@@ -122,6 +122,7 @@
      *
      * @return the class name
      */
+    @Override
     public String getClassName() {
         if (super.getClassName() != null) {
             return super.getClassName();
@@ -166,6 +167,7 @@
      * 
      * @return a string representation of this <code>Binding</code>
      */
+    @Override
     public String toString() {
         return super.toString() + ":" + boundObj; //$NON-NLS-1$
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompositeName.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompositeName.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompositeName.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompositeName.java Wed Sep 20 20:06:42 2006
@@ -13,7 +13,6 @@
  * limitations under the License.
  */
 
-
 package javax.naming;
 
 import java.io.IOException;
@@ -21,7 +20,6 @@
 import java.io.ObjectOutputStream;
 import java.io.OptionalDataException;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
@@ -123,42 +121,27 @@
  */
 public class CompositeName implements Name {
 
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
-    // J2SE 1.4.2
     private static final long serialVersionUID = 1667768148915813118L;
-    
+
     // status used by parse()
     private static final int OUT_OF_QUOTE = 0;
+
     private static final int IN_SINGLE_QUOTE = 1;
+
     private static final int IN_DOUBLE_QUOTE = 2;
-    private static final int QUOTE_ENDED = 3;
 
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
+    private static final int QUOTE_ENDED = 3;
 
     /* a list holding elements */
     private transient Vector<String> elems;
 
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Private copy constructor.
      *
      * @param elements  a list of name elements
      */
     private CompositeName(List<String> elements) {
+        super();
         elems = new Vector<String>(elements);
     }
 
@@ -168,16 +151,18 @@
      * @param elements  an enumeration of name elements
      */
     protected CompositeName(Enumeration<String> elements) {
+        super();
         elems = new Vector<String>();
         while (elements.hasMoreElements()) {
             elems.add(elements.nextElement());
         }
     }
-    
+
     /**
      * Default constructor, creates an empty name with zero elements.
      */
     public CompositeName() {
+        super();
         elems = new Vector<String>();
     }
 
@@ -189,16 +174,11 @@
      * @throws InvalidNameException if the supplied name is invalid
      */
     public CompositeName(String name) throws InvalidNameException {
+        super();
         elems = parseName(name);
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
-    /*
+    /**
      * Parse string name elements. Delimiter is "/".
      * Escape is "\" and both single quote and double quote are supported.
      */
@@ -215,9 +195,7 @@
         }
 
         // general simple case, without escape and quote
-        if (name.indexOf('"') < 0
-            && name.indexOf('\'') < 0
-            && name.indexOf('\\') < 0) {
+        if (name.indexOf('"') < 0 && name.indexOf('\'') < 0 && name.indexOf('\\') < 0) {
             int i = 0, j = 0;
             while ((j = name.indexOf('/', i)) >= 0) {
                 l.add(name.substring(i, j));
@@ -230,7 +208,7 @@
         // general complicated case, consider escape and quote
         char c;
         char chars[] = name.toCharArray();
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         int status = OUT_OF_QUOTE;
         for (int i = 0; i < chars.length; i++) {
             c = chars[i];
@@ -243,7 +221,7 @@
                     status = OUT_OF_QUOTE;
                     continue;
                 }
-				throw new InvalidNameException("End quote is not at the end of element"); //$NON-NLS-1$
+                throw new InvalidNameException("End quote is not at the end of element"); //$NON-NLS-1$
             }
 
             if (c == '\\') {
@@ -304,11 +282,11 @@
     /*
      * Format name elements to its string representation.
      */
-    private static String formatName(Vector elems) {
+    private static String formatName(Vector<String> elems) {
 
         // special case: all empty elements
         if (isAllEmptyElements(elems)) {
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             for (int i = 0; i < elems.size(); i++) {
                 buf.append("/"); //$NON-NLS-1$
             }
@@ -316,21 +294,18 @@
         }
 
         // general case
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for (int i = 0; i < elems.size(); i++) {
-            String elem = (String) elems.get(i);
+            String elem = elems.get(i);
             if (i > 0) {
                 buf.append("/"); //$NON-NLS-1$
             }
-            if (elem.indexOf('/') < 0
-                && elem.indexOf('\\') < 0
-                && elem.indexOf('\'') < 0
-                && elem.indexOf('"') < 0) {
+            if (elem.indexOf('/') < 0 && elem.indexOf('\\') < 0 && elem.indexOf('\'') < 0
+                    && elem.indexOf('"') < 0) {
                 buf.append(elem);
             } else {
                 char chars[] = elem.toCharArray();
-                for (int j = 0; j < chars.length; j++) {
-                    char c = chars[j];
+                for (char c : chars) {
                     if (c == '/' || c == '\\' || c == '\'' || c == '"') {
                         buf.append('\\');
                     }
@@ -341,9 +316,9 @@
         return buf.toString();
     }
 
-    private static boolean isAllEmptyElements(Vector elems) {
+    private static boolean isAllEmptyElements(Vector<String> elems) {
         for (int i = 0; i < elems.size(); i++) {
-            String elem = (String) elems.get(i);
+            String elem = elems.get(i);
             if (elem.length() > 0) {
                 return false;
             }
@@ -351,18 +326,12 @@
         return true;
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods of interface Name
-     * -------------------------------------------------------------------
-     */
-
     public Enumeration<String> getAll() {
         return elems.elements();
     }
 
     public String get(int index) {
-        return (String) elems.get(index);
+        return elems.get(index);
     }
 
     public Name getPrefix(int index) {
@@ -451,8 +420,8 @@
         }
 
         // compare 1 by 1
-        Enumeration enumeration = name.getAll();
-        Object me, he;
+        Enumeration<String> enumeration = name.getAll();
+        String me, he;
         for (int i = 0; enumeration.hasMoreElements(); i++) {
             me = elems.get(i);
             he = enumeration.nextElement();
@@ -474,8 +443,8 @@
         }
 
         // compare 1 by 1
-        Enumeration enumeration = name.getAll();
-        Object me, he;
+        Enumeration<String> enumeration = name.getAll();
+        String me, he;
         for (int i = elems.size() - name.size(); enumeration.hasMoreElements(); i++) {
             me = elems.get(i);
             he = enumeration.nextElement();
@@ -506,7 +475,7 @@
             CompositeName he = (CompositeName) o;
             int r;
             for (int i = 0; i < elems.size() && i < he.elems.size(); i++) {
-                r = ((String) elems.get(i)).compareTo((String)he.elems.get(i));
+                r = (elems.get(i)).compareTo(he.elems.get(i));
                 if (r != 0) {
                     return r;
                 }
@@ -522,33 +491,14 @@
         throw new ClassCastException();
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods override parent class Object
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Create a copy of this composite name, a complete (deep) copy of the object.
      *
      * @return a complete (deep) copy of the object.
      */
+    @Override
     public Object clone() {
-        // Object.clone()
-        CompositeName copy = null;
-        try {
-            copy = (CompositeName) super.clone();
-        } catch (CloneNotSupportedException e) {
-            // should never happen
-            throw new InternalError(
-                "Failed to clone object of " //$NON-NLS-1$
-                    + this.getClass().getName()
-                    + " class."); //$NON-NLS-1$
-        }
-
-        // replicate fields
-        copy.elems = new Vector<String>(elems);
-        return copy;
+        return new CompositeName(elems);
     }
 
     /**
@@ -561,49 +511,40 @@
      *
      * @return the string representation of this composite name.
      */
+    @Override
     public String toString() {
         return formatName(elems);
     }
 
     /**
-     * Check if this <code>Name</code> is equal to the supplied object.
+     * Check if this <code>CompositeName</code> is equal to the supplied object.
      *
      * @param o the <code>CompositeName</code> to compare - can be null but 
      *          then returns false.
      * @return  true if they have the same number of elements all of
      *          which are equal. false if they are not equal.
      */
+    @Override
     public boolean equals(Object o) {
-        // check type
-        if (!(o instanceof CompositeName)) {
-            return false;
+        if (this == o) {
+            return true;
         }
 
-        // check size
-        Name name = (Name) o;
-        if (elems.size() != name.size()) {
+        // check type
+        if (!(o instanceof CompositeName)) {
             return false;
         }
 
-        // compare 1 by 1
-        Enumeration enumeration = name.getAll();
-        Object me, he;
-        for (int i = 0; enumeration.hasMoreElements(); i++) {
-            me = elems.get(i);
-            he = enumeration.nextElement();
-            if (!(null == me ? null == he : me.equals(he))) {
-                return false;
-            }
-        }
-        return true;
+        return this.elems.equals(((CompositeName) o).elems);
     }
 
     /**
-     * Calculate the hashcode of this <code>CompositeName</code> by summing 
-     * the hashcodes of all of its elements.
-     *
+     * Calculate the hashcode of this <code>CompositeName</code> by summing
+     * the hash codes of all of its elements.
+     * 
      * @return the hashcode of this object.
      */
+    @Override
     public int hashCode() {
         int sum = 0;
         for (int i = 0; i < elems.size(); i++) {
@@ -612,41 +553,38 @@
         return sum;
     }
 
-    /*
+    /**
      * Writes a serialized representation of the CompositeName. It starts with
      * an int which is the number of elements in the name, and is followed by a
      * String for each element.
      * 
      * @param oos
-     * @throws java.io.IOException if an error is encountered writing to the stream.
+     * @throws IOException if an error is encountered writing to the stream.
      */
     private void writeObject(ObjectOutputStream oos) throws IOException {
         oos.defaultWriteObject();
 
         oos.writeInt(elems.size());
-        for (Iterator iter = elems.iterator(); iter.hasNext();) {
-            oos.writeObject(iter.next());
+        for (Object element : elems) {
+            oos.writeObject(element);
         }
     }
 
-    /*
+    /**
      * Recreate a CompositeName from the data in the supplied stream.
      * 
      * @param ois
-     * @throws java.io.IOException if an error is encountered reading from the stream.
+     * @throws IOException if an error is encountered reading from the stream.
      * @throws ClassNotFoundException.
      */
-    private void readObject(ObjectInputStream ois)
-        throws OptionalDataException, ClassNotFoundException, IOException {
+    private void readObject(ObjectInputStream ois) throws OptionalDataException,
+            ClassNotFoundException, IOException {
         ois.defaultReadObject();
 
         int size = ois.readInt();
         elems = new Vector<String>();
         for (int i = 0; i < size; i++) {
-            elems.add((String)ois.readObject());
+            elems.add((String) ois.readObject());
         }
     }
-
 }
-
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java Wed Sep 20 20:06:42 2006
@@ -13,13 +13,11 @@
  * limitations under the License.
  */
 
-
 package javax.naming;
 
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Properties;
 import java.util.Vector;
@@ -211,21 +209,11 @@
 public class CompoundName implements Name {
 
     /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
-    /*
-     *=============
-     *Serialization
-     *=============
-     *
      *Note: For serialization purposes, the specified serialVersionUID must be used.
      *This class does not have serializable fields specified. Instead the readObject
-     *and writeObject methods are overidden.
+     *and writeObject methods are overridden.
      */
-    static final long serialVersionUID = 3513100557083972036L; // J2SE 1.4.2
+    private static final long serialVersionUID = 3513100557083972036L; // J2SE 1.4.2
 
     //const for property key
     private static final String SEPARATOR = "jndi.syntax.separator"; //$NON-NLS-1$
@@ -273,11 +261,6 @@
 
     private static final int QUOTEEND_STATUS = 4;
 
-    /*
-     * ============
-     * Variables
-     * ============ 
-     */
     //properties variables
     private transient String separatorString;
 
@@ -313,17 +296,11 @@
     
     /*
      * The specification calls for a protected variable called 'impl' which is of a non-API
-     * type.  I believe this is an error in the spec, but to be compliant we have implemented
+     * type.  I believe this is an error in the spec, but to be complaint we have implemented
      * this as a useless class (below).
      */
     protected transient javax.naming.NameImpl impl = new NameImpl();
 
-    /*
-     *============
-     *Constructors
-     *============ 
-     */
-
     /**
      * Constructs a <code>CompoundName</code> with supplied <code>Enumeration</code> 
      * and <code>Properties</code>
@@ -364,7 +341,7 @@
         parseName(s);
     }
 
-    /*
+    /**
      * init instance variables
      */
     private void init(Properties props) {
@@ -439,7 +416,7 @@
 
         //init variables
         int status = INIT_STATUS;
-        StringBuffer element = new StringBuffer();
+        StringBuilder element = new StringBuilder();
         int pos = 0;
         int length = s.length();
         boolean hasNotNullElement = false;
@@ -485,13 +462,11 @@
                 pos += escapeString.length();
                 if (pos == s.length()) {
                     //if this escape char is last character, throw exception
-                    throw new InvalidNameException(new StringBuffer(50).append(
-                            "The ") //$NON-NLS-1$
-                            .append(escapeString).append(
-                                    " cannot be at end of the component") //$NON-NLS-1$
-                            .toString());
+                    throw new InvalidNameException("The " + escapeString //$NON-NLS-1$
+                            + " cannot be at end of the component"); //$NON-NLS-1$
                 }
-                //if one escape char followed by a special char, append the special char to current element
+                // if one escape char followed by a special char, append the
+                // special char to current element
                 String str = extractEscapedString(s, pos, status);
                 if (null == str) {
                     pos -= escapeString.length();
@@ -533,9 +508,9 @@
     }
 
     /*
-     * add des parameter to stringbuffer if include is true
+     * add des parameter to StringBuilder if include is true
      */
-    private int addBuffer(StringBuffer buffer, String des, boolean include) {
+    private int addBuffer(StringBuilder buffer, String des, boolean include) {
         if (include) {
             buffer.append(des);
         }
@@ -546,7 +521,7 @@
      * add current content of supplied string buffer as one element of this 
      * CompoundName and reset the string buffer to empty
      */
-    private void addElement(StringBuffer element) {
+    private void addElement(StringBuilder element) {
         if (LEFT_TO_RIGHT == direction) {
             elem.add(element.toString());
         } else {
@@ -618,7 +593,7 @@
 
     public String get(int index) {
         validateIndex(index, false);
-        return (String) elem.elementAt(index);
+        return elem.elementAt(index);
     }
 
     /*
@@ -707,6 +682,7 @@
         return elem.remove(index);
     }
 
+    @Override
     public Object clone() {
         return new CompoundName(getAll(), mySyntax);
     }
@@ -734,7 +710,7 @@
                 .size());
     }
 
-    /*
+    /**
      * preprocess string according to trimblank and ignorecase properties
      */
     private String preProcess(String string, boolean caseInsensitive,
@@ -747,7 +723,7 @@
         return result;
     }
 
-    /*
+    /**
      * Writes a serialized representation of the CompoundName. It starts with
      * the properties, followed by an int which is the number of elements 
      * in the name, and is followed by a String for each element. 
@@ -758,12 +734,12 @@
         oos.writeObject(mySyntax);
         oos.writeInt(elem.size());
         for (int i = 0; i < elem.size(); i++) {
-            String element = (String) elem.elementAt(i);
+            String element = elem.elementAt(i);
             oos.writeObject(element);
         }
     }
 
-    /*
+    /**
      * Recreate a CompoundName from the data in the supplied stream.
      * Additionally there are 2 protected fields which are not serializable.
      * One of them is of a type which is a private class and cannot therefore
@@ -812,17 +788,15 @@
         }
         int result = -1;
         CompoundName otherName = (CompoundName) o;
-        Enumeration otherEnum = otherName.getAll();
+        Enumeration<String> otherEnum = otherName.getAll();
         String thisElement;
         String otherElement;
         int i;
         for (i = 0; i < size() && otherEnum.hasMoreElements(); i++) {
-            thisElement = preProcess((String) elem.get(i), ignoreCase,
-                    trimBlanks);
-            otherElement = preProcess((String) otherEnum.nextElement(),
-                    ignoreCase, trimBlanks);
-            result = (null == thisElement ? (null == otherElement ? 0 : -1)
-                    : thisElement.compareTo(otherElement));
+            thisElement = preProcess(elem.get(i), ignoreCase, trimBlanks);
+            otherElement = preProcess(otherEnum.nextElement(), ignoreCase, trimBlanks);
+            result = (null == thisElement ? (null == otherElement ? 0 : -1) : thisElement
+                    .compareTo(otherElement));
             if (0 != result) {
                 return result;
             }
@@ -835,12 +809,6 @@
         return result;
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods override parent class Object
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Calculate the hashcode of this <code>CompoundName</code> by summing 
      * the hashcodes of all of its elements. 
@@ -853,12 +821,12 @@
      * 
      * @return 				the hashcode of this object.
      */
+    @Override
     public int hashCode() {
         int result = 0;
-        Enumeration enumeration = elem.elements();
+        Enumeration<String> enumeration = elem.elements();
         while (enumeration.hasMoreElements()) {
-            result += preProcess((String) enumeration.nextElement(),
-                    ignoreCase, trimBlanks).hashCode();
+            result += preProcess(enumeration.nextElement(), ignoreCase, trimBlanks).hashCode();
         }
         return result;
     }
@@ -866,16 +834,18 @@
     /**
      * Gets the string representation of this <code>CompoundName</code>.
      * <p>
-     * This is generated by concatenating the elements together with the 
-     * separator string added as the separator between each of them. It may be 
-     * necessary to add quotes and escape string to preserve the meaning. 
-     * The resulting string should produce an equivalent <code>CompoundName</code> 
-     * when used to create a new instance.</p>
+     * This is generated by concatenating the elements together with the
+     * separator string added as the separator between each of them. It may be
+     * necessary to add quotes and escape string to preserve the meaning. The
+     * resulting string should produce an equivalent <code>CompoundName</code>
+     * when used to create a new instance.
+     * </p>
      * 
-     * @return the string representation of this <code>CompoundName</code>. 
+     * @return the string representation of this <code>CompoundName</code>.
      */
+    @Override
     public String toString() {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         String begin = NULL_STRING.equals(beginQuoteString) ? beginQuoteString2
                 : beginQuoteString;
         String end = NULL_STRING.equals(endQuoteString) ? endQuoteString2
@@ -898,7 +868,7 @@
         return sb.toString();
     }
 
-    private void addElement(StringBuffer sb, int index, String separator, String begin, String end) {
+    private void addElement(StringBuilder sb, int index, String separator, String begin, String end) {
         String elemString = elem.get(index);
         if (0 == elemString.length()) {
             // if empty element, append a separator and continue
@@ -979,6 +949,7 @@
      * @return true if supplied object <code>o</code> is equals to this
      *         <code>CompoundName</code>, false otherwise
      */
+    @Override
     public boolean equals(Object o) {
         if (!(o instanceof CompoundName)) {
             return false;
@@ -995,7 +966,7 @@
         return equals(otherName, 0, size);
     }
 
-    /*
+    /**
      * compare this name to the supplied <code>name</code> from position 
      * <code>start</code> to position <code>start</code>+
      * <code>length</code>-1 
@@ -1006,13 +977,13 @@
             return false;
         }
         CompoundName otherName = (CompoundName) name;
-        Enumeration otherEnum = otherName.getAll();
+        Enumeration<String> otherEnum = otherName.getAll();
         String thisElement;
         String otherElement;
         for (int i = 0; i < length; i++) {
-            thisElement = preProcess((String) elem.get(i + start), ignoreCase,
+            thisElement = preProcess(elem.get(i + start), ignoreCase,
                     trimBlanks);
-            otherElement = preProcess((String) otherEnum.nextElement(),
+            otherElement = preProcess(otherEnum.nextElement(),
                     ignoreCase, trimBlanks);
             if (!(null == thisElement ? null == otherElement : thisElement
                     .equals(otherElement))) {
@@ -1023,8 +994,8 @@
     }
 }
 
-/*
- * A useless class requied to satisfy the requirement for an 'impl'
+/**
+ * A useless class required to satisfy the requirement for an 'impl'
  * field (see above).
  */
 class NameImpl {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/InitialContext.java Wed Sep 20 20:06:42 2006
@@ -13,7 +13,6 @@
  * limitations under the License.
  */
 
-
 package javax.naming;
 
 import java.util.Hashtable;
@@ -93,12 +92,6 @@
  */
 public class InitialContext implements Context {
 
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Set to the result of the first successful invocation of <code>
      * NamingManager.getInitialContext</code> by <code>getDefaultInitCtx
@@ -173,19 +166,14 @@
         }
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
-    /*
-     * Does private initilaziation.
+    /**
+     * Does private initialization.
      * 
      * @param env               the JNDI environment properties used to create
      *                          the context 
      * @throws NamingException  If failed to create an InitialContext.
      */
+    @SuppressWarnings("unchecked")
     private void internalInit(Hashtable<?, ?> env) throws NamingException {
 
         // 1. Read the environment parameter used to create this Context
@@ -342,12 +330,6 @@
         return null == ctx ? getDefaultInitCtx() : ctx;
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods of Interface Context
-     * -------------------------------------------------------------------
-     */
-
     public Object lookup(Name name) throws NamingException {
         return getURLOrDefaultInitCtx(name).lookup(name);
     }
@@ -489,7 +471,4 @@
     public String getNameInNamespace() throws NamingException {
         return getDefaultInitCtx().getNameInNamespace();
     }
-
 }
-
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/LinkException.java Wed Sep 20 20:06:42 2006
@@ -90,6 +90,7 @@
      * @return the string representation of this <code>NamingException</code> 
      * together with the details of the remaining name.
      */
+    @Override
     public String toString() {
         return toStringImpl(false);
     }
@@ -118,6 +119,7 @@
      * @return  the string representation of this <code>NamingException</code> 
      * together with the details of the remaining name.
      */
+    @Override
     public String toString(boolean b) {
         return toStringImpl(b);
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java Wed Sep 20 20:06:42 2006
@@ -217,6 +217,7 @@
      * 
      * @return a string representation of this object
      */
+    @Override
     public String toString() {
         StringBuffer buf = new StringBuffer();
         if (!isRel) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NamingException.java Wed Sep 20 20:06:42 2006
@@ -278,6 +278,7 @@
      * <p>
      * The output from this goes to <code>System.err</code>.</p>
      */
+    @Override
     public void printStackTrace() {
         if (null != rootException) {
             System.err.print(super.toString());
@@ -295,6 +296,7 @@
      * @param p the <code>PrintStream</code> to which the stack trace is 
      * printed.
      */
+    @Override
     public void printStackTrace(PrintStream p) {
         if (null != rootException) {
             p.print(super.toString());
@@ -312,6 +314,7 @@
      * @param p the <code>PrintWrite</code> to which the stack trace is 
      * printed.
      */
+    @Override
     public void printStackTrace(PrintWriter p) {
         if (null != rootException) {
             p.print(super.toString());
@@ -326,7 +329,8 @@
      *  (non-Javadoc)
      * @see java.lang.Throwable#getCause()
      */
-	public Throwable getCause() {
+	@Override
+    public Throwable getCause() {
 		return super.getCause();
 	}
 
@@ -334,7 +338,8 @@
      *  (non-Javadoc)
      * @see java.lang.Throwable#initCause(Throwable)
      */
-	public Throwable initCause(Throwable cause) {
+	@Override
+    public Throwable initCause(Throwable cause) {
 		return super.initCause(cause);
 	}
 
@@ -354,6 +359,7 @@
      * 
      * @return the string
      */
+    @Override
     public String toString() {
         return this.toStringImpl(false);
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/RefAddr.java Wed Sep 20 20:06:42 2006
@@ -111,6 +111,7 @@
      * @return      true if this address is equal to <code>o</code>,
      *              otherwise false
      */
+    @Override
     public boolean equals(Object o) {
         if (o instanceof RefAddr) {
             RefAddr a = (RefAddr) o;
@@ -128,6 +129,7 @@
      * 
      * @return      the hashcode of this address
      */
+    @Override
     public int hashCode() {
         return this.addrType.hashCode()
             + (null == this.getContent() ? 0 : this.getContent().hashCode());
@@ -140,6 +142,7 @@
      *  
      * @return      the string representation of this address
      */
+    @Override
     public String toString() {
         return "The type of the address is: " //$NON-NLS-1$
             + this.addrType

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/Reference.java Wed Sep 20 20:06:42 2006
@@ -13,7 +13,6 @@
  * limitations under the License.
  */
 
-
 package javax.naming;
 
 import java.io.Serializable;
@@ -35,23 +34,7 @@
  */
 public class Reference implements Cloneable, Serializable {
 
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
-    /*
-     * This constant is used during deserialization to check the J2SE version which
-     * created the serialized object.
-     */
-    static final long serialVersionUID = -1673475790065791735L; //J2SE 1.4.2
-
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
+    private static final long serialVersionUID = -1673475790065791735L; //J2SE 1.4.2
 
     /**
      * The class of the object which is referenced.
@@ -87,12 +70,6 @@
      */
     protected String classFactoryLocation;
 
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Constructs a <code>Reference</code> instance with an empty list of 
      * addresses using the supplied class name.  
@@ -128,10 +105,8 @@
      * @param classFactoryLocation
      *                      the location of the class file. It may be null.
      */
-    public Reference(
-        String className,
-        String classFactory,
-        String classFactoryLocation) {
+    public Reference(String className, String classFactory, String classFactoryLocation) {
+        super();
         this.className = className;
         this.classFactory = classFactory;
         this.classFactoryLocation = classFactoryLocation;
@@ -142,35 +117,25 @@
      * Constructs a <code>Reference</code> instance with one entry of address
      * using the supplied class name, factory class and factory location.
      * 
-     * @param className     the class of the object which is referenced. It 
-     *                      cannot be null. 
-     * @param addr          the object's address. It cannot be null.
-     * @param classFactory  the class in a factory which is used to create 
-     *                      an object of the type which is referenced. It may
-     *                      be null.
-     * @param classFactoryLocation
-     *                      the location of the class file. It may be null.
+     * @param className the class of the object which is referenced. It cannot
+     *        be null.
+     * @param addr the object's address. It cannot be null.
+     * @param classFactory the class in a factory which is used to create an
+     *        object of the type which is referenced. It may be null.
+     * @param classFactoryLocation the location of the class file. It may be
+     *        null.
      */
-    public Reference(
-        String className,
-        RefAddr addr,
-        String classFactory,
-        String classFactoryLocation) {
+    public Reference(String className, RefAddr addr, String classFactory,
+            String classFactoryLocation) {
         this(className, classFactory, classFactoryLocation);
         this.addrs.add(addr);
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
     /**
-     * Gets the class of the object which is referenced.
-     * The result cannot be null.
+     * Gets the class of the object which is referenced. The result cannot be
+     * null.
      * 
-     * @return              the class of the object which is referenced
+     * @return the class of the object which is referenced
      */
     public String getClassName() {
         return this.className;
@@ -216,11 +181,11 @@
      * @return              the first address whose type matches the string
      */
     public RefAddr get(String type) {
-        Enumeration elements = addrs.elements();
+        Enumeration<RefAddr> elements = addrs.elements();
         RefAddr refAddr = null;
 
         while (elements.hasMoreElements()) {
-            refAddr = (RefAddr) elements.nextElement();
+            refAddr = elements.nextElement();
             if (type.equals(refAddr.getType())) {
                 return refAddr;
             }
@@ -239,7 +204,7 @@
      *                      If the index is invalid.
      */
     public RefAddr get(int index) {
-        return (RefAddr) addrs.get(index);
+        return addrs.get(index);
     }
 
     /**
@@ -295,24 +260,20 @@
         addrs.clear();
     }
 
-    /*
-     * -------------------------------------------------------------------
-     * Methods override parent class Object
-     * -------------------------------------------------------------------
-     */
-
     /**
      * Returns a deep clone of this <code>Reference</code> instance.
      * 
      * @return              a deep clone of this object
      */
+    @SuppressWarnings("unchecked")
+    @Override
     public Object clone() {
         try {
             Reference r = (Reference) super.clone();
             r.addrs = (Vector<RefAddr>) this.addrs.clone();
             return r;
         } catch (CloneNotSupportedException e) {
-            throw new InternalError("Failed to clone object of Reference class."); //$NON-NLS-1$
+            throw new AssertionError("Failed to clone object of Reference class."); //$NON-NLS-1$
         }
     }
 
@@ -328,6 +289,7 @@
      * @return              true if this object is equal to <code>o</code>,
      *                      otherwise false
      */
+    @Override
     public boolean equals(Object o) {
         if (o instanceof Reference) {
             Reference r = (Reference) o;
@@ -340,13 +302,14 @@
     /**
      * Returns the hashcode for this <code>Reference</code> instance.
      * The result is calculated by summing the hashcode of the class name and 
-     * the hascodes of each of the addresses in the address list.
+     * the hash codes of each of the addresses in the address list.
      * 
      * @return              the hashcode of this <code>Reference</code> instance
      */
+    @Override
     public int hashCode() {
         int i = this.className.hashCode();
-        Enumeration e = this.addrs.elements();
+        Enumeration<RefAddr> e = this.addrs.elements();
 
         while (e.hasMoreElements()) {
             i += e.nextElement().hashCode();
@@ -360,9 +323,10 @@
      * 
      * @return              the string representation of this object
      */
+    @Override
     public String toString() {
         String s = "Reference class name: " + this.className; //$NON-NLS-1$
-        Enumeration e = this.addrs.elements();
+        Enumeration<RefAddr> e = this.addrs.elements();
 
         s += "\nReference addresses:"; //$NON-NLS-1$
         while (e.hasMoreElements()) {
@@ -370,7 +334,4 @@
         }
         return s + "\n"; //$NON-NLS-1$
     }
-
 }
-
-

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/StringRefAddr.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/StringRefAddr.java?view=diff&rev=448441&r1=448440&r2=448441
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/StringRefAddr.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/StringRefAddr.java Wed Sep 20 20:06:42 2006
@@ -78,6 +78,7 @@
      * 
      * @return          a string containing this address which may be null
      */
+    @Override
     public Object getContent() {
         return contents;
     }



Mime
View raw message