directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r240276 - in /directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value: HostAddress.java HostAddresses.java
Date Fri, 26 Aug 2005 16:27:05 GMT
Author: erodriguez
Date: Fri Aug 26 09:27:01 2005
New Revision: 240276

URL: http://svn.apache.org/viewcvs?rev=240276&view=rev
Log:
o  Removed unused code
o  Added toString methods

Modified:
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddress.java
    directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddresses.java

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddress.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddress.java?rev=240276&r1=240275&r2=240276&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddress.java
(original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddress.java
Fri Aug 26 09:27:01 2005
@@ -24,40 +24,12 @@
  */
 public class HostAddress
 {
-    // Host address length - inet
-	public static final int ADDR_LEN_INET      = 4;
-    // Host address length - chaos
-	public static final int ADDR_LEN_CHAOS     = 2;
-    // Host address length - osi
-	public static final int ADDR_LEN_OSI       = 0; // variable
-    // Host address length - xns
-	public static final int ADDR_LEN_XNS       = 6;
-    // Host address length - appletalk
-	public static final int ADDR_LEN_APPLETALK = 3;
-    // Host address length - decnet
-	public static final int ADDR_LEN_DECNET    = 2;
-
-	private static byte[] localInetAddress;
-
     private HostAddressType addressType;
     private byte[] address;
 
     /**
      * Class constructors
      */
-    public HostAddress()
-    {
-        try
-        {
-            addressType = HostAddressType.ADDRTYPE_INET;
-            address = getLocalInetAddress();
-        }
-        catch ( UnknownHostException uhe )
-        {
-            uhe.printStackTrace();
-        }
-    }
-
     public HostAddress( HostAddressType addressType, byte[] address )
     {
         this.addressType = addressType;
@@ -72,24 +44,25 @@
         System.arraycopy( newAddress, 0, address, 0, newAddress.length );
     }
 
-    public boolean equals( HostAddress h )
+    public boolean equals( HostAddress that )
     {
-        if ( addressType != h.addressType || ( address != null && h.address == null
)
-                || ( address == null && h.address != null ) )
+        if ( this.addressType != that.addressType
+                || ( this.address != null && that.address == null )
+                || ( this.address == null && that.address != null ) )
         {
             return false;
         }
 
-        if ( address != null && h.address != null )
+        if ( this.address != null && that.address != null )
         {
-            if ( address.length != h.address.length )
+            if ( this.address.length != that.address.length )
             {
                 return false;
             }
 
-            for ( int ii = 0; ii < address.length; ii++ )
+            for ( int ii = 0; ii < this.address.length; ii++ )
             {
-                if ( address[ ii ] != h.address[ ii ] )
+                if ( this.address[ ii ] != that.address[ ii ] )
                 {
                     return false;
                 }
@@ -99,19 +72,6 @@
         return true;
     }
 
-    public static byte[] getLocalInetAddress() throws UnknownHostException
-    {
-        if ( localInetAddress == null )
-        {
-            localInetAddress = InetAddress.getLocalHost().getAddress();
-        }
-
-        byte[] result = new byte[ localInetAddress.length ];
-        System.arraycopy( localInetAddress, 0, result, 0, localInetAddress.length );
-
-        return result;
-    }
-
     public byte[] getAddress()
     {
         return address;
@@ -120,5 +80,20 @@
     public HostAddressType getAddressType()
     {
         return addressType;
+    }
+
+    public String toString()
+    {
+        String result = "";
+
+        try
+        {
+            result = InetAddress.getByAddress( address ).getHostAddress();
+        }
+        catch ( UnknownHostException uhe )
+        {
+        }
+
+        return result;
     }
 }

Modified: directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddresses.java
URL: http://svn.apache.org/viewcvs/directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddresses.java?rev=240276&r1=240275&r2=240276&view=diff
==============================================================================
--- directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddresses.java
(original)
+++ directory/shared/kerberos/branches/refactor-to-chain/common/src/java/org/apache/kerberos/messages/value/HostAddresses.java
Fri Aug 26 09:27:01 2005
@@ -28,12 +28,6 @@
         this.addresses = addresses;
     }
 
-    public HostAddresses()
-    {
-        addresses = new HostAddress[ 1 ];
-        addresses[ 0 ] = new HostAddress();
-    }
-
     public boolean contains( HostAddress address )
     {
         if ( addresses != null )
@@ -80,5 +74,22 @@
     public HostAddress[] getAddresses()
     {
         return addresses;
+    }
+
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+
+        for ( int ii = 0; ii < this.addresses.length; ii++ )
+        {
+            sb.append( addresses[ ii ].toString() );
+
+            if ( ii < addresses.length - 1 )
+            {
+                sb.append( ", " );
+            }
+        }
+
+        return sb.toString();
     }
 }



Mime
View raw message