directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r109302 - /incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java
Date Wed, 01 Dec 2004 06:33:57 GMT
Author: trustin
Date: Tue Nov 30 22:33:56 2004
New Revision: 109302

URL: http://svn.apache.org/viewcvs?view=rev&rev=109302
Log:
IntraVmAddress.port is now an integer to let InetServiceDatabase can handle TDP/UDP/IntraVM
in the unified manner.
Modified:
   incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java

Modified: incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java
Url: http://svn.apache.org/viewcvs/incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java?view=diff&rev=109302&p1=incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java&r1=109301&p2=incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java&r2=109302
==============================================================================
--- incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java
(original)
+++ incubator/directory/seda/branches/trustin/src/java/org/apache/netty/common/IntraVmAddress.java
Tue Nov 30 22:33:56 2004
@@ -21,8 +21,6 @@
 
 import java.net.SocketAddress;
 
-import org.apache.commons.lang.Validate;
-
 
 /**
  * TODO Insert type comment.
@@ -31,22 +29,25 @@
  * @version $Rev$, $Date$
  */
 public class IntraVmAddress extends SocketAddress {
-    private final String port;
+    private final int port;
 
     /**
      * Creates a new instance.
      */
-    public IntraVmAddress(String port) {
-        Validate.notNull(port);
+    public IntraVmAddress(int port) {
+        if ((port < 0) || (port > 65535)) {
+            throw new IllegalArgumentException();
+        }
+
         this.port = port;
     }
 
-    public String getPort() {
+    public int getPort() {
         return port;
     }
 
     public int hashCode() {
-        return port.hashCode();
+        return port;
     }
 
     public boolean equals(Object o) {
@@ -59,9 +60,13 @@
         }
 
         if (o instanceof IntraVmAddress) {
-            return port.equals(((IntraVmAddress) o).getPort());
+            return port == ((IntraVmAddress) o).port;
         }
 
         return false;
+    }
+
+    public String toString() {
+        return "vm://localhost:" + port;
     }
 }

Mime
View raw message