commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1623602 - /commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java
Date Tue, 09 Sep 2014 00:36:18 GMT
Author: sebb
Date: Tue Sep  9 00:36:18 2014
New Revision: 1623602

URL: http://svn.apache.org/r1623602
Log:
Simplify conditional by using switch
Add missing value

Modified:
    commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java

Modified: commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java?rev=1623602&r1=1623601&r2=1623602&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java Tue Sep
 9 00:36:18 2014
@@ -274,7 +274,7 @@ public class TelnetClientExample impleme
      * negotiation command.
      * <p>
      * @param negotiation_code - type of negotiation command received
-     * (RECEIVED_DO, RECEIVED_DONT, RECEIVED_WILL, RECEIVED_WONT)
+     * (RECEIVED_DO, RECEIVED_DONT, RECEIVED_WILL, RECEIVED_WONT, RECEIVED_COMMAND)
      * <p>
      * @param option_code - code of the option negotiated
      * <p>
@@ -283,21 +283,25 @@ public class TelnetClientExample impleme
     public void receivedNegotiation(int negotiation_code, int option_code)
     {
         String command = null;
-        if(negotiation_code == TelnetNotificationHandler.RECEIVED_DO)
-        {
-            command = "DO";
-        }
-        else if(negotiation_code == TelnetNotificationHandler.RECEIVED_DONT)
-        {
-            command = "DONT";
-        }
-        else if(negotiation_code == TelnetNotificationHandler.RECEIVED_WILL)
-        {
-            command = "WILL";
-        }
-        else if(negotiation_code == TelnetNotificationHandler.RECEIVED_WONT)
-        {
-            command = "WONT";
+        switch (negotiation_code) {
+            case TelnetNotificationHandler.RECEIVED_DO:
+                command = "DO";
+                break;
+            case TelnetNotificationHandler.RECEIVED_DONT:
+                command = "DONT";
+                break;
+            case TelnetNotificationHandler.RECEIVED_WILL:
+                command = "WILL";
+                break;
+            case TelnetNotificationHandler.RECEIVED_WONT:
+                command = "WONT";
+                break;
+            case TelnetNotificationHandler.RECEIVED_COMMAND:
+                command = "COMMAND";
+                break;
+            default:
+                command = Integer.toString(negotiation_code); // Should not happen
+                break;
         }
         System.out.println("Received " + command + " for option code " + option_code);
    }



Mime
View raw message