Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 652BA11A93 for ; Tue, 9 Sep 2014 00:36:40 +0000 (UTC) Received: (qmail 34578 invoked by uid 500); 9 Sep 2014 00:36:40 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 34502 invoked by uid 500); 9 Sep 2014 00:36:40 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 34492 invoked by uid 99); 9 Sep 2014 00:36:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Sep 2014 00:36:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Sep 2014 00:36:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8661523888FE; Tue, 9 Sep 2014 00:36:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1623602 - /commons/proper/net/trunk/src/main/java/examples/telnet/TelnetClientExample.java Date: Tue, 09 Sep 2014 00:36:18 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140909003618.8661523888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. *

* @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) *

* @param option_code - code of the option negotiated *

@@ -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); }