You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/12/17 15:17:58 UTC

[commons-net] branch master updated: Rename private and package-private names that had leading underscores.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git


The following commit(s) were added to refs/heads/master by this push:
     new e1816ec  Rename private and package-private names that had leading underscores.
e1816ec is described below

commit e1816ec720397d6a57ecc62b39f06c931ce3b786
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 17 10:17:53 2020 -0500

    Rename private and package-private names that had leading underscores.
---
 src/main/java/org/apache/commons/net/ftp/FTP.java  |  45 +++---
 .../java/org/apache/commons/net/imap/IMAP.java     |  20 +--
 .../commons/net/io/FromNetASCIIInputStream.java    |   8 +-
 .../commons/net/io/FromNetASCIIOutputStream.java   |   6 +-
 .../java/org/apache/commons/net/nntp/NNTP.java     |  70 +++++-----
 .../org/apache/commons/net/nntp/NNTPClient.java    |  20 +--
 .../java/org/apache/commons/net/pop3/POP3.java     |  18 +--
 .../org/apache/commons/net/pop3/POP3SClient.java   |   4 +-
 .../java/org/apache/commons/net/smtp/SMTP.java     | 151 ++++++++++-----------
 .../java/org/apache/commons/net/telnet/Telnet.java |  64 ++++-----
 .../apache/commons/net/telnet/TelnetClient.java    |   2 +-
 .../commons/net/telnet/TelnetInputStream.java      |   8 +-
 .../java/org/apache/commons/net/tftp/TFTP.java     |   4 +-
 .../org/apache/commons/net/tftp/TFTPAckPacket.java |   2 +-
 .../apache/commons/net/tftp/TFTPDataPacket.java    |   2 +-
 .../apache/commons/net/tftp/TFTPErrorPacket.java   |   2 +-
 .../org/apache/commons/net/tftp/TFTPPacket.java    |   2 +-
 .../apache/commons/net/tftp/TFTPRequestPacket.java |   8 +-
 18 files changed, 207 insertions(+), 229 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/ftp/FTP.java b/src/main/java/org/apache/commons/net/ftp/FTP.java
index 9526e63..c6afbf8 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTP.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTP.java
@@ -276,7 +276,7 @@ public class FTP extends SocketClient
     }
 
     // The RFC-compliant multiline termination check
-    private boolean __strictCheck(final String line, final String code) {
+    private boolean strictCheck(final String line, final String code) {
         return !(line.startsWith(code) && line.charAt(REPLY_CODE_LEN) == ' ');
     }
 
@@ -285,20 +285,12 @@ public class FTP extends SocketClient
     // 426 multi-line reply in response to ls /.  We relax the condition to
     // test that the line starts with a digit rather than starting with
     // the code.
-    private boolean __lenientCheck(final String line) {
+    private boolean lenientCheck(final String line) {
         return !(line.length() > REPLY_CODE_LEN&& line.charAt(REPLY_CODE_LEN) != '-' &&
                 Character.isDigit(line.charAt(0)));
     }
 
     /**
-     * Get the reply, and pass it to command listeners
-     */
-    private void __getReply()  throws IOException
-    {
-        __getReply(true);
-    }
-
-    /**
      * Get the reply, but don't pass it to command listeners.
      * Used for keep-alive processing only.
      * @since 3.0
@@ -306,10 +298,10 @@ public class FTP extends SocketClient
      */
     protected void __getReplyNoReport()  throws IOException
     {
-        __getReply(false);
+        getReply(false);
     }
 
-    private void __getReply(final boolean reportReply) throws IOException
+    private int getReply(final boolean reportReply) throws IOException
     {
         int length;
 
@@ -365,7 +357,7 @@ public class FTP extends SocketClient
                     // returning too soon after encountering a naked CR or some other
                     // anomaly.
                 }
-                while ( isStrictMultilineParsing() ? __strictCheck(line, code) : __lenientCheck(line));
+                while ( isStrictMultilineParsing() ? strictCheck(line, code) : lenientCheck(line));
 
             } else if (isStrictReplyParsing()) {
                 if (length == REPLY_CODE_LEN + 1) { // expecting some text
@@ -385,6 +377,7 @@ public class FTP extends SocketClient
         if (_replyCode == FTPReply.SERVICE_NOT_AVAILABLE) {
             throw new FTPConnectionClosedException("FTP response 421 received.  Server closed connection.");
         }
+        return _replyCode;
     }
 
     /**
@@ -420,10 +413,10 @@ public class FTP extends SocketClient
             final int original = _socket_.getSoTimeout();
             _socket_.setSoTimeout(connectTimeout);
             try {
-                __getReply();
+                getReply();
                 // If we received code 120, we have to fetch completion reply.
                 if (FTPReply.isPositivePreliminary(_replyCode)) {
-                    __getReply();
+                    getReply();
                 }
             } catch (final SocketTimeoutException e) {
                 final IOException ioe = new IOException("Timed out waiting for initial connect reply");
@@ -433,10 +426,10 @@ public class FTP extends SocketClient
                 _socket_.setSoTimeout(original);
             }
         } else {
-            __getReply();
+            getReply();
             // If we received code 120, we have to fetch completion reply.
             if (FTPReply.isPositivePreliminary(_replyCode)) {
-                __getReply();
+                getReply();
             }
         }
     }
@@ -512,17 +505,16 @@ public class FTP extends SocketClient
             throw new IOException("Connection is not open");
         }
 
-        final String message = __buildMessage(command, args);
+        final String message = buildMessage(command, args);
 
-        __send(message);
+        send(message);
 
         fireCommandSent(command, message);
 
-        __getReply();
-        return _replyCode;
+        return getReply();
     }
 
-    private String __buildMessage(final String command, final String args) {
+    private String buildMessage(final String command, final String args) {
         final StringBuilder __commandBuffer = new StringBuilder();
 
         __commandBuffer.append(command);
@@ -536,7 +528,7 @@ public class FTP extends SocketClient
         return __commandBuffer.toString();
     }
 
-    private void __send(final String message) throws IOException,
+    private void send(final String message) throws IOException,
             FTPConnectionClosedException, SocketException {
         try{
             _controlOutput_.write(message);
@@ -560,8 +552,8 @@ public class FTP extends SocketClient
      * @since 3.0
      */
     protected void __noop() throws IOException {
-        final String msg = __buildMessage(FTPCmd.NOOP.getCommand(), null);
-        __send(msg);
+        final String msg = buildMessage(FTPCmd.NOOP.getCommand(), null);
+        send(msg);
         __getReplyNoReport(); // This may timeout
     }
 
@@ -724,8 +716,7 @@ public class FTP extends SocketClient
      ***/
     public int getReply() throws IOException
     {
-        __getReply();
-        return _replyCode;
+        return getReply(true);
     }
 
 
diff --git a/src/main/java/org/apache/commons/net/imap/IMAP.java b/src/main/java/org/apache/commons/net/imap/IMAP.java
index 9a39a45..f10624a 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAP.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAP.java
@@ -62,7 +62,7 @@ public class IMAP extends SocketClient
 
     protected BufferedReader _reader;
     private int replyCode;
-    private final List<String> _replyLines;
+    private final List<String> replyLines;
 
     /**
      * Implement this interface and register it via {@link #setChunkListener(IMAPChunkListener)}
@@ -121,7 +121,7 @@ public class IMAP extends SocketClient
         state = IMAPState.DISCONNECTED_STATE;
         _reader = null;
         __writer = null;
-        _replyLines = new ArrayList<>();
+        replyLines = new ArrayList<>();
         createCommandSupport();
     }
 
@@ -144,14 +144,14 @@ public class IMAP extends SocketClient
      */
     private void getReply(final boolean wantTag) throws IOException
     {
-        _replyLines.clear();
+        replyLines.clear();
         String line = _reader.readLine();
 
         if (line == null) {
             throw new EOFException("Connection closed without indication.");
         }
 
-        _replyLines.add(line);
+        replyLines.add(line);
 
         if (wantTag) {
             while(IMAPReply.isUntagged(line)) {
@@ -162,7 +162,7 @@ public class IMAP extends SocketClient
                     if (line == null) {
                         throw new EOFException("Connection closed without indication.");
                     }
-                    _replyLines.add(line);
+                    replyLines.add(line);
                     literalCount -= line.length() + 2; // Allow for CRLF
                 }
                 if (isMultiLine) {
@@ -171,7 +171,7 @@ public class IMAP extends SocketClient
                         final boolean clear = il.chunkReceived(this);
                         if (clear) {
                             fireReplyReceived(IMAPReply.PARTIAL, getReplyString());
-                            _replyLines.clear();
+                            replyLines.clear();
                         }
                     }
                 }
@@ -179,7 +179,7 @@ public class IMAP extends SocketClient
                 if (line == null) {
                     throw new EOFException("Connection closed without indication.");
                 }
-                _replyLines.add(line);
+                replyLines.add(line);
             }
             // check the response code on the last line
             replyCode = IMAPReply.getReplyCode(line);
@@ -267,7 +267,7 @@ public class IMAP extends SocketClient
         super.disconnect();
         _reader = null;
         __writer = null;
-        _replyLines.clear();
+        replyLines.clear();
         setState(IMAPState.DISCONNECTED_STATE);
     }
 
@@ -407,7 +407,7 @@ public class IMAP extends SocketClient
      */
     public String[] getReplyStrings()
     {
-        return _replyLines.toArray(new String[_replyLines.size()]);
+        return replyLines.toArray(new String[replyLines.size()]);
     }
 
     /**
@@ -420,7 +420,7 @@ public class IMAP extends SocketClient
     public String getReplyString()
     {
         final StringBuilder buffer = new StringBuilder(256);
-        for (final String s : _replyLines)
+        for (final String s : replyLines)
         {
             buffer.append(s);
             buffer.append(SocketClient.NETASCII_EOL);
diff --git a/src/main/java/org/apache/commons/net/io/FromNetASCIIInputStream.java b/src/main/java/org/apache/commons/net/io/FromNetASCIIInputStream.java
index d22247c..34959f7 100644
--- a/src/main/java/org/apache/commons/net/io/FromNetASCIIInputStream.java
+++ b/src/main/java/org/apache/commons/net/io/FromNetASCIIInputStream.java
@@ -75,7 +75,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
     }
 
 
-    private int __read() throws IOException
+    private int readInt() throws IOException
     {
         int ch;
 
@@ -124,7 +124,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
             return super.read();
         }
 
-        return __read();
+        return readInt();
     }
 
 
@@ -183,7 +183,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
         }
 
 
-        if ((ch = __read()) == -1) {
+        if ((ch = readInt()) == -1) {
             return -1;
         }
 
@@ -193,7 +193,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
         {
             buffer[offset++] = (byte)ch;
         }
-        while (--this.length > 0 && (ch = __read()) != -1);
+        while (--this.length > 0 && (ch = readInt()) != -1);
 
 
         return offset - off;
diff --git a/src/main/java/org/apache/commons/net/io/FromNetASCIIOutputStream.java b/src/main/java/org/apache/commons/net/io/FromNetASCIIOutputStream.java
index 027d20b..6728c37 100644
--- a/src/main/java/org/apache/commons/net/io/FromNetASCIIOutputStream.java
+++ b/src/main/java/org/apache/commons/net/io/FromNetASCIIOutputStream.java
@@ -53,7 +53,7 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
     }
 
 
-    private void __write(final int ch) throws IOException
+    private void writeInt(final int ch) throws IOException
     {
         switch (ch)
         {
@@ -105,7 +105,7 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
             return ;
         }
 
-        __write(ch);
+        writeInt(ch);
     }
 
 
@@ -147,7 +147,7 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
         }
 
         while (length-- > 0) {
-            __write(buffer[offset++]);
+            writeInt(buffer[offset++]);
         }
     }
 
diff --git a/src/main/java/org/apache/commons/net/nntp/NNTP.java b/src/main/java/org/apache/commons/net/nntp/NNTP.java
index 72f6e09..d583297 100644
--- a/src/main/java/org/apache/commons/net/nntp/NNTP.java
+++ b/src/main/java/org/apache/commons/net/nntp/NNTP.java
@@ -128,40 +128,6 @@ public class NNTP extends SocketClient
         _commandSupport_ = new ProtocolCommandSupport(this);
     }
 
-    private void __getReply() throws IOException
-    {
-        replyString = _reader_.readLine();
-
-        if (replyString == null) {
-            throw new NNTPConnectionClosedException(
-                    "Connection closed without indication.");
-        }
-
-        // In case we run into an anomaly we don't want fatal index exceptions
-        // to be thrown.
-        if (replyString.length() < 3) {
-            throw new MalformedServerReplyException(
-                "Truncated server reply: " + replyString);
-        }
-
-        try
-        {
-            replyCode = Integer.parseInt(replyString.substring(0, 3));
-        }
-        catch (final NumberFormatException e)
-        {
-            throw new MalformedServerReplyException(
-                "Could not parse response code.\nServer Reply: " + replyString);
-        }
-
-        fireReplyReceived(replyCode, replyString + SocketClient.NETASCII_EOL);
-
-        if (replyCode == NNTPReply.SERVICE_DISCONTINUED) {
-            throw new NNTPConnectionClosedException(
-                "NNTP response 400 received.  Server closed connection.");
-        }
-    }
-
     /***
      * Initiates control connections and gets initial reply, determining
      * if the client is allowed to post to the server.  Initializes
@@ -178,7 +144,7 @@ public class NNTP extends SocketClient
         _writer_ =
             new BufferedWriter(new OutputStreamWriter(_output_,
                                                       DEFAULT_ENCODING));
-        __getReply();
+        getReply();
 
         _isAllowedToPost = replyCode == NNTPReply.SERVER_READY_POSTING_ALLOWED;
     }
@@ -252,8 +218,7 @@ public class NNTP extends SocketClient
 
         fireCommandSent(command, message);
 
-        __getReply();
-        return replyCode;
+        return getReply();
     }
 
 
@@ -365,7 +330,36 @@ public class NNTP extends SocketClient
      ***/
     public int getReply() throws IOException
     {
-        __getReply();
+        replyString = _reader_.readLine();
+
+        if (replyString == null) {
+            throw new NNTPConnectionClosedException(
+                    "Connection closed without indication.");
+        }
+
+        // In case we run into an anomaly we don't want fatal index exceptions
+        // to be thrown.
+        if (replyString.length() < 3) {
+            throw new MalformedServerReplyException(
+                "Truncated server reply: " + replyString);
+        }
+
+        try
+        {
+            replyCode = Integer.parseInt(replyString.substring(0, 3));
+        }
+        catch (final NumberFormatException e)
+        {
+            throw new MalformedServerReplyException(
+                "Could not parse response code.\nServer Reply: " + replyString);
+        }
+
+        fireReplyReceived(replyCode, replyString + SocketClient.NETASCII_EOL);
+
+        if (replyCode == NNTPReply.SERVICE_DISCONTINUED) {
+            throw new NNTPConnectionClosedException(
+                "NNTP response 400 received.  Server closed connection.");
+        }
         return replyCode;
     }
 
diff --git a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java
index 886866f..462cd24 100644
--- a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java
+++ b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java
@@ -271,7 +271,7 @@ public class NNTPClient extends NNTP
     }
 
 
-    private BufferedReader __retrieve(final int command, final String articleId, final ArticleInfo pointer)
+    private BufferedReader retrieve(final int command, final String articleId, final ArticleInfo pointer)
     throws IOException
     {
         if (articleId != null)
@@ -355,7 +355,7 @@ public class NNTPClient extends NNTP
     public BufferedReader retrieveArticle(final String articleId, final ArticleInfo pointer)
     throws IOException
     {
-        return __retrieve(NNTPCommand.ARTICLE, articleId, pointer);
+        return retrieve(NNTPCommand.ARTICLE, articleId, pointer);
 
     }
 
@@ -486,7 +486,7 @@ public class NNTPClient extends NNTP
     public BufferedReader retrieveArticleHeader(final String articleId, final ArticleInfo pointer)
     throws IOException
     {
-        return __retrieve(NNTPCommand.HEAD, articleId, pointer);
+        return retrieve(NNTPCommand.HEAD, articleId, pointer);
 
     }
 
@@ -617,7 +617,7 @@ public class NNTPClient extends NNTP
     public BufferedReader retrieveArticleBody(final String articleId, final ArticleInfo pointer)
     throws IOException
     {
-        return __retrieve(NNTPCommand.BODY, articleId, pointer);
+        return retrieve(NNTPCommand.BODY, articleId, pointer);
 
     }
 
@@ -1460,7 +1460,7 @@ public class NNTPClient extends NNTP
      *         otherwise
      * @throws IOException
      */
-    private BufferedReader __retrieveArticleInfo(final String articleRange)
+    private BufferedReader retrieveArticleInfo(final String articleRange)
         throws IOException
     {
         if (!NNTPReply.isPositiveCompletion(xover(articleRange))) {
@@ -1479,7 +1479,7 @@ public class NNTPClient extends NNTP
      */
     public BufferedReader retrieveArticleInfo(final long articleNumber) throws IOException
     {
-        return __retrieveArticleInfo(Long.toString(articleNumber));
+        return retrieveArticleInfo(Long.toString(articleNumber));
     }
 
     /**
@@ -1496,7 +1496,7 @@ public class NNTPClient extends NNTP
         throws IOException
     {
         return
-            __retrieveArticleInfo(lowArticleNumber + "-" +
+            retrieveArticleInfo(lowArticleNumber + "-" +
                                              highArticleNumber);
     }
 
@@ -1533,7 +1533,7 @@ public class NNTPClient extends NNTP
      *         otherwise
      * @throws IOException
      */
-    private BufferedReader __retrieveHeader(final String header, final String articleRange)
+    private BufferedReader retrieveHeader(final String header, final String articleRange)
         throws IOException
     {
         if (!NNTPReply.isPositiveCompletion(xhdr(header, articleRange))) {
@@ -1554,7 +1554,7 @@ public class NNTPClient extends NNTP
     public BufferedReader retrieveHeader(final String header, final long articleNumber)
         throws IOException
     {
-        return __retrieveHeader(header, Long.toString(articleNumber));
+        return retrieveHeader(header, Long.toString(articleNumber));
     }
 
     /**
@@ -1572,7 +1572,7 @@ public class NNTPClient extends NNTP
         throws IOException
     {
         return
-            __retrieveHeader(header,lowArticleNumber + "-" + highArticleNumber);
+            retrieveHeader(header,lowArticleNumber + "-" + highArticleNumber);
     }
 
 
diff --git a/src/main/java/org/apache/commons/net/pop3/POP3.java b/src/main/java/org/apache/commons/net/pop3/POP3.java
index c35a1e1..4ae7f63 100644
--- a/src/main/java/org/apache/commons/net/pop3/POP3.java
+++ b/src/main/java/org/apache/commons/net/pop3/POP3.java
@@ -70,15 +70,15 @@ public class POP3 extends SocketClient
     /***  A constant representing the POP3 update state. ***/
     public static final int UPDATE_STATE = 2;
 
-    static final String _OK = "+OK";
+    static final String OK = "+OK";
     // The reply indicating intermediate response to a command.
-    static final String _OK_INT = "+ ";
-    static final String _ERROR = "-ERR";
+    static final String OK_INT = "+ ";
+    static final String ERROR = "-ERR";
 
     // We have to ensure that the protocol communication is in ASCII
     // but we use ISO-8859-1 just in case 8-bit characters cross
     // the wire.
-    static final Charset _DEFAULT_ENCODING = StandardCharsets.ISO_8859_1;
+    static final Charset DEFAULT_ENCODING = StandardCharsets.ISO_8859_1;
 
     private int popState;
     BufferedWriter writer;
@@ -119,11 +119,11 @@ public class POP3 extends SocketClient
             throw new EOFException("Connection closed without indication.");
         }
 
-        if (line.startsWith(_OK)) {
+        if (line.startsWith(OK)) {
             replyCode = POP3Reply.OK;
-        } else if (line.startsWith(_ERROR)) {
+        } else if (line.startsWith(ERROR)) {
             replyCode = POP3Reply.ERROR;
-        } else if (line.startsWith(_OK_INT)) {
+        } else if (line.startsWith(OK_INT)) {
             replyCode = POP3Reply.OK_INT;
         } else {
             throw new
@@ -148,10 +148,10 @@ public class POP3 extends SocketClient
         super._connectAction_();
         reader =
           new CRLFLineReader(new InputStreamReader(_input_,
-                                                   _DEFAULT_ENCODING));
+                                                   DEFAULT_ENCODING));
         writer =
           new BufferedWriter(new OutputStreamWriter(_output_,
-                                                    _DEFAULT_ENCODING));
+                                                    DEFAULT_ENCODING));
         getReply();
         setState(AUTHORIZATION_STATE);
     }
diff --git a/src/main/java/org/apache/commons/net/pop3/POP3SClient.java b/src/main/java/org/apache/commons/net/pop3/POP3SClient.java
index f223f92..c85a912 100644
--- a/src/main/java/org/apache/commons/net/pop3/POP3SClient.java
+++ b/src/main/java/org/apache/commons/net/pop3/POP3SClient.java
@@ -230,8 +230,8 @@ public class POP3SClient extends POP3Client
         _socket_ = socket;
         _input_ = socket.getInputStream();
         _output_ = socket.getOutputStream();
-        reader = new CRLFLineReader(new InputStreamReader(_input_, _DEFAULT_ENCODING));
-        writer = new BufferedWriter(new OutputStreamWriter(_output_, _DEFAULT_ENCODING));
+        reader = new CRLFLineReader(new InputStreamReader(_input_, DEFAULT_ENCODING));
+        writer = new BufferedWriter(new OutputStreamWriter(_output_, DEFAULT_ENCODING));
 
         if (hostnameVerifier != null && !hostnameVerifier.verify(host, socket.getSession())) {
             throw new SSLHandshakeException("Hostname doesn't match certificate");
diff --git a/src/main/java/org/apache/commons/net/smtp/SMTP.java b/src/main/java/org/apache/commons/net/smtp/SMTP.java
index 4a77a74..3da87dc 100644
--- a/src/main/java/org/apache/commons/net/smtp/SMTP.java
+++ b/src/main/java/org/apache/commons/net/smtp/SMTP.java
@@ -145,7 +145,7 @@ public class SMTP extends SocketClient
      * @return the reply code
      * @throws IOException
      */
-    private int __sendCommand(final String command, final String args, final boolean includeSpace)
+    private int sendCommand(final String command, final String args, final boolean includeSpace)
     throws IOException
     {
         final StringBuilder __commandBuffer = new StringBuilder();
@@ -167,8 +167,7 @@ public class SMTP extends SocketClient
 
         fireCommandSent(command, message);
 
-        __getReply();
-        return replyCode;
+        return getReply();
     }
 
     /**
@@ -179,78 +178,10 @@ public class SMTP extends SocketClient
      * @return the reply code
      * @throws IOException
      */
-    private int __sendCommand(final int command, final String args, final boolean includeSpace)
+    private int sendCommand(final int command, final String args, final boolean includeSpace)
     throws IOException
     {
-        return __sendCommand(SMTPCommand.getCommand(command), args, includeSpace);
-    }
-
-    private void __getReply() throws IOException
-    {
-        int length;
-
-        newReplyString = true;
-        replyLines.clear();
-
-        String line = reader.readLine();
-
-        if (line == null) {
-            throw new SMTPConnectionClosedException(
-                "Connection closed without indication.");
-        }
-
-        // In case we run into an anomaly we don't want fatal index exceptions
-        // to be thrown.
-        length = line.length();
-        if (length < 3) {
-            throw new MalformedServerReplyException(
-                "Truncated server reply: " + line);
-        }
-
-        try
-        {
-            final String code = line.substring(0, 3);
-            replyCode = Integer.parseInt(code);
-        }
-        catch (final NumberFormatException e)
-        {
-            throw new MalformedServerReplyException(
-                "Could not parse response code.\nServer Reply: " + line);
-        }
-
-        replyLines.add(line);
-
-        // Get extra lines if message continues.
-        if (length > 3 && line.charAt(3) == '-')
-        {
-            do
-            {
-                line = reader.readLine();
-
-                if (line == null) {
-                    throw new SMTPConnectionClosedException(
-                        "Connection closed without indication.");
-                }
-
-                replyLines.add(line);
-
-                // The length() check handles problems that could arise from readLine()
-                // returning too soon after encountering a naked CR or some other
-                // anomaly.
-            }
-            while (!(line.length() >= 4 && line.charAt(3) != '-' &&
-                     Character.isDigit(line.charAt(0))));
-            // This is too strong a condition because a non-conforming server
-            // could screw things up like ftp.funet.fi does for FTP
-            // line.startsWith(code)));
-        }
-
-        fireReplyReceived(replyCode, getReplyString());
-
-        if (replyCode == SMTPReply.SERVICE_NOT_AVAILABLE) {
-            throw new SMTPConnectionClosedException(
-                "SMTP response 421 received.  Server closed connection.");
-        }
+        return sendCommand(SMTPCommand.getCommand(command), args, includeSpace);
     }
 
     /*** Initiates control connections and gets initial reply. ***/
@@ -264,8 +195,7 @@ public class SMTP extends SocketClient
         writer =
             new BufferedWriter(new OutputStreamWriter(_output_,
                                                       encoding));
-        __getReply();
-
+        getReply();
     }
 
 
@@ -311,7 +241,7 @@ public class SMTP extends SocketClient
      ***/
     public int sendCommand(final String command, final String args) throws IOException
     {
-        return __sendCommand(command, args, true);
+        return sendCommand(command, args, true);
     }
 
 
@@ -423,7 +353,70 @@ public class SMTP extends SocketClient
      ***/
     public int getReply() throws IOException
     {
-        __getReply();
+        int length;
+
+        newReplyString = true;
+        replyLines.clear();
+
+        String line = reader.readLine();
+
+        if (line == null) {
+            throw new SMTPConnectionClosedException(
+                "Connection closed without indication.");
+        }
+
+        // In case we run into an anomaly we don't want fatal index exceptions
+        // to be thrown.
+        length = line.length();
+        if (length < 3) {
+            throw new MalformedServerReplyException(
+                "Truncated server reply: " + line);
+        }
+
+        try
+        {
+            final String code = line.substring(0, 3);
+            replyCode = Integer.parseInt(code);
+        }
+        catch (final NumberFormatException e)
+        {
+            throw new MalformedServerReplyException(
+                "Could not parse response code.\nServer Reply: " + line);
+        }
+
+        replyLines.add(line);
+
+        // Get extra lines if message continues.
+        if (length > 3 && line.charAt(3) == '-')
+        {
+            do
+            {
+                line = reader.readLine();
+
+                if (line == null) {
+                    throw new SMTPConnectionClosedException(
+                        "Connection closed without indication.");
+                }
+
+                replyLines.add(line);
+
+                // The length() check handles problems that could arise from readLine()
+                // returning too soon after encountering a naked CR or some other
+                // anomaly.
+            }
+            while (!(line.length() >= 4 && line.charAt(3) != '-' &&
+                     Character.isDigit(line.charAt(0))));
+            // This is too strong a condition because a non-conforming server
+            // could screw things up like ftp.funet.fi does for FTP
+            // line.startsWith(code)));
+        }
+
+        fireReplyReceived(replyCode, getReplyString());
+
+        if (replyCode == SMTPReply.SERVICE_NOT_AVAILABLE) {
+            throw new SMTPConnectionClosedException(
+                "SMTP response 421 received.  Server closed connection.");
+        }
         return replyCode;
     }
 
@@ -506,7 +499,7 @@ public class SMTP extends SocketClient
      ***/
     public int mail(final String reversePath) throws IOException
     {
-        return __sendCommand(SMTPCommand.MAIL, reversePath, false);
+        return sendCommand(SMTPCommand.MAIL, reversePath, false);
     }
 
 
@@ -526,7 +519,7 @@ public class SMTP extends SocketClient
      ***/
     public int rcpt(final String forwardPath) throws IOException
     {
-        return __sendCommand(SMTPCommand.RCPT, forwardPath, false);
+        return sendCommand(SMTPCommand.RCPT, forwardPath, false);
     }
 
 
diff --git a/src/main/java/org/apache/commons/net/telnet/Telnet.java b/src/main/java/org/apache/commons/net/telnet/Telnet.java
index ec3cd6d..d0909bb 100644
--- a/src/main/java/org/apache/commons/net/telnet/Telnet.java
+++ b/src/main/java/org/apache/commons/net/telnet/Telnet.java
@@ -31,32 +31,32 @@ class Telnet extends SocketClient
 
     static final boolean debugoptions =  /*true;*/ false;
 
-    static final byte[] _COMMAND_DO = {
+    static final byte[] COMMAND_DO = {
                                           (byte)TelnetCommand.IAC, (byte)TelnetCommand.DO
                                       };
 
-    static final byte[] _COMMAND_DONT = {
+    static final byte[] COMMAND_DONT = {
                                             (byte)TelnetCommand.IAC, (byte)TelnetCommand.DONT
                                         };
 
-    static final byte[] _COMMAND_WILL = {
+    static final byte[] COMMAND_WILL = {
                                             (byte)TelnetCommand.IAC, (byte)TelnetCommand.WILL
                                         };
 
-    static final byte[] _COMMAND_WONT = {
+    static final byte[] COMMAND_WONT = {
                                             (byte)TelnetCommand.IAC, (byte)TelnetCommand.WONT
                                         };
 
-    static final byte[] _COMMAND_SB = {
+    static final byte[] COMMAND_SB = {
                                           (byte)TelnetCommand.IAC, (byte)TelnetCommand.SB
                                       };
 
-    static final byte[] _COMMAND_SE = {
+    static final byte[] COMMAND_SE = {
                                           (byte)TelnetCommand.IAC, (byte)TelnetCommand.SE
                                       };
 
-    static final int _WILL_MASK = 0x01, _DO_MASK = 0x02,
-                                  _REQUESTED_WILL_MASK = 0x04, _REQUESTED_DO_MASK = 0x08;
+    static final int WILL_MASK = 0x01, DO_MASK = 0x02,
+                                  REQUESTED_WILL_MASK = 0x04, REQUESTED_DO_MASK = 0x08;
 
     /* public */
     static final int DEFAULT_PORT =  23;
@@ -82,7 +82,7 @@ class Telnet extends SocketClient
     /***
      * Is sequence (for subnegotiation)
      ***/
-    static final byte[] _COMMAND_IS = {
+    static final byte[] COMMAND_IS = {
                                           (byte) TERMINAL_TYPE, (byte) TERMINAL_TYPE_IS
                                       };
 
@@ -104,7 +104,7 @@ class Telnet extends SocketClient
     /***
      * AYT sequence
      ***/
-    static final byte[] _COMMAND_AYT = {
+    static final byte[] COMMAND_AYT = {
                                           (byte) TelnetCommand.IAC, (byte) TelnetCommand.AYT
                                        };
 
@@ -168,7 +168,7 @@ class Telnet extends SocketClient
      ***/
     boolean stateIsWill(final int option)
     {
-        return (options[option] & _WILL_MASK) != 0;
+        return (options[option] & WILL_MASK) != 0;
     }
 
     /***
@@ -192,7 +192,7 @@ class Telnet extends SocketClient
      ***/
     boolean stateIsDo(final int option)
     {
-        return (options[option] & _DO_MASK) != 0;
+        return (options[option] & DO_MASK) != 0;
     }
 
     /***
@@ -216,7 +216,7 @@ class Telnet extends SocketClient
      ***/
     boolean requestedWill(final int option)
     {
-        return (options[option] & _REQUESTED_WILL_MASK) != 0;
+        return (options[option] & REQUESTED_WILL_MASK) != 0;
     }
 
     /***
@@ -240,7 +240,7 @@ class Telnet extends SocketClient
      ***/
     boolean requestedDo(final int option)
     {
-        return (options[option] & _REQUESTED_DO_MASK) != 0;
+        return (options[option] & REQUESTED_DO_MASK) != 0;
     }
 
     /***
@@ -263,7 +263,7 @@ class Telnet extends SocketClient
      ***/
     void setWill(final int option) throws IOException
     {
-        options[option] |= _WILL_MASK;
+        options[option] |= WILL_MASK;
 
         /* open TelnetOptionHandler functionality (start)*/
         if (requestedWill(option))
@@ -292,7 +292,7 @@ class Telnet extends SocketClient
      ***/
     void setDo(final int option) throws IOException
     {
-        options[option] |= _DO_MASK;
+        options[option] |= DO_MASK;
 
         /* open TelnetOptionHandler functionality (start)*/
         if (requestedDo(option))
@@ -320,7 +320,7 @@ class Telnet extends SocketClient
      ***/
     void setWantWill(final int option)
     {
-        options[option] |= _REQUESTED_WILL_MASK;
+        options[option] |= REQUESTED_WILL_MASK;
     }
 
     /***
@@ -330,7 +330,7 @@ class Telnet extends SocketClient
      ***/
     void setWantDo(final int option)
     {
-        options[option] |= _REQUESTED_DO_MASK;
+        options[option] |= REQUESTED_DO_MASK;
     }
 
     /***
@@ -340,7 +340,7 @@ class Telnet extends SocketClient
      ***/
     void setWont(final int option)
     {
-        options[option] &= ~_WILL_MASK;
+        options[option] &= ~WILL_MASK;
 
         /* open TelnetOptionHandler functionality (start)*/
         if (optionHandlers[option] != null)
@@ -357,7 +357,7 @@ class Telnet extends SocketClient
      ***/
     void setDont(final int option)
     {
-        options[option] &= ~_DO_MASK;
+        options[option] &= ~DO_MASK;
 
         /* open TelnetOptionHandler functionality (start)*/
         if (optionHandlers[option] != null)
@@ -374,7 +374,7 @@ class Telnet extends SocketClient
      ***/
     void setWantWont(final int option)
     {
-        options[option] &= ~_REQUESTED_WILL_MASK;
+        options[option] &= ~REQUESTED_WILL_MASK;
     }
 
     /***
@@ -384,7 +384,7 @@ class Telnet extends SocketClient
      ***/
     void setWantDont(final int option)
     {
-        options[option] &= ~_REQUESTED_DO_MASK;
+        options[option] &= ~REQUESTED_DO_MASK;
     }
 
     /**
@@ -739,10 +739,10 @@ class Telnet extends SocketClient
         }
         if (terminalType != null)
         {
-            _output_.write(_COMMAND_SB);
-            _output_.write(_COMMAND_IS);
+            _output_.write(COMMAND_SB);
+            _output_.write(COMMAND_IS);
             _output_.write(terminalType.getBytes(getCharset()));
-            _output_.write(_COMMAND_SE);
+            _output_.write(COMMAND_SE);
             _output_.flush();
         }
     }
@@ -769,7 +769,7 @@ class Telnet extends SocketClient
         }
         if (subn != null)
         {
-            _output_.write(_COMMAND_SB);
+            _output_.write(COMMAND_SB);
             // Note _output_ is buffered, so might as well simplify by writing single bytes
             for (final int element : subn)
             {
@@ -779,7 +779,7 @@ class Telnet extends SocketClient
                 }
                 _output_.write(b);
             }
-            _output_.write(_COMMAND_SE);
+            _output_.write(COMMAND_SE);
 
             /* Code Section added for sending the negotiation ASAP (start)*/
             _output_.flush();
@@ -877,7 +877,7 @@ class Telnet extends SocketClient
         {
             System.err.println("DO: " + TelnetOption.getOption(option));
         }
-        _output_.write(_COMMAND_DO);
+        _output_.write(COMMAND_DO);
         _output_.write(option);
 
         /* Code Section added for sending the negotiation ASAP (start)*/
@@ -917,7 +917,7 @@ class Telnet extends SocketClient
         {
             System.err.println("DONT: " + TelnetOption.getOption(option));
         }
-        _output_.write(_COMMAND_DONT);
+        _output_.write(COMMAND_DONT);
         _output_.write(option);
 
         /* Code Section added for sending the negotiation ASAP (start)*/
@@ -958,7 +958,7 @@ class Telnet extends SocketClient
         {
             System.err.println("WILL: " + TelnetOption.getOption(option));
         }
-        _output_.write(_COMMAND_WILL);
+        _output_.write(COMMAND_WILL);
         _output_.write(option);
 
         /* Code Section added for sending the negotiation ASAP (start)*/
@@ -998,7 +998,7 @@ class Telnet extends SocketClient
         {
             System.err.println("WONT: " + TelnetOption.getOption(option));
         }
-        _output_.write(_COMMAND_WONT);
+        _output_.write(COMMAND_WONT);
         _output_.write(option);
 
         /* Code Section added for sending the negotiation ASAP (start)*/
@@ -1061,7 +1061,7 @@ class Telnet extends SocketClient
             synchronized (this)
             {
                 aytFlag = false;
-                _output_.write(_COMMAND_AYT);
+                _output_.write(COMMAND_AYT);
                 _output_.flush();
             }
             aytMonitor.wait(timeout);
diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetClient.java b/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
index a889eac..a2b37d1 100644
--- a/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
+++ b/src/main/java/org/apache/commons/net/telnet/TelnetClient.java
@@ -129,7 +129,7 @@ public class TelnetClient extends Telnet
         final TelnetInputStream tmp = new TelnetInputStream(_input_, this, readerThread);
         if(readerThread)
         {
-            tmp._start();
+            tmp.start();
         }
         // __input CANNOT refer to the TelnetInputStream.  We run into
         // blocking problems when some classes use TelnetInputStream, so
diff --git a/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java b/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
index 2e7ef38..783cafb 100644
--- a/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
+++ b/src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java
@@ -80,7 +80,7 @@ final class TelnetInputStream extends BufferedInputStream implements Runnable
         this(input, client, true);
     }
 
-    void _start()
+    void start()
     {
         if(thread == null) {
             return;
@@ -116,7 +116,7 @@ final class TelnetInputStream extends BufferedInputStream implements Runnable
      * or -1 (EOF) if end of stread reached,
      * or -2 (WOULD_BLOCK) if mayBlock is false and there is no data available
      */
-    private int __read(final boolean mayBlock) throws IOException
+    private int read(final boolean mayBlock) throws IOException
     {
         int ch;
 
@@ -400,7 +400,7 @@ final class TelnetInputStream extends BufferedInputStream implements Runnable
                         {
                             try
                             {
-                                if ((ch = __read(mayBlock)) < 0) { // must be EOF
+                                if ((ch = read(mayBlock)) < 0) { // must be EOF
                                     if(ch != WOULD_BLOCK) {
                                         return ch;
                                     }
@@ -597,7 +597,7 @@ _outerLoop:
             {
                 try
                 {
-                    if ((ch = __read(true)) < 0) {
+                    if ((ch = read(true)) < 0) {
                         break;
                     }
                 }
diff --git a/src/main/java/org/apache/commons/net/tftp/TFTP.java b/src/main/java/org/apache/commons/net/tftp/TFTP.java
index ac7c205..9025fc7 100644
--- a/src/main/java/org/apache/commons/net/tftp/TFTP.java
+++ b/src/main/java/org/apache/commons/net/tftp/TFTP.java
@@ -117,7 +117,7 @@ public class TFTP extends DatagramSocketClient
      ***/
     public static final String getModeName(final int mode)
     {
-        return TFTPRequestPacket._modeStrings[mode];
+        return TFTPRequestPacket.modeStrings[mode];
     }
 
     /***
@@ -227,7 +227,7 @@ public class TFTP extends DatagramSocketClient
     public final void bufferedSend(final TFTPPacket packet) throws IOException
     {
         trace(">", packet);
-        _socket_.send(packet._newDatagram(sendDatagram, sendBuffer));
+        _socket_.send(packet.newDatagram(sendDatagram, sendBuffer));
     }
 
 
diff --git a/src/main/java/org/apache/commons/net/tftp/TFTPAckPacket.java b/src/main/java/org/apache/commons/net/tftp/TFTPAckPacket.java
index 7317a07..0298250 100644
--- a/src/main/java/org/apache/commons/net/tftp/TFTPAckPacket.java
+++ b/src/main/java/org/apache/commons/net/tftp/TFTPAckPacket.java
@@ -96,7 +96,7 @@ public final class TFTPAckPacket extends TFTPPacket
      * @return The datagram argument.
      ***/
     @Override
-    DatagramPacket _newDatagram(final DatagramPacket datagram, final byte[] data)
+    DatagramPacket newDatagram(final DatagramPacket datagram, final byte[] data)
     {
         data[0] = 0;
         data[1] = (byte)type;
diff --git a/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java b/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java
index f542388..bfeb39b 100644
--- a/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java
+++ b/src/main/java/org/apache/commons/net/tftp/TFTPDataPacket.java
@@ -140,7 +140,7 @@ public final class TFTPDataPacket extends TFTPPacket
      * @return The datagram argument.
      ***/
     @Override
-    DatagramPacket _newDatagram(final DatagramPacket datagram, final byte[] data)
+    DatagramPacket newDatagram(final DatagramPacket datagram, final byte[] data)
     {
         data[0] = 0;
         data[1] = (byte)type;
diff --git a/src/main/java/org/apache/commons/net/tftp/TFTPErrorPacket.java b/src/main/java/org/apache/commons/net/tftp/TFTPErrorPacket.java
index 4c93cad..e2956eb 100644
--- a/src/main/java/org/apache/commons/net/tftp/TFTPErrorPacket.java
+++ b/src/main/java/org/apache/commons/net/tftp/TFTPErrorPacket.java
@@ -146,7 +146,7 @@ public final class TFTPErrorPacket extends TFTPPacket
      * @return The datagram argument.
      ***/
     @Override
-    DatagramPacket _newDatagram(final DatagramPacket datagram, final byte[] data)
+    DatagramPacket newDatagram(final DatagramPacket datagram, final byte[] data)
     {
         int length;
 
diff --git a/src/main/java/org/apache/commons/net/tftp/TFTPPacket.java b/src/main/java/org/apache/commons/net/tftp/TFTPPacket.java
index 0fa9ebd..74f4a35 100644
--- a/src/main/java/org/apache/commons/net/tftp/TFTPPacket.java
+++ b/src/main/java/org/apache/commons/net/tftp/TFTPPacket.java
@@ -185,7 +185,7 @@ public abstract class TFTPPacket
      * @param data The buffer to store the packet and to use in the datagram.
      * @return The datagram argument.
      ***/
-    abstract DatagramPacket _newDatagram(DatagramPacket datagram, byte[] data);
+    abstract DatagramPacket newDatagram(DatagramPacket datagram, byte[] data);
 
     /***
      * Creates a UDP datagram containing all the TFTP packet
diff --git a/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java b/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
index c9f0be9..4348555 100644
--- a/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
+++ b/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
@@ -53,7 +53,7 @@ public abstract class TFTPRequestPacket extends TFTPPacket
      * An array containing the string names of the transfer modes and indexed
      * by the transfer mode constants.
      ***/
-    static final String[] _modeStrings = { "netascii", "octet" };
+    static final String[] modeStrings = { "netascii", "octet" };
 
     /***
      * A null terminated byte array representation of the ascii names of the
@@ -141,12 +141,12 @@ public abstract class TFTPRequestPacket extends TFTPPacket
         }
 
         final String modeString = buffer.toString().toLowerCase(java.util.Locale.ENGLISH);
-        length = _modeStrings.length;
+        length = modeStrings.length;
 
         int mode = 0;
         for (index = 0; index < length; index++)
         {
-            if (modeString.equals(_modeStrings[index]))
+            if (modeString.equals(modeStrings[index]))
             {
                 mode = index;
                 break;
@@ -177,7 +177,7 @@ public abstract class TFTPRequestPacket extends TFTPPacket
      * @return The datagram argument.
      ***/
     @Override
-    final DatagramPacket _newDatagram(final DatagramPacket datagram, final byte[] data)
+    final DatagramPacket newDatagram(final DatagramPacket datagram, final byte[] data)
     {
         int fileLength, modeLength;