harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r388398 - /incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java
Date Fri, 24 Mar 2006 06:12:25 GMT
Author: tellison
Date: Thu Mar 23 22:12:23 2006
New Revision: 388398

URL: http://svn.apache.org/viewcvs?rev=388398&view=rev
Log:
Fix for HARMONY-220 (javax.naming.NameClassPair lacks two Java 5.0 methods)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameClassPair.java?rev=388398&r1=388397&r2=388398&view=diff
==============================================================================
--- 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
Thu Mar 23 22:12:23 2006
@@ -11,186 +11,223 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package javax.naming;
-
-import java.io.Serializable;
-
-/**
- * <code>NameClassPair</code> associates a name in a naming service with a 
- * specified class name and also with a relative flag. In JNDI, 
- * <code>NameClassPair</code> is extended by <code>javax.naming.Binding</code>;
- * <code>Binding</code> objects are used in <code>javax.naming.Context</code>
- * implementations.
- * <p>
- * A <code>NameClassPair</code> object is not thread-safe unless appropriate

- * synchronization is applied to any code manipulating these objects.</p>
- * <p>
- * As this class implements the <code>Serializable</code> interface, it is 
- * important that fields below are declared with the same names.</p>
- * 
- */
-public class NameClassPair implements Serializable {
-
-    /*
-     * -------------------------------------------------------------------
-     * Constants
-     * -------------------------------------------------------------------
-     */
-
-    // J2SE 1.4.2
-    private static final long serialVersionUID = 5620776610160863339L;
-
-    /*
-     * -------------------------------------------------------------------
-     * Instance variables
-     * -------------------------------------------------------------------
-     */
-
-    /**
-     * The name used in a naming service. This field may be null and has default
-     * value of null.
-     * 
-     * @serial
-     */
-    private String name;
-
-    /**
-     * The class of an object represented by this name in a naming service.
-     * This field may be null and has default value null.
-     * 
-     * @serial
-     */
-    private String className;
-
-    /**
-     * This flag indicates whether the name s used in a naming service is relative
-     * to the context. It is set by setRelative and is not derived. This field has
-     * default value true. If this is set to false then the name is not relative and
-     * is actually a URL.
-     * 
-     * @serial
-     */
-    private boolean isRel;
-
-    /*
-     * -------------------------------------------------------------------
-     * Constructors
-     * -------------------------------------------------------------------
-     */
-
-    /**
-     * Construct a <code>NameClassPair</code> from a name and a class.
-     * Both arguments can be null.
-     * Relative flag is true.
-     * 
-     * @param name      a name used in naming service
-     * @param className a class name
-     */
-    public NameClassPair(String name, String className) {
-        this(name, className, true);
-    }
-
-    /**
-     * Construct a <code>NameClassPair</code> from a name, a class and a 
-     * relative flag. The name and class arguments can be null.
-     * 
-     * @param name      a name used in naming service
-     * @param className a class name
-     * @param relative  a relative flag
-     */
-    public NameClassPair(String name, String className, boolean relative) {
-        this.name = name;
-        this.className = className;
-        this.isRel = relative;
-    }
-
-    /*
-     * -------------------------------------------------------------------
-     * Methods
-     * -------------------------------------------------------------------
-     */
-
-    /**
-     * Returns the value of the class which may be null.
-     * 
-     * @return the value of the class which may be null.
-     */
-    public String getClassName() {
-        return className;
-    }
-
-    /**
-     * Returns the value of the name field which may be null.
-     * 
-     * @return the value of the name field which may be null.
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Returns the value of the relative flag.
-     * 
-     * @return the value of the relative flag.
-     */
-    public boolean isRelative() {
-        return isRel;
-    }
-
-    /**
-     * Set the class of this object. The argument can be null.
-     * 
-     * @param className a class name
-     */
-    public void setClassName(String className) {
-        this.className = className;
-    }
-
-    /**
-     * Set the name of this object. The argument can be null.
-     * 
-     * @param name  a name used in naming service
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * Set the isRelative flag field of this object.
-     * 
-     * @param relative  a relative flag
-     */
-    public void setRelative(boolean relative) {
-        this.isRel = relative;
-    }
-
-    /*
-     * -------------------------------------------------------------------
-     * Methods override parent class Object
-     * -------------------------------------------------------------------
-     */
-
-    /**
-     * If the flag is set to false then the string is preceded with
-     * "(not relative)" and then has the name value, ": " and the class
-     * value.
-     * 
-     * @return a string representation of this object
-     */
-    public String toString() {
-        StringBuffer buf = new StringBuffer();
-        if (!isRel) {
-            buf.append("(not relative)"); //$NON-NLS-1$
-        }
-        buf.append(getName());
-        buf.append(": "); //$NON-NLS-1$
-        buf.append(getClassName()); // getClassName() is overrided by subclass
-        return buf.toString();
-    }
-
-}
-
-
+ */
+
+
+package javax.naming;
+
+import java.io.Serializable;
+
+/**
+ * <code>NameClassPair</code> associates a name in a naming service with a 
+ * specified class name and also with a relative flag. In JNDI, 
+ * <code>NameClassPair</code> is extended by <code>javax.naming.Binding</code>;
+ * <code>Binding</code> objects are used in <code>javax.naming.Context</code>
+ * implementations.
+ * <p>
+ * A <code>NameClassPair</code> object is not thread-safe unless appropriate

+ * synchronization is applied to any code manipulating these objects.</p>
+ * <p>
+ * As this class implements the <code>Serializable</code> interface, it is 
+ * important that fields below are declared with the same names.</p>
+ * 
+ */
+public class NameClassPair implements Serializable {
+
+    /*
+     * -------------------------------------------------------------------
+     * Constants
+     * -------------------------------------------------------------------
+     */
+
+    // J2SE 1.5.0
+    private static final long serialVersionUID = 5620776610160863339L;
+
+    /*
+     * -------------------------------------------------------------------
+     * Instance variables
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * The name used in a naming service. This field may be null and has default
+     * value of null.
+     * 
+     * @serial
+     */
+    private String name;
+
+    /**
+     * The class of an object represented by this name in a naming service.
+     * This field may be null and has default value null.
+     * 
+     * @serial
+     */
+    private String className;
+
+	/**
+	 * 
+	 * @serial
+	 */
+	private String fullName;
+
+    /**
+     * This flag indicates whether the name s used in a naming service is relative
+     * to the context. It is set by setRelative and is not derived. This field has
+     * default value true. If this is set to false then the name is not relative and
+     * is actually a URL.
+     * 
+     * @serial
+     */
+    private boolean isRel;
+
+	/*
+     * -------------------------------------------------------------------
+     * Constructors
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Construct a <code>NameClassPair</code> from a name and a class.
+     * Both arguments can be null.
+     * Relative flag is true.
+     * 
+     * @param name      a name used in naming service
+     * @param className a class name
+     */
+    public NameClassPair(String name, String className) {
+        this(name, className, true);
+    }
+
+    /**
+     * Construct a <code>NameClassPair</code> from a name, a class and a 
+     * relative flag. The name and class arguments can be null.
+     * 
+     * @param name      a name used in naming service
+     * @param className a class name
+     * @param relative  a relative flag
+     */
+    public NameClassPair(String name, String className, boolean relative) {
+        if (name == null) {
+            throw new IllegalArgumentException("name must not be null");
+        }
+        this.name = name;
+        this.className = className;
+        this.isRel = relative;
+        this.fullName = null;
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Returns the value of the class which may be null.
+     * 
+     * @return the value of the class which may be null.
+     */
+    public String getClassName() {
+        return className;
+    }
+
+    /**
+     * Returns the value of the name field which may be null.
+     * 
+     * @return the value of the name field which may be null.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Returns the value of the relative flag.
+     * 
+     * @return the value of the relative flag.
+     */
+    public boolean isRelative() {
+        return isRel;
+    }
+
+    /**
+     * Set the class of this object. The argument can be null.
+     * 
+     * @param className a class name
+     */
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    /**
+     * Set the name of this object. The argument can be null.
+     * 
+     * @param name  a name used in naming service
+     */
+    public void setName(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("name must not be null");
+        }
+        this.name = name;
+    }
+
+    /**
+     * Set the isRelative flag field of this object.
+     * 
+     * @param relative  a relative flag
+     */
+    public void setRelative(boolean relative) {
+        this.isRel = relative;
+    }
+
+    /**
+     * Returns the value of the full name field which may be null.
+     * 
+     * @return the value of the full name field which may be null.
+     *
+     * @throws UnsupportedOperationException
+     */
+    public String getNameInNamespace() {
+        if (fullName == null) {
+            throw new UnsupportedOperationException(
+                    "full name doesn't apply to this binding");
+        }
+        return fullName;
+    }
+
+    /**
+     * Set the full name of this object. The argument can be null.
+     * 
+     * @param fullName  a full name
+     */
+    public void setNameInNamespace(String fullName) {
+        this.fullName = fullName;
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods override parent class Object
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * If the flag is set to false then the string is preceded with
+     * "(not relative)" and then has the name value, ": " and the class
+     * value.
+     * 
+     * @return a string representation of this object
+     */
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        if (!isRel) {
+            buf.append("(not relative)"); //$NON-NLS-1$
+        }
+        buf.append(getName());
+        buf.append(": "); //$NON-NLS-1$
+        buf.append(getClassName()); // getClassName() is overrided by subclass
+        return buf.toString();
+    }
+
+}
+
+



Mime
View raw message