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/09/20 19:05:03 UTC
[commons-net] 07/09: Use final.
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
commit 75203979592aefd409775ae843225deb4035f4b3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Sep 20 15:00:34 2020 -0400
Use final.
---
.../apache/commons/net/DatagramSocketClient.java | 12 +-
.../commons/net/DefaultDatagramSocketFactory.java | 4 +-
.../apache/commons/net/DefaultSocketFactory.java | 30 +-
.../commons/net/MalformedServerReplyException.java | 2 +-
.../apache/commons/net/PrintCommandListener.java | 28 +-
.../apache/commons/net/ProtocolCommandEvent.java | 4 +-
.../apache/commons/net/ProtocolCommandSupport.java | 14 +-
.../java/org/apache/commons/net/SocketClient.java | 64 ++---
.../org/apache/commons/net/bsd/RCommandClient.java | 30 +-
.../org/apache/commons/net/bsd/RExecClient.java | 12 +-
.../org/apache/commons/net/bsd/RLoginClient.java | 8 +-
.../commons/net/chargen/CharGenUDPClient.java | 4 +-
.../commons/net/daytime/DaytimeTCPClient.java | 2 +-
.../commons/net/daytime/DaytimeUDPClient.java | 4 +-
.../commons/net/discard/DiscardUDPClient.java | 6 +-
.../org/apache/commons/net/echo/EchoUDPClient.java | 8 +-
.../java/org/apache/commons/net/examples/Main.java | 19 +-
.../net/examples/cidr/SubnetUtilsExample.java | 12 +-
.../commons/net/examples/ftp/FTPClientExample.java | 45 +--
.../net/examples/ftp/ServerToServerFTP.java | 16 +-
.../commons/net/examples/ftp/TFTPExample.java | 36 +--
.../commons/net/examples/mail/IMAPExportMbox.java | 50 ++--
.../commons/net/examples/mail/IMAPImportMbox.java | 42 +--
.../apache/commons/net/examples/mail/IMAPMail.java | 6 +-
.../commons/net/examples/mail/IMAPUtils.java | 8 +-
.../commons/net/examples/mail/POP3ExportMbox.java | 44 +--
.../apache/commons/net/examples/mail/POP3Mail.java | 30 +-
.../apache/commons/net/examples/mail/SMTPMail.java | 10 +-
.../apache/commons/net/examples/mail/Utils.java | 8 +-
.../commons/net/examples/nntp/ArticleReader.java | 20 +-
.../commons/net/examples/nntp/ExtendedNNTPOps.java | 24 +-
.../commons/net/examples/nntp/ListNewsgroups.java | 16 +-
.../net/examples/nntp/MessageThreading.java | 28 +-
.../commons/net/examples/nntp/NNTPUtils.java | 8 +-
.../commons/net/examples/nntp/PostMessage.java | 8 +-
.../apache/commons/net/examples/ntp/NTPClient.java | 56 ++--
.../commons/net/examples/ntp/SimpleNTPServer.java | 22 +-
.../commons/net/examples/ntp/TimeClient.java | 14 +-
.../net/examples/telnet/TelnetClientExample.java | 64 ++---
.../commons/net/examples/telnet/WeatherTelnet.java | 6 +-
.../apache/commons/net/examples/unix/chargen.java | 16 +-
.../apache/commons/net/examples/unix/daytime.java | 14 +-
.../org/apache/commons/net/examples/unix/echo.java | 16 +-
.../apache/commons/net/examples/unix/finger.java | 12 +-
.../apache/commons/net/examples/unix/fwhois.java | 6 +-
.../apache/commons/net/examples/unix/rdate.java | 14 +-
.../apache/commons/net/examples/unix/rexec.java | 10 +-
.../apache/commons/net/examples/unix/rlogin.java | 10 +-
.../apache/commons/net/examples/unix/rshell.java | 10 +-
.../apache/commons/net/examples/util/IOUtil.java | 6 +-
.../apache/commons/net/finger/FingerClient.java | 16 +-
src/main/java/org/apache/commons/net/ftp/FTP.java | 122 ++++----
.../java/org/apache/commons/net/ftp/FTPClient.java | 316 ++++++++++-----------
.../apache/commons/net/ftp/FTPClientConfig.java | 72 ++---
.../org/apache/commons/net/ftp/FTPCommand.java | 4 +-
.../net/ftp/FTPConnectionClosedException.java | 2 +-
.../java/org/apache/commons/net/ftp/FTPFile.java | 38 +--
.../commons/net/ftp/FTPFileEntryParserImpl.java | 4 +-
.../org/apache/commons/net/ftp/FTPFileFilters.java | 6 +-
.../org/apache/commons/net/ftp/FTPHTTPClient.java | 40 +--
.../apache/commons/net/ftp/FTPListParseEngine.java | 32 +--
.../java/org/apache/commons/net/ftp/FTPReply.java | 12 +-
.../org/apache/commons/net/ftp/FTPSClient.java | 86 +++---
.../org/apache/commons/net/ftp/FTPSCommand.java | 2 +-
.../commons/net/ftp/FTPSServerSocketFactory.java | 10 +-
.../apache/commons/net/ftp/FTPSSocketFactory.java | 18 +-
.../apache/commons/net/ftp/FTPSTrustManager.java | 6 +-
.../net/ftp/parser/CompositeFileEntryParser.java | 10 +-
.../parser/ConfigurableFTPFileEntryParserImpl.java | 10 +-
.../parser/DefaultFTPFileEntryParserFactory.java | 24 +-
.../ftp/parser/EnterpriseUnixFTPEntryParser.java | 32 +--
.../net/ftp/parser/FTPTimestampParserImpl.java | 46 +--
.../commons/net/ftp/parser/MLSxEntryParser.java | 46 +--
.../commons/net/ftp/parser/MVSFTPEntryParser.java | 40 +--
.../net/ftp/parser/MacOsPeterFTPEntryParser.java | 30 +-
.../commons/net/ftp/parser/NTFTPEntryParser.java | 20 +-
.../net/ftp/parser/NetwareFTPEntryParser.java | 20 +-
.../commons/net/ftp/parser/OS2FTPEntryParser.java | 18 +-
.../net/ftp/parser/OS400FTPEntryParser.java | 20 +-
.../ftp/parser/ParserInitializationException.java | 4 +-
.../ftp/parser/RegexFTPFileEntryParserImpl.java | 12 +-
.../commons/net/ftp/parser/UnixFTPEntryParser.java | 38 +--
.../commons/net/ftp/parser/VMSFTPEntryParser.java | 32 +--
.../ftp/parser/VMSVersioningFTPEntryParser.java | 34 +--
.../commons/net/imap/AuthenticatingIMAPClient.java | 46 +--
.../java/org/apache/commons/net/imap/IMAP.java | 44 +--
.../org/apache/commons/net/imap/IMAPClient.java | 44 +--
.../org/apache/commons/net/imap/IMAPCommand.java | 12 +-
.../org/apache/commons/net/imap/IMAPReply.java | 22 +-
.../org/apache/commons/net/imap/IMAPSClient.java | 32 +--
.../org/apache/commons/net/io/CRLFLineReader.java | 6 +-
.../apache/commons/net/io/CopyStreamAdapter.java | 14 +-
.../org/apache/commons/net/io/CopyStreamEvent.java | 4 +-
.../apache/commons/net/io/CopyStreamException.java | 6 +-
.../commons/net/io/DotTerminatedMessageReader.java | 12 +-
.../commons/net/io/DotTerminatedMessageWriter.java | 12 +-
.../commons/net/io/FromNetASCIIInputStream.java | 8 +-
.../commons/net/io/FromNetASCIIOutputStream.java | 10 +-
.../apache/commons/net/io/SocketInputStream.java | 2 +-
.../apache/commons/net/io/SocketOutputStream.java | 4 +-
.../commons/net/io/ToNetASCIIInputStream.java | 6 +-
.../commons/net/io/ToNetASCIIOutputStream.java | 8 +-
src/main/java/org/apache/commons/net/io/Util.java | 52 ++--
.../java/org/apache/commons/net/nntp/Article.java | 34 +--
.../apache/commons/net/nntp/ArticleIterator.java | 4 +-
.../java/org/apache/commons/net/nntp/NNTP.java | 70 ++---
.../org/apache/commons/net/nntp/NNTPClient.java | 234 +++++++--------
.../org/apache/commons/net/nntp/NNTPCommand.java | 2 +-
.../net/nntp/NNTPConnectionClosedException.java | 2 +-
.../org/apache/commons/net/nntp/NNTPReply.java | 10 +-
.../commons/net/nntp/NewGroupsOrNewsQuery.java | 8 +-
.../org/apache/commons/net/nntp/NewsgroupInfo.java | 10 +-
.../apache/commons/net/nntp/NewsgroupIterator.java | 4 +-
.../org/apache/commons/net/nntp/ReplyIterator.java | 8 +-
.../apache/commons/net/nntp/SimpleNNTPHeader.java | 8 +-
.../apache/commons/net/nntp/ThreadContainer.java | 2 +-
.../java/org/apache/commons/net/nntp/Threader.java | 44 +--
.../org/apache/commons/net/ntp/NTPUDPClient.java | 20 +-
.../java/org/apache/commons/net/ntp/NtpUtils.java | 16 +-
.../java/org/apache/commons/net/ntp/NtpV3Impl.java | 74 ++---
.../java/org/apache/commons/net/ntp/TimeInfo.java | 32 +--
.../java/org/apache/commons/net/ntp/TimeStamp.java | 50 ++--
.../commons/net/pop3/ExtendedPOP3Client.java | 22 +-
.../java/org/apache/commons/net/pop3/POP3.java | 20 +-
.../org/apache/commons/net/pop3/POP3Client.java | 30 +-
.../org/apache/commons/net/pop3/POP3Command.java | 2 +-
.../apache/commons/net/pop3/POP3MessageInfo.java | 6 +-
.../org/apache/commons/net/pop3/POP3SClient.java | 32 +--
.../commons/net/smtp/AuthenticatingSMTPClient.java | 42 +--
.../org/apache/commons/net/smtp/RelayPath.java | 6 +-
.../java/org/apache/commons/net/smtp/SMTP.java | 44 +--
.../org/apache/commons/net/smtp/SMTPClient.java | 26 +-
.../org/apache/commons/net/smtp/SMTPCommand.java | 2 +-
.../net/smtp/SMTPConnectionClosedException.java | 2 +-
.../org/apache/commons/net/smtp/SMTPReply.java | 10 +-
.../org/apache/commons/net/smtp/SMTPSClient.java | 32 +--
.../apache/commons/net/smtp/SimpleSMTPHeader.java | 8 +-
.../commons/net/telnet/EchoOptionHandler.java | 4 +-
.../net/telnet/InvalidTelnetOptionException.java | 2 +-
.../commons/net/telnet/SimpleOptionHandler.java | 12 +-
.../net/telnet/SuppressGAOptionHandler.java | 4 +-
.../java/org/apache/commons/net/telnet/Telnet.java | 104 +++----
.../apache/commons/net/telnet/TelnetClient.java | 30 +-
.../apache/commons/net/telnet/TelnetCommand.java | 4 +-
.../commons/net/telnet/TelnetInputStream.java | 34 +--
.../apache/commons/net/telnet/TelnetOption.java | 4 +-
.../commons/net/telnet/TelnetOptionHandler.java | 24 +-
.../commons/net/telnet/TelnetOutputStream.java | 6 +-
.../net/telnet/TerminalTypeOptionHandler.java | 16 +-
.../net/telnet/WindowSizeOptionHandler.java | 20 +-
.../java/org/apache/commons/net/tftp/TFTP.java | 16 +-
.../org/apache/commons/net/tftp/TFTPAckPacket.java | 8 +-
.../org/apache/commons/net/tftp/TFTPClient.java | 70 ++---
.../apache/commons/net/tftp/TFTPDataPacket.java | 16 +-
.../apache/commons/net/tftp/TFTPErrorPacket.java | 8 +-
.../org/apache/commons/net/tftp/TFTPPacket.java | 8 +-
.../commons/net/tftp/TFTPPacketException.java | 2 +-
.../commons/net/tftp/TFTPReadRequestPacket.java | 6 +-
.../apache/commons/net/tftp/TFTPRequestPacket.java | 14 +-
.../commons/net/tftp/TFTPWriteRequestPacket.java | 6 +-
.../org/apache/commons/net/time/TimeUDPClient.java | 8 +-
.../java/org/apache/commons/net/util/Base64.java | 110 +++----
.../java/org/apache/commons/net/util/Charsets.java | 4 +-
.../apache/commons/net/util/KeyManagerUtils.java | 42 +--
.../org/apache/commons/net/util/ListenerList.java | 4 +-
.../apache/commons/net/util/SSLContextUtils.java | 8 +-
.../apache/commons/net/util/SSLSocketUtils.java | 24 +-
.../org/apache/commons/net/util/SubnetUtils.java | 52 ++--
.../apache/commons/net/util/TrustManagerUtils.java | 14 +-
.../org/apache/commons/net/whois/WhoisClient.java | 4 +-
.../commons/net/SocketClientFunctionalTest.java | 4 +-
.../org/apache/commons/net/SocketClientTest.java | 4 +-
.../org/apache/commons/net/SubnetUtilsTest.java | 76 ++---
.../org/apache/commons/net/examples/MainTest.java | 36 +--
.../net/ftp/FTPClientConfigFunctionalTest.java | 28 +-
.../commons/net/ftp/FTPClientConfigTest.java | 44 +--
.../org/apache/commons/net/ftp/FTPClientTest.java | 36 +--
.../org/apache/commons/net/ftp/FTPCommandTest.java | 2 +-
.../org/apache/commons/net/ftp/FTPSClientTest.java | 12 +-
.../commons/net/ftp/ListingFunctionalTest.java | 70 ++---
.../apache/commons/net/ftp/TestConnectTimeout.java | 8 +-
.../ftp/parser/CompositeFTPParseTestFramework.java | 30 +-
.../DefaultFTPFileEntryParserFactoryTest.java | 28 +-
.../commons/net/ftp/parser/DownloadListings.java | 30 +-
.../parser/EnterpriseUnixFTPEntryParserTest.java | 10 +-
.../net/ftp/parser/FTPConfigEntryParserTest.java | 16 +-
.../net/ftp/parser/FTPParseTestFramework.java | 30 +-
.../net/ftp/parser/FTPTimestampParserImplTest.java | 192 ++++++-------
.../commons/net/ftp/parser/MLSDComparison.java | 70 ++---
.../net/ftp/parser/MLSxEntryParserTest.java | 4 +-
.../net/ftp/parser/MVSFTPEntryParserTest.java | 44 +--
.../ftp/parser/MacOsPeterFTPEntryParserTest.java | 12 +-
.../net/ftp/parser/NTFTPEntryParserTest.java | 32 +--
.../net/ftp/parser/NetwareFTPEntryParserTest.java | 12 +-
.../net/ftp/parser/OS2FTPEntryParserTest.java | 8 +-
.../parser/OS400FTPEntryParserAdditionalTest.java | 12 +-
.../net/ftp/parser/OS400FTPEntryParserTest.java | 16 +-
.../net/ftp/parser/UnixFTPEntryParserTest.java | 70 ++---
.../net/ftp/parser/VMSFTPEntryParserTest.java | 28 +-
.../java/org/apache/commons/net/imap/IMAPTest.java | 6 +-
.../commons/net/io/ToNetASCIIInputStreamTest.java | 20 +-
.../org/apache/commons/net/nntp/TestThreader.java | 24 +-
.../org/apache/commons/net/ntp/TestNtpClient.java | 22 +-
.../org/apache/commons/net/ntp/TestNtpPacket.java | 36 +--
.../org/apache/commons/net/ntp/TestTimeInfo.java | 36 +--
.../org/apache/commons/net/ntp/TimeStampTest.java | 26 +-
.../commons/net/pop3/POP3ClientCommandsTest.java | 26 +-
.../apache/commons/net/pop3/POP3ClientTest.java | 2 +-
.../commons/net/pop3/POP3ConstructorTest.java | 8 +-
.../commons/net/smtp/SimpleSMTPHeaderTestCase.java | 30 +-
.../commons/net/telnet/EchoOptionHandlerTest.java | 8 +-
.../net/telnet/SimpleOptionHandlerTest.java | 8 +-
.../net/telnet/SuppressGAOptionHandlerTest.java | 8 +-
.../net/telnet/TelnetClientFunctionalTest.java | 12 +-
.../commons/net/telnet/TelnetClientTest.java | 190 ++++++-------
.../commons/net/telnet/TelnetTestResponder.java | 12 +-
.../commons/net/telnet/TelnetTestSimpleServer.java | 14 +-
.../net/telnet/TerminalTypeOptionHandlerTest.java | 16 +-
.../net/telnet/WindowSizeOptionHandlerTest.java | 22 +-
.../org/apache/commons/net/tftp/TFTPServer.java | 98 +++----
.../apache/commons/net/tftp/TFTPServerMain.java | 18 +-
.../commons/net/tftp/TFTPServerPathTest.java | 38 +--
.../java/org/apache/commons/net/tftp/TFTPTest.java | 34 +--
.../apache/commons/net/time/TimeTCPClientTest.java | 14 +-
.../commons/net/time/TimeTestSimpleServer.java | 18 +-
.../org/apache/commons/net/util/Base64Test.java | 12 +-
.../java/org/apache/commons/net/util/UtilTest.java | 56 ++--
227 files changed, 2944 insertions(+), 2942 deletions(-)
diff --git a/src/main/java/org/apache/commons/net/DatagramSocketClient.java b/src/main/java/org/apache/commons/net/DatagramSocketClient.java
index 4273d2a..a39a80b 100644
--- a/src/main/java/org/apache/commons/net/DatagramSocketClient.java
+++ b/src/main/java/org/apache/commons/net/DatagramSocketClient.java
@@ -119,7 +119,7 @@ public abstract class DatagramSocketClient
* @throws SocketException If the socket could not be opened or the
* timeout could not be set.
***/
- public void open(int port) throws SocketException
+ public void open(final int port) throws SocketException
{
_socket_ = _socketFactory_.createDatagramSocket(port);
_socket_.setSoTimeout(_timeout_);
@@ -141,7 +141,7 @@ public abstract class DatagramSocketClient
* @throws SocketException If the socket could not be opened or the
* timeout could not be set.
***/
- public void open(int port, InetAddress laddr) throws SocketException
+ public void open(final int port, final InetAddress laddr) throws SocketException
{
_socket_ = _socketFactory_.createDatagramSocket(port, laddr);
_socket_.setSoTimeout(_timeout_);
@@ -188,7 +188,7 @@ public abstract class DatagramSocketClient
* @param timeout The timeout in milliseconds to use for the datagram socket
* connection.
***/
- public void setDefaultTimeout(int timeout)
+ public void setDefaultTimeout(final int timeout)
{
_timeout_ = timeout;
}
@@ -216,7 +216,7 @@ public abstract class DatagramSocketClient
* open datagram socket connection.
* @throws SocketException if an error setting the timeout
***/
- public void setSoTimeout(int timeout) throws SocketException
+ public void setSoTimeout(final int timeout) throws SocketException
{
_socket_.setSoTimeout(timeout);
}
@@ -272,7 +272,7 @@ public abstract class DatagramSocketClient
* @param factory The new DatagramSocketFactory the DatagramSocketClient
* should use.
***/
- public void setDatagramSocketFactory(DatagramSocketFactory factory)
+ public void setDatagramSocketFactory(final DatagramSocketFactory factory)
{
if (factory == null) {
_socketFactory_ = __DEFAULT_SOCKET_FACTORY;
@@ -309,7 +309,7 @@ public abstract class DatagramSocketClient
* @param charset the charset.
* @since 3.3
*/
- public void setCharset(Charset charset) {
+ public void setCharset(final Charset charset) {
this.charset = charset;
}
}
diff --git a/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java b/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
index 7ad1997..b215e91 100644
--- a/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
+++ b/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
@@ -56,7 +56,7 @@ public class DefaultDatagramSocketFactory implements DatagramSocketFactory
* @throws SocketException If the socket could not be created.
***/
@Override
- public DatagramSocket createDatagramSocket(int port) throws SocketException
+ public DatagramSocket createDatagramSocket(final int port) throws SocketException
{
return new DatagramSocket(port);
}
@@ -71,7 +71,7 @@ public class DefaultDatagramSocketFactory implements DatagramSocketFactory
* @throws SocketException If the socket could not be created.
***/
@Override
- public DatagramSocket createDatagramSocket(int port, InetAddress laddr)
+ public DatagramSocket createDatagramSocket(final int port, final InetAddress laddr)
throws SocketException
{
return new DatagramSocket(port, laddr);
diff --git a/src/main/java/org/apache/commons/net/DefaultSocketFactory.java b/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
index 3e68b75..4e5faac 100644
--- a/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
+++ b/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
@@ -59,7 +59,7 @@ public class DefaultSocketFactory extends SocketFactory
* @param proxy The Proxy to use when creating new Sockets.
* @since 3.2
*/
- public DefaultSocketFactory(Proxy proxy)
+ public DefaultSocketFactory(final Proxy proxy)
{
connProxy = proxy;
}
@@ -91,12 +91,12 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating the Socket.
***/
@Override
- public Socket createSocket(String host, int port)
+ public Socket createSocket(final String host, final int port)
throws UnknownHostException, IOException
{
if (connProxy != null)
{
- Socket s = new Socket(connProxy);
+ final Socket s = new Socket(connProxy);
s.connect(new InetSocketAddress(host, port));
return s;
}
@@ -112,12 +112,12 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating the Socket.
***/
@Override
- public Socket createSocket(InetAddress address, int port)
+ public Socket createSocket(final InetAddress address, final int port)
throws IOException
{
if (connProxy != null)
{
- Socket s = new Socket(connProxy);
+ final Socket s = new Socket(connProxy);
s.connect(new InetSocketAddress(address, port));
return s;
}
@@ -137,13 +137,13 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating the Socket.
***/
@Override
- public Socket createSocket(String host, int port,
- InetAddress localAddr, int localPort)
+ public Socket createSocket(final String host, final int port,
+ final InetAddress localAddr, final int localPort)
throws UnknownHostException, IOException
{
if (connProxy != null)
{
- Socket s = new Socket(connProxy);
+ final Socket s = new Socket(connProxy);
s.bind(new InetSocketAddress(localAddr, localPort));
s.connect(new InetSocketAddress(host, port));
return s;
@@ -163,13 +163,13 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating the Socket.
***/
@Override
- public Socket createSocket(InetAddress address, int port,
- InetAddress localAddr, int localPort)
+ public Socket createSocket(final InetAddress address, final int port,
+ final InetAddress localAddr, final int localPort)
throws IOException
{
if (connProxy != null)
{
- Socket s = new Socket(connProxy);
+ final Socket s = new Socket(connProxy);
s.bind(new InetSocketAddress(localAddr, localPort));
s.connect(new InetSocketAddress(address, port));
return s;
@@ -186,7 +186,7 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating
* the ServerSocket.
***/
- public ServerSocket createServerSocket(int port) throws IOException
+ public ServerSocket createServerSocket(final int port) throws IOException
{
return new ServerSocket(port);
}
@@ -202,7 +202,7 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating
* the ServerSocket.
***/
- public ServerSocket createServerSocket(int port, int backlog)
+ public ServerSocket createServerSocket(final int port, final int backlog)
throws IOException
{
return new ServerSocket(port, backlog);
@@ -221,8 +221,8 @@ public class DefaultSocketFactory extends SocketFactory
* @throws IOException If an I/O error occurs while creating
* the ServerSocket.
***/
- public ServerSocket createServerSocket(int port, int backlog,
- InetAddress bindAddr)
+ public ServerSocket createServerSocket(final int port, final int backlog,
+ final InetAddress bindAddr)
throws IOException
{
return new ServerSocket(port, backlog, bindAddr);
diff --git a/src/main/java/org/apache/commons/net/MalformedServerReplyException.java b/src/main/java/org/apache/commons/net/MalformedServerReplyException.java
index e5ade4e..15a8a03 100644
--- a/src/main/java/org/apache/commons/net/MalformedServerReplyException.java
+++ b/src/main/java/org/apache/commons/net/MalformedServerReplyException.java
@@ -48,7 +48,7 @@ public class MalformedServerReplyException extends IOException
*
* @param message The message explaining the reason for the exception.
***/
- public MalformedServerReplyException(String message)
+ public MalformedServerReplyException(final String message)
{
super(message);
}
diff --git a/src/main/java/org/apache/commons/net/PrintCommandListener.java b/src/main/java/org/apache/commons/net/PrintCommandListener.java
index 8fff4ed..1ccb1c7 100644
--- a/src/main/java/org/apache/commons/net/PrintCommandListener.java
+++ b/src/main/java/org/apache/commons/net/PrintCommandListener.java
@@ -42,7 +42,7 @@ public class PrintCommandListener implements ProtocolCommandListener
* e.g. System.out
* @since 3.0
*/
- public PrintCommandListener(PrintStream stream)
+ public PrintCommandListener(final PrintStream stream)
{
this(new PrintWriter(stream));
}
@@ -56,7 +56,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @since 3.0
*/
- public PrintCommandListener(PrintStream stream, boolean suppressLogin) {
+ public PrintCommandListener(final PrintStream stream, final boolean suppressLogin) {
this(new PrintWriter(stream), suppressLogin);
}
@@ -70,7 +70,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @since 3.0
*/
- public PrintCommandListener(PrintStream stream, boolean suppressLogin, char eolMarker) {
+ public PrintCommandListener(final PrintStream stream, final boolean suppressLogin, final char eolMarker) {
this(new PrintWriter(stream), suppressLogin, eolMarker);
}
@@ -85,7 +85,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @since 3.0
*/
- public PrintCommandListener(PrintStream stream, boolean suppressLogin, char eolMarker, boolean showDirection) {
+ public PrintCommandListener(final PrintStream stream, final boolean suppressLogin, final char eolMarker, final boolean showDirection) {
this(new PrintWriter(stream), suppressLogin, eolMarker, showDirection);
}
@@ -94,7 +94,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @param writer where to write the commands and responses
*/
- public PrintCommandListener(PrintWriter writer)
+ public PrintCommandListener(final PrintWriter writer)
{
this(writer, false);
}
@@ -107,7 +107,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @since 3.0
*/
- public PrintCommandListener(PrintWriter writer, boolean suppressLogin)
+ public PrintCommandListener(final PrintWriter writer, final boolean suppressLogin)
{
this(writer, suppressLogin, (char) 0);
}
@@ -122,7 +122,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @since 3.0
*/
- public PrintCommandListener(PrintWriter writer, boolean suppressLogin, char eolMarker)
+ public PrintCommandListener(final PrintWriter writer, final boolean suppressLogin, final char eolMarker)
{
this(writer, suppressLogin, eolMarker, false);
}
@@ -138,7 +138,7 @@ public class PrintCommandListener implements ProtocolCommandListener
*
* @since 3.0
*/
- public PrintCommandListener(PrintWriter writer, boolean suppressLogin, char eolMarker, boolean showDirection)
+ public PrintCommandListener(final PrintWriter writer, final boolean suppressLogin, final char eolMarker, final boolean showDirection)
{
__writer = writer;
__nologin = suppressLogin;
@@ -147,13 +147,13 @@ public class PrintCommandListener implements ProtocolCommandListener
}
@Override
- public void protocolCommandSent(ProtocolCommandEvent event)
+ public void protocolCommandSent(final ProtocolCommandEvent event)
{
if (__directionMarker) {
__writer.print("> ");
}
if (__nologin) {
- String cmd = event.getCommand();
+ final String cmd = event.getCommand();
if ("PASS".equalsIgnoreCase(cmd) || "USER".equalsIgnoreCase(cmd)) {
__writer.print(cmd);
__writer.println(" *******"); // Don't bother with EOL marker for this!
@@ -174,13 +174,13 @@ public class PrintCommandListener implements ProtocolCommandListener
__writer.flush();
}
- private String getPrintableString(String msg){
+ private String getPrintableString(final String msg){
if (__eolMarker == 0) {
return msg;
}
- int pos = msg.indexOf(SocketClient.NETASCII_EOL);
+ final int pos = msg.indexOf(SocketClient.NETASCII_EOL);
if (pos > 0) {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append(msg.substring(0,pos));
sb.append(__eolMarker);
sb.append(msg.substring(pos));
@@ -190,7 +190,7 @@ public class PrintCommandListener implements ProtocolCommandListener
}
@Override
- public void protocolReplyReceived(ProtocolCommandEvent event)
+ public void protocolReplyReceived(final ProtocolCommandEvent event)
{
if (__directionMarker) {
__writer.print("< ");
diff --git a/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java b/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
index d921c61..da9fce8 100644
--- a/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
+++ b/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
@@ -52,7 +52,7 @@ public class ProtocolCommandEvent extends EventObject
* @param message The entire command string verbatim as sent to the server,
* including all arguments.
***/
- public ProtocolCommandEvent(Object source, String command, String message)
+ public ProtocolCommandEvent(final Object source, final String command, final String message)
{
super(source);
__replyCode = 0;
@@ -76,7 +76,7 @@ public class ProtocolCommandEvent extends EventObject
* strings like OK rather than integer codes (i.e., POP3Repy.OK).
* @param message The entire reply as received from the server.
***/
- public ProtocolCommandEvent(Object source, int replyCode, String message)
+ public ProtocolCommandEvent(final Object source, final int replyCode, final String message)
{
super(source);
__replyCode = replyCode;
diff --git a/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java b/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
index 95611f0..3e1017d 100644
--- a/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
+++ b/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
@@ -46,7 +46,7 @@ public class ProtocolCommandSupport implements Serializable
*
* @param source The source to use for all generated ProtocolCommandEvents.
***/
- public ProtocolCommandSupport(Object source)
+ public ProtocolCommandSupport(final Object source)
{
__listeners = new ListenerList();
__source = source;
@@ -64,13 +64,13 @@ public class ProtocolCommandSupport implements Serializable
* @param message The entire command string verbatim as sent to the server,
* including all arguments.
***/
- public void fireCommandSent(String command, String message)
+ public void fireCommandSent(final String command, final String message)
{
ProtocolCommandEvent event;
event = new ProtocolCommandEvent(__source, command, message);
- for (EventListener listener : __listeners)
+ for (final EventListener listener : __listeners)
{
((ProtocolCommandListener)listener).protocolCommandSent(event);
}
@@ -89,12 +89,12 @@ public class ProtocolCommandSupport implements Serializable
* strings like OK rather than integer codes (i.e., POP3Repy.OK).
* @param message The entire reply as received from the server.
***/
- public void fireReplyReceived(int replyCode, String message)
+ public void fireReplyReceived(final int replyCode, final String message)
{
ProtocolCommandEvent event;
event = new ProtocolCommandEvent(__source, replyCode, message);
- for (EventListener listener : __listeners)
+ for (final EventListener listener : __listeners)
{
((ProtocolCommandListener)listener).protocolReplyReceived(event);
}
@@ -105,7 +105,7 @@ public class ProtocolCommandSupport implements Serializable
*
* @param listener The ProtocolCommandListener to add.
***/
- public void addProtocolCommandListener(ProtocolCommandListener listener)
+ public void addProtocolCommandListener(final ProtocolCommandListener listener)
{
__listeners.addListener(listener);
}
@@ -115,7 +115,7 @@ public class ProtocolCommandSupport implements Serializable
*
* @param listener The ProtocolCommandListener to remove.
***/
- public void removeProtocolCommandListener(ProtocolCommandListener listener)
+ public void removeProtocolCommandListener(final ProtocolCommandListener listener)
{
__listeners.removeListener(listener);
}
diff --git a/src/main/java/org/apache/commons/net/SocketClient.java b/src/main/java/org/apache/commons/net/SocketClient.java
index 6c938b5..4c854e5 100644
--- a/src/main/java/org/apache/commons/net/SocketClient.java
+++ b/src/main/java/org/apache/commons/net/SocketClient.java
@@ -174,7 +174,7 @@ public abstract class SocketClient
* cases you will only want to catch IOException since SocketException is
* derived from it.
*/
- public void connect(InetAddress host, int port)
+ public void connect(final InetAddress host, final int port)
throws SocketException, IOException
{
_hostname_ = null;
@@ -195,7 +195,7 @@ public abstract class SocketClient
* derived from it.
* @throws java.net.UnknownHostException If the hostname cannot be resolved.
*/
- public void connect(String hostname, int port)
+ public void connect(final String hostname, final int port)
throws SocketException, IOException
{
_hostname_ = hostname;
@@ -218,8 +218,8 @@ public abstract class SocketClient
* cases you will only want to catch IOException since SocketException is
* derived from it.
*/
- public void connect(InetAddress host, int port,
- InetAddress localAddr, int localPort)
+ public void connect(final InetAddress host, final int port,
+ final InetAddress localAddr, final int localPort)
throws SocketException, IOException
{
_hostname_ = null;
@@ -227,7 +227,7 @@ public abstract class SocketClient
}
// helper method to allow code to be shared with connect(String,...) methods
- private void _connect(InetAddress host, int port, InetAddress localAddr, int localPort)
+ private void _connect(final InetAddress host, final int port, final InetAddress localAddr, final int localPort)
throws SocketException, IOException
{
_socket_ = _socketFactory_.createSocket();
@@ -260,8 +260,8 @@ public abstract class SocketClient
* derived from it.
* @throws java.net.UnknownHostException If the hostname cannot be resolved.
*/
- public void connect(String hostname, int port,
- InetAddress localAddr, int localPort)
+ public void connect(final String hostname, final int port,
+ final InetAddress localAddr, final int localPort)
throws SocketException, IOException
{
_hostname_ = hostname;
@@ -281,7 +281,7 @@ public abstract class SocketClient
* cases you will only want to catch IOException since SocketException is
* derived from it.
*/
- public void connect(InetAddress host) throws SocketException, IOException
+ public void connect(final InetAddress host) throws SocketException, IOException
{
_hostname_ = null;
connect(host, _defaultPort_);
@@ -301,7 +301,7 @@ public abstract class SocketClient
* derived from it.
* @throws java.net.UnknownHostException If the hostname cannot be resolved.
*/
- public void connect(String hostname) throws SocketException, IOException
+ public void connect(final String hostname) throws SocketException, IOException
{
connect(hostname, _defaultPort_);
}
@@ -328,21 +328,21 @@ public abstract class SocketClient
_output_ = null;
}
- private void closeQuietly(Socket socket) {
+ private void closeQuietly(final Socket socket) {
if (socket != null){
try {
socket.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Ignored
}
}
}
- private void closeQuietly(Closeable close){
+ private void closeQuietly(final Closeable close){
if (close != null){
try {
close.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Ignored
}
}
@@ -400,7 +400,7 @@ public abstract class SocketClient
_socket_.getInputStream();
_socket_.getOutputStream();
}
- catch (IOException ioex)
+ catch (final IOException ioex)
{
return false;
}
@@ -418,7 +418,7 @@ public abstract class SocketClient
* <p>
* @param port The default port to set.
*/
- public void setDefaultPort(int port)
+ public void setDefaultPort(final int port)
{
_defaultPort_ = port;
}
@@ -446,7 +446,7 @@ public abstract class SocketClient
* @param timeout The timeout in milliseconds to use for the socket
* connection.
*/
- public void setDefaultTimeout(int timeout)
+ public void setDefaultTimeout(final int timeout)
{
_timeout_ = timeout;
}
@@ -477,7 +477,7 @@ public abstract class SocketClient
* @throws SocketException If the operation fails.
* @throws NullPointerException if the socket is not currently open
*/
- public void setSoTimeout(int timeout) throws SocketException
+ public void setSoTimeout(final int timeout) throws SocketException
{
_socket_.setSoTimeout(timeout);
}
@@ -490,7 +490,7 @@ public abstract class SocketClient
* @throws SocketException never thrown, but subclasses might want to do so
* @since 2.0
*/
- public void setSendBufferSize(int size) throws SocketException {
+ public void setSendBufferSize(final int size) throws SocketException {
sendBufferSize = size;
}
@@ -510,7 +510,7 @@ public abstract class SocketClient
* @throws SocketException never (but subclasses may wish to do so)
* @since 2.0
*/
- public void setReceiveBufferSize(int size) throws SocketException {
+ public void setReceiveBufferSize(final int size) throws SocketException {
receiveBufferSize = size;
}
@@ -543,7 +543,7 @@ public abstract class SocketClient
* @throws SocketException If the operation fails.
* @throws NullPointerException if the socket is not currently open
*/
- public void setTcpNoDelay(boolean on) throws SocketException
+ public void setTcpNoDelay(final boolean on) throws SocketException
{
_socket_.setTcpNoDelay(on);
}
@@ -575,7 +575,7 @@ public abstract class SocketClient
* @throws NullPointerException if the socket is not currently open
* @since 2.2
*/
- public void setKeepAlive(boolean keepAlive) throws SocketException {
+ public void setKeepAlive(final boolean keepAlive) throws SocketException {
_socket_.setKeepAlive(keepAlive);
}
@@ -599,7 +599,7 @@ public abstract class SocketClient
* @throws SocketException If the operation fails.
* @throws NullPointerException if the socket is not currently open
*/
- public void setSoLinger(boolean on, int val) throws SocketException
+ public void setSoLinger(final boolean on, final int val) throws SocketException
{
_socket_.setSoLinger(on, val);
}
@@ -682,7 +682,7 @@ public abstract class SocketClient
* @param socket the item to check against
* @return True if the remote hosts are the same, false if not.
*/
- public boolean verifyRemote(Socket socket)
+ public boolean verifyRemote(final Socket socket)
{
InetAddress host1, host2;
@@ -702,7 +702,7 @@ public abstract class SocketClient
* <p>
* @param factory The new SocketFactory the SocketClient should use.
*/
- public void setSocketFactory(SocketFactory factory)
+ public void setSocketFactory(final SocketFactory factory)
{
if (factory == null) {
_socketFactory_ = __DEFAULT_SOCKET_FACTORY;
@@ -724,7 +724,7 @@ public abstract class SocketClient
* @param factory The new ServerSocketFactory the SocketClient should use.
* @since 2.0
*/
- public void setServerSocketFactory(ServerSocketFactory factory) {
+ public void setServerSocketFactory(final ServerSocketFactory factory) {
if (factory == null) {
_serverSocketFactory_ = __DEFAULT_SERVER_SOCKET_FACTORY;
} else {
@@ -738,7 +738,7 @@ public abstract class SocketClient
* @param connectTimeout The connection timeout to use (in ms)
* @since 2.0
*/
- public void setConnectTimeout(int connectTimeout) {
+ public void setConnectTimeout(final int connectTimeout) {
this.connectTimeout = connectTimeout;
}
@@ -767,7 +767,7 @@ public abstract class SocketClient
* @param listener The ProtocolCommandListener to add.
* @since 3.0
*/
- public void addProtocolCommandListener(ProtocolCommandListener listener) {
+ public void addProtocolCommandListener(final ProtocolCommandListener listener) {
getCommandSupport().addProtocolCommandListener(listener);
}
@@ -777,7 +777,7 @@ public abstract class SocketClient
* @param listener The ProtocolCommandListener to remove.
* @since 3.0
*/
- public void removeProtocolCommandListener(ProtocolCommandListener listener) {
+ public void removeProtocolCommandListener(final ProtocolCommandListener listener) {
getCommandSupport().removeProtocolCommandListener(listener);
}
@@ -788,7 +788,7 @@ public abstract class SocketClient
* @param reply the full reply text
* @since 3.0
*/
- protected void fireReplyReceived(int replyCode, String reply) {
+ protected void fireReplyReceived(final int replyCode, final String reply) {
if (getCommandSupport().getListenerCount() > 0) {
getCommandSupport().fireReplyReceived(replyCode, reply);
}
@@ -801,7 +801,7 @@ public abstract class SocketClient
* @param message the complete message, including command name
* @since 3.0
*/
- protected void fireCommandSent(String command, String message) {
+ protected void fireCommandSent(final String command, final String message) {
if (getCommandSupport().getListenerCount() > 0) {
getCommandSupport().fireCommandSent(command, message);
}
@@ -833,7 +833,7 @@ public abstract class SocketClient
* @param proxy the new proxy for connections.
* @since 3.2
*/
- public void setProxy(Proxy proxy) {
+ public void setProxy(final Proxy proxy) {
setSocketFactory(new DefaultSocketFactory(proxy));
connProxy = proxy;
}
@@ -874,7 +874,7 @@ public abstract class SocketClient
* @param charset the charset.
* @since 3.3
*/
- public void setCharset(Charset charset) {
+ public void setCharset(final Charset charset) {
this.charset = charset;
}
diff --git a/src/main/java/org/apache/commons/net/bsd/RCommandClient.java b/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
index 6819cae..d6c313a 100644
--- a/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
+++ b/src/main/java/org/apache/commons/net/bsd/RCommandClient.java
@@ -123,7 +123,7 @@ public class RCommandClient extends RExecClient
getLocalAddress());
break; // got a socket
}
- catch (SocketException e)
+ catch (final SocketException e)
{
continue;
}
@@ -177,7 +177,7 @@ public class RCommandClient extends RExecClient
* cases you will only want to catch IOException since SocketException is
* derived from it.
***/
- public void connect(InetAddress host, int port, InetAddress localAddr)
+ public void connect(final InetAddress host, final int port, final InetAddress localAddr)
throws SocketException, BindException, IOException
{
int localPort;
@@ -191,10 +191,10 @@ public class RCommandClient extends RExecClient
_socket_ =
_socketFactory_.createSocket(host, port, localAddr, localPort);
}
- catch (BindException be) {
+ catch (final BindException be) {
continue;
}
- catch (SocketException e)
+ catch (final SocketException e)
{
continue;
}
@@ -226,7 +226,7 @@ public class RCommandClient extends RExecClient
* derived from it.
***/
@Override
- public void connect(InetAddress host, int port)
+ public void connect(final InetAddress host, final int port)
throws SocketException, IOException
{
connect(host, port, InetAddress.getLocalHost());
@@ -250,7 +250,7 @@ public class RCommandClient extends RExecClient
* @throws UnknownHostException If the hostname cannot be resolved.
***/
@Override
- public void connect(String hostname, int port)
+ public void connect(final String hostname, final int port)
throws SocketException, IOException, UnknownHostException
{
connect(InetAddress.getByName(hostname), port, InetAddress.getLocalHost());
@@ -273,7 +273,7 @@ public class RCommandClient extends RExecClient
* cases you will only want to catch IOException since SocketException is
* derived from it.
***/
- public void connect(String hostname, int port, InetAddress localAddr)
+ public void connect(final String hostname, final int port, final InetAddress localAddr)
throws SocketException, IOException
{
connect(InetAddress.getByName(hostname), port, localAddr);
@@ -301,8 +301,8 @@ public class RCommandClient extends RExecClient
* is specified.
***/
@Override
- public void connect(InetAddress host, int port,
- InetAddress localAddr, int localPort)
+ public void connect(final InetAddress host, final int port,
+ final InetAddress localAddr, final int localPort)
throws SocketException, IOException, IllegalArgumentException
{
if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) {
@@ -334,8 +334,8 @@ public class RCommandClient extends RExecClient
* is specified.
***/
@Override
- public void connect(String hostname, int port,
- InetAddress localAddr, int localPort)
+ public void connect(final String hostname, final int port,
+ final InetAddress localAddr, final int localPort)
throws SocketException, IOException, IllegalArgumentException, UnknownHostException
{
if (localPort < MIN_CLIENT_PORT || localPort > MAX_CLIENT_PORT) {
@@ -381,8 +381,8 @@ public class RCommandClient extends RExecClient
* @throws IOException If the rcommand() attempt fails. The exception
* will contain a message indicating the nature of the failure.
***/
- public void rcommand(String localUsername, String remoteUsername,
- String command, boolean separateErrorStream)
+ public void rcommand(final String localUsername, final String remoteUsername,
+ final String command, final boolean separateErrorStream)
throws IOException
{
rexec(localUsername, remoteUsername, command, separateErrorStream);
@@ -397,8 +397,8 @@ public class RCommandClient extends RExecClient
* @param command the command
* @throws IOException on error
***/
- public void rcommand(String localUsername, String remoteUsername,
- String command)
+ public void rcommand(final String localUsername, final String remoteUsername,
+ final String command)
throws IOException
{
rcommand(localUsername, remoteUsername, command, false);
diff --git a/src/main/java/org/apache/commons/net/bsd/RExecClient.java b/src/main/java/org/apache/commons/net/bsd/RExecClient.java
index 37f9fbd..7bc5a1a 100644
--- a/src/main/java/org/apache/commons/net/bsd/RExecClient.java
+++ b/src/main/java/org/apache/commons/net/bsd/RExecClient.java
@@ -199,8 +199,8 @@ public class RExecClient extends SocketClient
* @throws IOException If the rexec() attempt fails. The exception
* will contain a message indicating the nature of the failure.
***/
- public void rexec(String username, String password,
- String command, boolean separateErrorStream)
+ public void rexec(final String username, final String password,
+ final String command, final boolean separateErrorStream)
throws IOException
{
int ch;
@@ -224,7 +224,7 @@ public class RExecClient extends SocketClient
ch = _input_.read();
if (ch > 0) {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
while ((ch = _input_.read()) != -1 && ch != '\n') {
buffer.append((char)ch);
@@ -244,8 +244,8 @@ public class RExecClient extends SocketClient
* @param command the command to run
* @throws IOException if an error occurs
***/
- public void rexec(String username, String password,
- String command)
+ public void rexec(final String username, final String password,
+ final String command)
throws IOException
{
rexec(username, password, command, false);
@@ -277,7 +277,7 @@ public class RExecClient extends SocketClient
*
* @param enable True to enable verification, false to disable verification.
***/
- public final void setRemoteVerificationEnabled(boolean enable)
+ public final void setRemoteVerificationEnabled(final boolean enable)
{
__remoteVerificationEnabled = enable;
}
diff --git a/src/main/java/org/apache/commons/net/bsd/RLoginClient.java b/src/main/java/org/apache/commons/net/bsd/RLoginClient.java
index 9e60903..6599e48 100644
--- a/src/main/java/org/apache/commons/net/bsd/RLoginClient.java
+++ b/src/main/java/org/apache/commons/net/bsd/RLoginClient.java
@@ -108,8 +108,8 @@ public class RLoginClient extends RCommandClient
* @throws IOException If the rlogin() attempt fails. The exception
* will contain a message indicating the nature of the failure.
***/
- public void rlogin(String localUsername, String remoteUsername,
- String terminalType, int terminalSpeed)
+ public void rlogin(final String localUsername, final String remoteUsername,
+ final String terminalType, final int terminalSpeed)
throws IOException
{
rexec(localUsername, remoteUsername, terminalType + "/" + terminalSpeed,
@@ -123,8 +123,8 @@ public class RLoginClient extends RCommandClient
* @param terminalType the terminal type
* @throws IOException on error
***/
- public void rlogin(String localUsername, String remoteUsername,
- String terminalType)
+ public void rlogin(final String localUsername, final String remoteUsername,
+ final String terminalType)
throws IOException
{
rexec(localUsername, remoteUsername, terminalType, false);
diff --git a/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java b/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java
index 5b51965..a503eb7 100644
--- a/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java
+++ b/src/main/java/org/apache/commons/net/chargen/CharGenUDPClient.java
@@ -89,7 +89,7 @@ public final class CharGenUDPClient extends DatagramSocketClient
* @param port The port of the service.
* @throws IOException If an error occurs while sending the datagram.
***/
- public void send(InetAddress host, int port) throws IOException
+ public void send(final InetAddress host, final int port) throws IOException
{
__sendPacket.setAddress(host);
__sendPacket.setPort(port);
@@ -100,7 +100,7 @@ public final class CharGenUDPClient extends DatagramSocketClient
* @param host the destination host
* @throws IOException on error
***/
- public void send(InetAddress host) throws IOException
+ public void send(final InetAddress host) throws IOException
{
send(host, DEFAULT_PORT);
}
diff --git a/src/main/java/org/apache/commons/net/daytime/DaytimeTCPClient.java b/src/main/java/org/apache/commons/net/daytime/DaytimeTCPClient.java
index 033a776..6dfc195 100644
--- a/src/main/java/org/apache/commons/net/daytime/DaytimeTCPClient.java
+++ b/src/main/java/org/apache/commons/net/daytime/DaytimeTCPClient.java
@@ -68,7 +68,7 @@ public final class DaytimeTCPClient extends SocketClient
public String getTime() throws IOException
{
int read;
- StringBuilder result = new StringBuilder(__buffer.length);
+ final StringBuilder result = new StringBuilder(__buffer.length);
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(_input_, getCharset()));
diff --git a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
index 2dc8618..3f2d941 100644
--- a/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
+++ b/src/main/java/org/apache/commons/net/daytime/DaytimeUDPClient.java
@@ -56,7 +56,7 @@ public final class DaytimeUDPClient extends DatagramSocketClient
* @return The time string.
* @throws IOException If an error occurs while retrieving the time.
*/
- public String getTime(InetAddress host, int port) throws IOException
+ public String getTime(final InetAddress host, final int port) throws IOException
{
DatagramPacket sendPacket, receivePacket;
@@ -75,7 +75,7 @@ public final class DaytimeUDPClient extends DatagramSocketClient
* @return the time
* @throws IOException on error
*/
- public String getTime(InetAddress host) throws IOException
+ public String getTime(final InetAddress host) throws IOException
{
return getTime(host, DEFAULT_PORT);
}
diff --git a/src/main/java/org/apache/commons/net/discard/DiscardUDPClient.java b/src/main/java/org/apache/commons/net/discard/DiscardUDPClient.java
index e7c092d..65fd497 100644
--- a/src/main/java/org/apache/commons/net/discard/DiscardUDPClient.java
+++ b/src/main/java/org/apache/commons/net/discard/DiscardUDPClient.java
@@ -60,7 +60,7 @@ public class DiscardUDPClient extends DatagramSocketClient
* @throws IOException If an error occurs during the datagram send
* operation.
***/
- public void send(byte[] data, int length, InetAddress host, int port)
+ public void send(final byte[] data, final int length, final InetAddress host, final int port)
throws IOException
{
_sendPacket.setData(data);
@@ -80,7 +80,7 @@ public class DiscardUDPClient extends DatagramSocketClient
* @see #send(byte[], int, InetAddress, int)
* @throws IOException if an error occurs
***/
- public void send(byte[] data, int length, InetAddress host)
+ public void send(final byte[] data, final int length, final InetAddress host)
throws IOException
{
send(data, length, host, DEFAULT_PORT);
@@ -95,7 +95,7 @@ public class DiscardUDPClient extends DatagramSocketClient
* @see #send(byte[], int, InetAddress, int)
* @throws IOException if an error occurs
***/
- public void send(byte[] data, InetAddress host) throws IOException
+ public void send(final byte[] data, final InetAddress host) throws IOException
{
send(data, data.length, host, DEFAULT_PORT);
}
diff --git a/src/main/java/org/apache/commons/net/echo/EchoUDPClient.java b/src/main/java/org/apache/commons/net/echo/EchoUDPClient.java
index 96ab7df..723c514 100644
--- a/src/main/java/org/apache/commons/net/echo/EchoUDPClient.java
+++ b/src/main/java/org/apache/commons/net/echo/EchoUDPClient.java
@@ -57,7 +57,7 @@ public final class EchoUDPClient extends DiscardUDPClient
* operation.
***/
@Override
- public void send(byte[] data, int length, InetAddress host)
+ public void send(final byte[] data, final int length, final InetAddress host)
throws IOException
{
send(data, length, host, DEFAULT_PORT);
@@ -66,7 +66,7 @@ public final class EchoUDPClient extends DiscardUDPClient
/*** Same as <code> send(data, data.length, host) </code> ***/
@Override
- public void send(byte[] data, InetAddress host) throws IOException
+ public void send(final byte[] data, final InetAddress host) throws IOException
{
send(data, data.length, host, DEFAULT_PORT);
}
@@ -83,7 +83,7 @@ public final class EchoUDPClient extends DiscardUDPClient
* @return Length of actual data received.
* @throws IOException If an error occurs while receiving the data.
***/
- public int receive(byte[] data, int length) throws IOException
+ public int receive(final byte[] data, final int length) throws IOException
{
__receivePacket.setData(data);
__receivePacket.setLength(length);
@@ -96,7 +96,7 @@ public final class EchoUDPClient extends DiscardUDPClient
* @return the number of bytes
* @throws IOException on error
***/
- public int receive(byte[] data) throws IOException
+ public int receive(final byte[] data) throws IOException
{
return receive(data, data.length);
}
diff --git a/src/main/java/org/apache/commons/net/examples/Main.java b/src/main/java/org/apache/commons/net/examples/Main.java
index c6e1d6c..6c07163 100644
--- a/src/main/java/org/apache/commons/net/examples/Main.java
+++ b/src/main/java/org/apache/commons/net/examples/Main.java
@@ -41,7 +41,7 @@ public class Main {
* are passed to the target class.
* @throws Throwable if an error occurs
*/
- public static void main(String[] args) throws Throwable {
+ public static void main(final String[] args) throws Throwable {
final Properties fp = new Properties();
final InputStream ras = Main.class.getResourceAsStream("examples.properties");
if (ras != null) {
@@ -65,40 +65,41 @@ public class Main {
}
}
@SuppressWarnings("unchecked") // property names are Strings
+ final
List<String> l = (List<String>) Collections.list(fp.propertyNames());
if (l.isEmpty()) {
return;
}
Collections.sort(l);
System.out.println("\nAliases and their classes:");
- for(String s : l) {
+ for(final String s : l) {
System.out.printf("%-25s %s%n",s,fp.getProperty(s));
}
return;
}
- String shortName = args[0];
+ final String shortName = args[0];
String fullName = fp.getProperty(shortName);
if (fullName == null) {
fullName = shortName;
}
fullName = fullName.replace('/', '.');
try {
- Class<?> clazz = Class.forName(fullName);
- Method m = clazz.getDeclaredMethod("main", args.getClass());
- String[] args2 = new String[args.length-1];
+ final Class<?> clazz = Class.forName(fullName);
+ final Method m = clazz.getDeclaredMethod("main", args.getClass());
+ final String[] args2 = new String[args.length-1];
System.arraycopy(args, 1, args2, 0, args2.length);
try {
m.invoke(null, (Object)args2);
- } catch (InvocationTargetException ite) {
- Throwable cause = ite.getCause();
+ } catch (final InvocationTargetException ite) {
+ final Throwable cause = ite.getCause();
if (cause != null) {
throw cause;
} else {
throw ite;
}
}
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
System.out.println(e);
}
}
diff --git a/src/main/java/org/apache/commons/net/examples/cidr/SubnetUtilsExample.java b/src/main/java/org/apache/commons/net/examples/cidr/SubnetUtilsExample.java
index c12b649..57cb1b8 100644
--- a/src/main/java/org/apache/commons/net/examples/cidr/SubnetUtilsExample.java
+++ b/src/main/java/org/apache/commons/net/examples/cidr/SubnetUtilsExample.java
@@ -28,10 +28,10 @@ import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
*/
public class SubnetUtilsExample {
- public static void main(String[] args) {
- String subnet = "192.168.0.3/31";
- SubnetUtils utils = new SubnetUtils(subnet);
- SubnetInfo info = utils.getInfo();
+ public static void main(final String[] args) {
+ final String subnet = "192.168.0.3/31";
+ final SubnetUtils utils = new SubnetUtils(subnet);
+ final SubnetInfo info = utils.getInfo();
System.out.printf("Subnet Information for %s:%n", subnet);
System.out.println("--------------------------------------");
@@ -57,9 +57,9 @@ public class SubnetUtilsExample {
final String prompt ="Enter an IP address (e.g. 192.168.0.10):";
System.out.println(prompt);
- Scanner scanner = new Scanner(System.in);
+ final Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
- String address = scanner.nextLine();
+ final String address = scanner.nextLine();
System.out.println("The IP address [" + address + "] is "
+ (info.isInRange(address) ? "" : "not ")
+ "within the subnet [" + subnet + "]");
diff --git a/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java b/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java
index 2911f17..9691ad9 100644
--- a/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java
+++ b/src/main/java/org/apache/commons/net/examples/ftp/FTPClientExample.java
@@ -87,7 +87,7 @@ public final class FTPClientExample
"\t-PrP password - HTTP Proxy server password\n" +
"\t-# - add hash display during transfers\n";
- public static void main(String[] args) throws UnknownHostException
+ public static void main(final String[] args) throws UnknownHostException
{
boolean storeFile = false, binaryTransfer = false, error = false, listFiles = false, listNames = false, hidden = false;
boolean localActive = false, useEpsvWithIPv4 = false, feat = false, printHash = false;
@@ -206,7 +206,7 @@ public final class FTPClientExample
}
else if (args[base].equals("-PrH")) {
proxyHost = args[++base];
- String parts[] = proxyHost.split(":");
+ final String parts[] = proxyHost.split(":");
if (parts.length == 2){
proxyHost=parts[0];
proxyPort=Integer.parseInt(parts[1]);
@@ -226,7 +226,7 @@ public final class FTPClientExample
}
}
- int remain = args.length - base;
+ final int remain = args.length - base;
if (username != null) {
minParams -= 2;
}
@@ -241,7 +241,7 @@ public final class FTPClientExample
String server = args[base++];
int port = 0;
- String parts[] = server.split(":");
+ final String parts[] = server.split(":");
if (parts.length == 2){
server=parts[0];
port=Integer.parseInt(parts[1]);
@@ -277,7 +277,7 @@ public final class FTPClientExample
} else if (protocol.equals("false")) {
ftps = new FTPSClient(false);
} else {
- String prot[] = protocol.split(",");
+ final String prot[] = protocol.split(",");
if (prot.length == 1) { // Just protocol
ftps = new FTPSClient(protocol);
} else { // protocol,true|false
@@ -347,7 +347,7 @@ public final class FTPClientExample
System.exit(1);
}
}
- catch (IOException e)
+ catch (final IOException e)
{
if (ftp.isConnected())
{
@@ -355,7 +355,7 @@ public final class FTPClientExample
{
ftp.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{
// do nothing
}
@@ -413,13 +413,13 @@ __main:
else if (listFiles || mlsd || mdtm || mlst || listNames || size)
{
if (mlsd) {
- for (FTPFile f : ftp.mlistDir(remote)) {
+ for (final FTPFile f : ftp.mlistDir(remote)) {
System.out.println(f.getRawListing());
System.out.println(f.toFormattedString(displayTimeZoneId));
}
}
if (mdtm) {
- FTPFile f = ftp.mdtmFile(remote);
+ final FTPFile f = ftp.mdtmFile(remote);
if (f != null) {
System.out.println(f.getRawListing());
System.out.println(f.toFormattedString(displayTimeZoneId));
@@ -428,13 +428,13 @@ __main:
}
}
if (mlst) {
- FTPFile f = ftp.mlistFile(remote);
+ final FTPFile f = ftp.mlistFile(remote);
if (f != null){
System.out.println(f.toFormattedString(displayTimeZoneId));
}
}
if (listNames) {
- for (String s : ftp.listNames(remote)) {
+ for (final String s : ftp.listNames(remote)) {
System.out.println(s);
}
}
@@ -451,7 +451,7 @@ __main:
ftp.configure(config );
}
- for (FTPFile f : ftp.listFiles(remote)) {
+ for (final FTPFile f : ftp.listFiles(remote)) {
System.out.println(f.getRawListing());
System.out.println(f.toFormattedString(displayTimeZoneId));
}
@@ -472,9 +472,9 @@ __main:
}
// Strings feature check
- String []features = ftp.featureValues(remote);
+ final String []features = ftp.featureValues(remote);
if (features != null) {
- for(String f : features) {
+ for(final String f : features) {
System.out.println("FEAT "+remote+"="+f+".");
}
} else {
@@ -522,13 +522,13 @@ __main:
ftp.logout();
}
- catch (FTPConnectionClosedException e)
+ catch (final FTPConnectionClosedException e)
{
error = true;
System.err.println("Server closed connection.");
e.printStackTrace();
}
- catch (IOException e)
+ catch (final IOException e)
{
error = true;
e.printStackTrace();
@@ -541,7 +541,7 @@ __main:
{
ftp.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{
// do nothing
}
@@ -551,8 +551,9 @@ __main:
System.exit(error ? 1 : 0);
} // end main
- private static void showCslStats(FTPClient ftp) {
+ private static void showCslStats(final FTPClient ftp) {
@SuppressWarnings("deprecation") // debug code
+ final
int []stats = ftp.getCslDebug();
System.out.println("CslDebug="+Arrays.toString(stats));
@@ -563,14 +564,14 @@ __main:
private long megsTotal = 0;
@Override
- public void bytesTransferred(CopyStreamEvent event) {
+ public void bytesTransferred(final CopyStreamEvent event) {
bytesTransferred(event.getTotalBytesTransferred(), event.getBytesTransferred(), event.getStreamSize());
}
@Override
- public void bytesTransferred(long totalBytesTransferred,
- int bytesTransferred, long streamSize) {
- long megs = totalBytesTransferred / 1000000;
+ public void bytesTransferred(final long totalBytesTransferred,
+ final int bytesTransferred, final long streamSize) {
+ final long megs = totalBytesTransferred / 1000000;
for (long l = megsTotal; l < megs; l++) {
System.err.print("#");
}
diff --git a/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java b/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java
index ca0645f..f98139b 100644
--- a/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java
+++ b/src/main/java/org/apache/commons/net/examples/ftp/ServerToServerFTP.java
@@ -39,7 +39,7 @@ import org.apache.commons.net.ftp.FTPReply;
public final class ServerToServerFTP
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
String server1, username1, password1, file1;
String server2, username2, password2, file2;
@@ -100,7 +100,7 @@ public final class ServerToServerFTP
System.exit(1);
}
}
- catch (IOException e)
+ catch (final IOException e)
{
if (ftp1.isConnected())
{
@@ -108,7 +108,7 @@ public final class ServerToServerFTP
{
ftp1.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{
// do nothing
}
@@ -137,7 +137,7 @@ public final class ServerToServerFTP
System.exit(1);
}
}
- catch (IOException e)
+ catch (final IOException e)
{
if (ftp2.isConnected())
{
@@ -145,7 +145,7 @@ public final class ServerToServerFTP
{
ftp2.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{
// do nothing
}
@@ -198,7 +198,7 @@ __main:
}
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -213,7 +213,7 @@ __main:
ftp1.disconnect();
}
}
- catch (IOException e)
+ catch (final IOException e)
{
// do nothing
}
@@ -226,7 +226,7 @@ __main:
ftp2.disconnect();
}
}
- catch (IOException e)
+ catch (final IOException e)
{
// do nothing
}
diff --git a/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java b/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java
index a69b59f..aee4b74 100644
--- a/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java
+++ b/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java
@@ -63,7 +63,7 @@ public final class TFTPExample
"\t-v Verbose (trace packets)\n"
;
- public static void main(String[] args)
+ public static void main(final String[] args)
{
boolean receiveFile = true, closed;
int transferMode = TFTP.BINARY_MODE, argc;
@@ -117,7 +117,7 @@ public final class TFTPExample
if (verbose) {
tftp = new TFTPClient() {
@Override
- protected void trace(String direction, TFTPPacket packet) {
+ protected void trace(final String direction, final TFTPPacket packet) {
System.out.println(direction + " " + packet);
}
};
@@ -150,8 +150,8 @@ public final class TFTPExample
System.out.println("OK");
}
- private static boolean send(int transferMode, String hostname, String localFilename, String remoteFilename,
- TFTPClient tftp) {
+ private static boolean send(final int transferMode, final String hostname, final String localFilename, final String remoteFilename,
+ final TFTPClient tftp) {
boolean closed;
FileInputStream input = null;
@@ -160,7 +160,7 @@ public final class TFTPExample
{
input = new FileInputStream(localFilename);
}
- catch (IOException e)
+ catch (final IOException e)
{
tftp.close();
throw new RuntimeException("Error: could not open local file for reading.", e);
@@ -171,20 +171,20 @@ public final class TFTPExample
// Try to send local file via TFTP
try
{
- String [] parts = hostname.split(":");
+ final String [] parts = hostname.split(":");
if (parts.length == 2) {
tftp.sendFile(remoteFilename, transferMode, input, parts[0], Integer.parseInt(parts[1]));
} else {
tftp.sendFile(remoteFilename, transferMode, input, hostname);
}
}
- catch (UnknownHostException e)
+ catch (final UnknownHostException e)
{
System.err.println("Error: could not resolve hostname.");
System.err.println(e.getMessage());
System.exit(1);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Error: I/O exception occurred while sending file.");
System.err.println(e.getMessage());
@@ -199,8 +199,8 @@ public final class TFTPExample
return closed;
}
- private static boolean receive(int transferMode, String hostname, String localFilename, String remoteFilename,
- TFTPClient tftp) {
+ private static boolean receive(final int transferMode, final String hostname, final String localFilename, final String remoteFilename,
+ final TFTPClient tftp) {
boolean closed;
FileOutputStream output = null;
File file;
@@ -219,7 +219,7 @@ public final class TFTPExample
{
output = new FileOutputStream(file);
}
- catch (IOException e)
+ catch (final IOException e)
{
tftp.close();
throw new RuntimeException("Error: could not open local file for writing.", e);
@@ -230,20 +230,20 @@ public final class TFTPExample
// Try to receive remote file via TFTP
try
{
- String [] parts = hostname.split(":");
+ final String [] parts = hostname.split(":");
if (parts.length == 2) {
tftp.receiveFile(remoteFilename, transferMode, output, parts[0], Integer.parseInt(parts[1]));
} else {
tftp.receiveFile(remoteFilename, transferMode, output, hostname);
}
}
- catch (UnknownHostException e)
+ catch (final UnknownHostException e)
{
System.err.println("Error: could not resolve hostname.");
System.err.println(e.getMessage());
System.exit(1);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println(
"Error: I/O exception occurred while receiving file.");
@@ -259,7 +259,7 @@ public final class TFTPExample
return closed;
}
- private static boolean close(TFTPClient tftp, Closeable output) {
+ private static boolean close(final TFTPClient tftp, final Closeable output) {
boolean closed;
tftp.close();
try
@@ -269,7 +269,7 @@ public final class TFTPExample
}
closed = true;
}
- catch (IOException e)
+ catch (final IOException e)
{
closed = false;
System.err.println("Error: error closing file.");
@@ -278,12 +278,12 @@ public final class TFTPExample
return closed;
}
- private static void open(TFTPClient tftp) {
+ private static void open(final TFTPClient tftp) {
try
{
tftp.open();
}
- catch (SocketException e)
+ catch (final SocketException e)
{
throw new RuntimeException("Error: could not open local UDP socket.", e);
}
diff --git a/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java b/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java
index 7b13f08..035271a 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/IMAPExportMbox.java
@@ -102,7 +102,7 @@ public final class IMAPExportMbox
private static final int CONNECT_TIMEOUT = 10; // Seconds
private static final int READ_TIMEOUT = 10;
- public static void main(String[] args) throws IOException, URISyntaxException
+ public static void main(final String[] args) throws IOException, URISyntaxException
{
int connect_timeout = CONNECT_TIMEOUT;
int read_timeout = READ_TIMEOUT;
@@ -157,8 +157,8 @@ public final class IMAPExportMbox
URI uri;
try {
uri = URI.create(uriString);
- } catch(IllegalArgumentException e) { // cannot parse the path as is; let's pull it apart and try again
- Matcher m = Pattern.compile("(imaps?://[^/]+)(/.*)").matcher(uriString);
+ } catch(final IllegalArgumentException e) { // cannot parse the path as is; let's pull it apart and try again
+ final Matcher m = Pattern.compile("(imaps?://[^/]+)(/.*)").matcher(uriString);
if (m.matches()) {
uri = URI.create(m.group(1)); // Just the scheme and auth parts
uri = new URI(uri.getScheme(), uri.getAuthority(), m.group(2), null, null);
@@ -172,7 +172,7 @@ public final class IMAPExportMbox
// Handle 0, 1 or multiple item names
if (argCount > 3) {
if (argCount > 4) {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("(");
for(int i=4; i <= argCount; i++) {
if (i>4) {
@@ -212,16 +212,16 @@ public final class IMAPExportMbox
chunkListener = new MboxListener(new BufferedWriter(new FileWriter(mbox)), eol, printHash, printMarker, checkSequence);
}
- String path = uri.getPath();
+ final String path = uri.getPath();
if (path == null || path.length() < 1) {
throw new IllegalArgumentException("Invalid folderPath: '" + path + "'");
}
- String folder = path.substring(1); // skip the leading /
+ final String folder = path.substring(1); // skip the leading /
// suppress login details
final PrintCommandListener listener = new PrintCommandListener(System.out, true) {
@Override
- public void protocolReplyReceived(ProtocolCommandEvent event) {
+ public void protocolReplyReceived(final ProtocolCommandEvent event) {
if (event.getReplyCode() != IMAPReply.PARTIAL){ // This is dealt with by the chunk listener
super.protocolReplyReceived(event);
}
@@ -241,7 +241,7 @@ public final class IMAPExportMbox
throw new IOException("Could not select folder: " + folder);
}
- for(String line : imap.getReplyStrings()) {
+ for(final String line : imap.getReplyStrings()) {
maxIndexInFolder = matches(line, PATEXISTS, 1);
if (maxIndexInFolder != null) {
break;
@@ -254,7 +254,7 @@ public final class IMAPExportMbox
while(true) {
- boolean ok = imap.fetch(sequenceSet, itemNames);
+ final boolean ok = imap.fetch(sequenceSet, itemNames);
// If the fetch failed, can we retry?
if (!ok && retryWaitSecs > 0 && chunkListener != null && checkSequence) {
final String replyString = imap.getReplyString(); //includes EOL
@@ -263,7 +263,7 @@ public final class IMAPExportMbox
sequenceSet = (chunkListener.lastSeq+1)+":*";
try {
Thread.sleep(retryWaitSecs * 1000);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
// ignored
}
} else {
@@ -274,8 +274,8 @@ public final class IMAPExportMbox
}
}
- } catch (IOException ioe) {
- String count = chunkListener == null ? "?" : Integer.toString(chunkListener.total);
+ } catch (final IOException ioe) {
+ final String count = chunkListener == null ? "?" : Integer.toString(chunkListener.total);
System.err.println(
"FETCH " + sequenceSet + " " + itemNames + " failed after processing " + count + " complete messages ");
if (chunkListener != null) {
@@ -292,7 +292,7 @@ public final class IMAPExportMbox
chunkListener.close();
final Iterator<String> missingIds = chunkListener.missingIds.iterator();
if (missingIds.hasNext()) {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
for(;;) {
sb.append(missingIds.next());
if (!missingIds.hasNext()) {
@@ -314,13 +314,13 @@ public final class IMAPExportMbox
}
}
- private static boolean startsWith(String input, Pattern pat) {
- Matcher m = pat.matcher(input);
+ private static boolean startsWith(final String input, final Pattern pat) {
+ final Matcher m = pat.matcher(input);
return m.lookingAt();
}
- private static String matches(String input, Pattern pat, int index) {
- Matcher m = pat.matcher(input);
+ private static String matches(final String input, final Pattern pat, final int index) {
+ final Matcher m = pat.matcher(input);
if (m.lookingAt()) {
return m.group(index);
}
@@ -345,7 +345,7 @@ public final class IMAPExportMbox
private final boolean printMarker;
private final boolean checkSequence;
- MboxListener(BufferedWriter bw, String eol, boolean printHash, boolean printMarker, boolean checkSequence)
+ MboxListener(final BufferedWriter bw, final String eol, final boolean printHash, final boolean printMarker, final boolean checkSequence)
throws IOException {
this.eol = eol;
this.printHash = printHash;
@@ -356,16 +356,16 @@ public final class IMAPExportMbox
}
@Override
- public boolean chunkReceived(IMAP imap) {
+ public boolean chunkReceived(final IMAP imap) {
final String[] replyStrings = imap.getReplyStrings();
Date received = new Date();
final String firstLine = replyStrings[0];
Matcher m = PATID.matcher(firstLine);
if (m.lookingAt()) { // found a match
- String date = m.group(PATID_DATE_GROUP);
+ final String date = m.group(PATID_DATE_GROUP);
try {
received=IDPARSE.parse(date);
- } catch (ParseException e) {
+ } catch (final ParseException e) {
System.err.println(e);
}
} else {
@@ -375,7 +375,7 @@ public final class IMAPExportMbox
for(int i=1; i< replyStrings.length - 1; i++) {
final String line = replyStrings[i];
if (line.startsWith("Return-Path: ")) {
- String[] parts = line.split(" ", 2);
+ final String[] parts = line.split(" ", 2);
if (!parts[1].equals("<>")) {// Don't replace default with blank
replyTo = parts[1];
if (replyTo.startsWith("<")) {
@@ -411,14 +411,14 @@ public final class IMAPExportMbox
bw.append(eol);
}
// The last line ends with the trailing closing ")" which needs to be stripped
- String lastLine = replyStrings[replyStrings.length-1];
+ final String lastLine = replyStrings[replyStrings.length-1];
final int lastLength = lastLine.length();
if (lastLength > 1) { // there's some content, we need to save it
bw.append(lastLine, 0, lastLength-1);
bw.append(eol);
}
bw.append(eol); // blank line between entries
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
throw new RuntimeException(e); // chunkReceived cannot throw a checked Exception
}
@@ -429,7 +429,7 @@ public final class IMAPExportMbox
if (m.lookingAt()) { // found a match
final long msgSeq = Long.parseLong(m.group(PATSEQ_SEQUENCE_GROUP)); // Cannot fail to parse
if (lastSeq != -1) {
- long missing = msgSeq - lastSeq - 1;
+ final long missing = msgSeq - lastSeq - 1;
if (missing != 0) {
for(long j = lastSeq + 1; j < msgSeq; j++) {
missingIds.add(String.valueOf(j));
diff --git a/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java b/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java
index d075cdb..373a990 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/IMAPImportMbox.java
@@ -51,7 +51,7 @@ public final class IMAPImportMbox
private static final String CRLF = "\r\n";
private static final Pattern PATFROM = Pattern.compile(">+From "); // escaped From
- public static void main(String[] args) throws IOException
+ public static void main(final String[] args) throws IOException
{
if (args.length < 2)
{
@@ -69,23 +69,23 @@ public final class IMAPImportMbox
throw new IOException("Cannot read mailbox file: " + mbox);
}
- String path = uri.getPath();
+ final String path = uri.getPath();
if (path == null || path.length() < 1) {
throw new IllegalArgumentException("Invalid folderPath: '" + path + "'");
}
- String folder = path.substring(1); // skip the leading /
+ final String folder = path.substring(1); // skip the leading /
- List<String> contains = new ArrayList<>(); // list of strings to find
- BitSet msgNums = new BitSet(); // list of message numbers
+ final List<String> contains = new ArrayList<>(); // list of strings to find
+ final BitSet msgNums = new BitSet(); // list of message numbers
for(int i = 2; i < args.length; i++) {
- String arg = args[i];
+ final String arg = args[i];
if (arg.matches("\\d+(-\\d+)?(,\\d+(-\\d+)?)*")) { // number,m-n
- for(String entry : arg.split(",")) {
- String []parts = entry.split("-");
+ for(final String entry : arg.split(",")) {
+ final String []parts = entry.split("-");
if (parts.length == 2) { // m-n
- int low = Integer.parseInt(parts[0]);
- int high = Integer.parseInt(parts[1]);
+ final int low = Integer.parseInt(parts[0]);
+ final int high = Integer.parseInt(parts[1]);
for(int j=low; j <= high; j++) {
msgNums.set(j);
}
@@ -111,7 +111,7 @@ public final class IMAPImportMbox
final BufferedReader br = new BufferedReader(new FileReader(file)); // TODO charset?
String line;
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
boolean wanted = false; // Skip any leading rubbish
while((line=br.readLine())!=null) {
if (line.startsWith("From ")) { // start of message; i.e. end of previous (if any)
@@ -134,7 +134,7 @@ public final class IMAPImportMbox
if (wanted && process(sb, imap, folder, total)) { // last message (if any)
loaded++;
}
- } catch (IOException e) {
+ } catch (final IOException e) {
System.out.println("Error processing msg: " + total + " " + imap.getReplyString());
e.printStackTrace();
System.exit(10);
@@ -146,18 +146,18 @@ public final class IMAPImportMbox
System.out.println("Processed " + total + " messages, loaded " + loaded);
}
- private static boolean startsWith(String input, Pattern pat) {
- Matcher m = pat.matcher(input);
+ private static boolean startsWith(final String input, final Pattern pat) {
+ final Matcher m = pat.matcher(input);
return m.lookingAt();
}
- private static String getDate(String msg) {
+ private static String getDate(final String msg) {
// From SENDER Fri Sep 13 17:04:01 2019
final Pattern FROM_RE = Pattern.compile("From \\S+ +\\S+ (\\S+) ?(\\S+) (\\S+) (\\S+)");
// [Fri] Sep 13 HMS 2019
// output date: 13-Sep-2019 17:04:01 +0000
String date = null;
- Matcher m = FROM_RE.matcher(msg);
+ final Matcher m = FROM_RE.matcher(msg);
if (m.lookingAt()) {
date = m.group(2)+"-"+m.group(1)+"-"+m.group(4)+" "+m.group(3)+" +0000";
}
@@ -167,11 +167,11 @@ public final class IMAPImportMbox
private static boolean process(final StringBuilder sb, final IMAPClient imap, final String folder
,final int msgNum) throws IOException {
final int length = sb.length();
- boolean haveMessage = length > 2;
+ final boolean haveMessage = length > 2;
if (haveMessage) {
System.out.println("MsgNum: " + msgNum +" Length " + length);
sb.setLength(length-2); // drop trailing CRLF (mbox format has trailing blank line)
- String msg = sb.toString();
+ final String msg = sb.toString();
if (!imap.append(folder, null, getDate(msg), msg)) {
throw new IOException("Failed to import message: " + msgNum + " " + imap.getReplyString());
}
@@ -188,7 +188,7 @@ public final class IMAPImportMbox
* @param contains the list of strings to be contained
* @return true if the message is wanted
*/
- private static boolean wanted(int msgNum, String line, BitSet msgNums, List<String> contains) {
+ private static boolean wanted(final int msgNum, final String line, final BitSet msgNums, final List<String> contains) {
return (msgNums.isEmpty() && contains.isEmpty()) // no selectors
|| msgNums.get(msgNum) // matches message number
|| listContains(contains, line); // contains string
@@ -200,8 +200,8 @@ public final class IMAPImportMbox
* @param string the String to check against
* @return true if at least one entry in the contains list is contained in the string
*/
- private static boolean listContains(List<String> contains, String string) {
- for(String entry : contains) {
+ private static boolean listContains(final List<String> contains, final String string) {
+ for(final String entry : contains) {
if (string.contains(entry)) {
return true;
}
diff --git a/src/main/java/org/apache/commons/net/examples/mail/IMAPMail.java b/src/main/java/org/apache/commons/net/examples/mail/IMAPMail.java
index 8929905..17935f5 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/IMAPMail.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/IMAPMail.java
@@ -38,7 +38,7 @@ import org.apache.commons.net.imap.IMAPClient;
public final class IMAPMail
{
- public static void main(String[] args) throws IOException {
+ public static void main(final String[] args) throws IOException {
if (args.length != 1)
{
System.err.println(
@@ -47,7 +47,7 @@ public final class IMAPMail
System.exit(1);
}
- URI uri = URI.create(args[0]);
+ final URI uri = URI.create(args[0]);
// Connect and login
final IMAPClient imap = IMAPUtils.imapLogin(uri, 10000, null);
@@ -68,7 +68,7 @@ public final class IMAPMail
imap.list("", "*"); // Show the folders
- } catch (IOException e) {
+ } catch (final IOException e) {
System.out.println(imap.getReplyString());
e.printStackTrace();
System.exit(10);
diff --git a/src/main/java/org/apache/commons/net/examples/mail/IMAPUtils.java b/src/main/java/org/apache/commons/net/examples/mail/IMAPUtils.java
index 8c06dff..b0c26ff 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/IMAPUtils.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/IMAPUtils.java
@@ -40,18 +40,18 @@ class IMAPUtils {
* @return the IMAP client - connected and logged in
* @throws IOException if any problems occur
*/
- static IMAPClient imapLogin(URI uri, int defaultTimeout, ProtocolCommandListener listener) throws IOException {
+ static IMAPClient imapLogin(final URI uri, final int defaultTimeout, final ProtocolCommandListener listener) throws IOException {
final String userInfo = uri.getUserInfo();
if (userInfo == null) {
throw new IllegalArgumentException("Missing userInfo details");
}
- String []userpass = userInfo.split(":");
+ final String []userpass = userInfo.split(":");
if (userpass.length != 2) {
throw new IllegalArgumentException("Invalid userInfo details: '" + userInfo + "'");
}
- String username = userpass[0];
+ final String username = userpass[0];
String password = userpass[1];
// prompt for the password if necessary
password = Utils.getPassword(username, password);
@@ -84,7 +84,7 @@ class IMAPUtils {
try {
imap.connect(server);
System.out.println("Successfully connected");
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Could not connect to server.", e);
}
diff --git a/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java b/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java
index 59a103e..cb28027 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/POP3ExportMbox.java
@@ -49,7 +49,7 @@ public final class POP3ExportMbox
private static final Pattern PATFROM = Pattern.compile(">*From "); // unescaped From_
- public static void main(String[] args)
+ public static void main(final String[] args)
{
int argIdx;
String file = null;
@@ -69,20 +69,20 @@ public final class POP3ExportMbox
System.exit(1);
}
- String arg0[] = args[argIdx++].split(":");
- String server=arg0[0];
- String username = args[argIdx++];
+ final String arg0[] = args[argIdx++].split(":");
+ final String server=arg0[0];
+ final String username = args[argIdx++];
String password = args[argIdx++];
// prompt for the password if necessary
try {
password = Utils.getPassword(username, password);
- } catch (IOException e1) {
+ } catch (final IOException e1) {
System.err.println("Could not retrieve password: " + e1.getMessage());
return;
}
- String proto = argCount > 3 ? args[argIdx++] : null;
- boolean implicit = argCount > 4 ? Boolean.parseBoolean(args[argIdx++]) : false;
+ final String proto = argCount > 3 ? args[argIdx++] : null;
+ final boolean implicit = argCount > 4 ? Boolean.parseBoolean(args[argIdx++]) : false;
POP3Client pop3;
@@ -108,7 +108,7 @@ public final class POP3ExportMbox
{
pop3.connect(server);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Could not connect to server.");
e.printStackTrace();
@@ -124,7 +124,7 @@ public final class POP3ExportMbox
return;
}
- POP3MessageInfo status = pop3.status();
+ final POP3MessageInfo status = pop3.status();
if (status == null) {
System.err.println("Could not retrieve status.");
pop3.logout();
@@ -133,15 +133,15 @@ public final class POP3ExportMbox
}
System.out.println("Status: " + status);
- int count = status.number;
+ final int count = status.number;
if (file != null) {
System.out.println("Getting messages: " + count);
- File mbox = new File(file);
+ final File mbox = new File(file);
if (mbox.isDirectory()) {
System.out.println("Writing dir: " + mbox);
// Currently POP3Client uses iso-8859-1
for (int i = 1; i <= count; i++) {
- OutputStreamWriter fw = new OutputStreamWriter(
+ final OutputStreamWriter fw = new OutputStreamWriter(
new FileOutputStream(new File(mbox,i+".eml")),StandardCharsets.ISO_8859_1);
writeFile(pop3, fw, i);
fw.close();
@@ -149,7 +149,7 @@ public final class POP3ExportMbox
} else {
System.out.println("Writing file: " + mbox);
// Currently POP3Client uses iso-8859-1
- OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(mbox),StandardCharsets.ISO_8859_1);
+ final OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(mbox),StandardCharsets.ISO_8859_1);
for (int i = 1; i <= count; i++) {
writeMbox(pop3, fw, i);
}
@@ -160,15 +160,15 @@ public final class POP3ExportMbox
pop3.logout();
pop3.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
return;
}
}
- private static void writeFile(POP3Client pop3, OutputStreamWriter fw, int i) throws IOException {
- BufferedReader r = (BufferedReader) pop3.retrieveMessage(i);
+ private static void writeFile(final POP3Client pop3, final OutputStreamWriter fw, final int i) throws IOException {
+ final BufferedReader r = (BufferedReader) pop3.retrieveMessage(i);
String line;
while ((line = r.readLine()) != null)
{
@@ -178,12 +178,12 @@ public final class POP3ExportMbox
r.close();
}
- private static void writeMbox(POP3Client pop3, OutputStreamWriter fw, int i) throws IOException {
+ private static void writeMbox(final POP3Client pop3, final OutputStreamWriter fw, final int i) throws IOException {
final SimpleDateFormat DATE_FORMAT // for mbox From_ lines
= new SimpleDateFormat("EEE MMM dd HH:mm:ss YYYY");
- String replyTo = "MAILER-DAEMON"; // default
- Date received = new Date();
- BufferedReader r = (BufferedReader) pop3.retrieveMessage(i);
+ final String replyTo = "MAILER-DAEMON"; // default
+ final Date received = new Date();
+ final BufferedReader r = (BufferedReader) pop3.retrieveMessage(i);
fw.append("From ");
fw.append(replyTo);
fw.append(' ');
@@ -202,8 +202,8 @@ public final class POP3ExportMbox
r.close();
}
- private static boolean startsWith(String input, Pattern pat) {
- Matcher m = pat.matcher(input);
+ private static boolean startsWith(final String input, final Pattern pat) {
+ final Matcher m = pat.matcher(input);
return m.lookingAt();
}
}
diff --git a/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java b/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java
index 27f8448..5a6a892 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/POP3Mail.java
@@ -38,13 +38,13 @@ import org.apache.commons.net.pop3.POP3SClient;
public final class POP3Mail
{
- public static final void printMessageInfo(BufferedReader reader, int id) throws IOException {
+ public static final void printMessageInfo(final BufferedReader reader, final int id) throws IOException {
String from = "";
String subject = "";
String line;
while ((line = reader.readLine()) != null)
{
- String lower = line.toLowerCase(Locale.ENGLISH);
+ final String lower = line.toLowerCase(Locale.ENGLISH);
if (lower.startsWith("from: ")) {
from = line.substring(6).trim();
} else if (lower.startsWith("subject: ")) {
@@ -55,7 +55,7 @@ public final class POP3Mail
System.out.println(Integer.toString(id) + " From: " + from + " Subject: " + subject);
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length < 3)
{
@@ -64,20 +64,20 @@ public final class POP3Mail
System.exit(1);
}
- String arg0[] = args[0].split(":");
- String server=arg0[0];
- String username = args[1];
+ final String arg0[] = args[0].split(":");
+ final String server=arg0[0];
+ final String username = args[1];
String password = args[2];
// prompt for the password if necessary
try {
password = Utils.getPassword(username, password);
- } catch (IOException e1) {
+ } catch (final IOException e1) {
System.err.println("Could not retrieve password: " + e1.getMessage());
return;
}
- String proto = args.length > 3 ? args[3] : null;
- boolean implicit = args.length > 4 ? Boolean.parseBoolean(args[4]) : false;
+ final String proto = args.length > 3 ? args[3] : null;
+ final boolean implicit = args.length > 4 ? Boolean.parseBoolean(args[4]) : false;
POP3Client pop3;
@@ -106,7 +106,7 @@ public final class POP3Mail
{
pop3.connect(server);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Could not connect to server.");
e.printStackTrace();
@@ -122,7 +122,7 @@ public final class POP3Mail
return;
}
- POP3MessageInfo status = pop3.status();
+ final POP3MessageInfo status = pop3.status();
if (status == null) {
System.err.println("Could not retrieve status.");
pop3.logout();
@@ -132,7 +132,7 @@ public final class POP3Mail
System.out.println("Status: " + status);
- POP3MessageInfo[] messages = pop3.listMessages();
+ final POP3MessageInfo[] messages = pop3.listMessages();
if (messages == null)
{
@@ -151,8 +151,8 @@ public final class POP3Mail
System.out.println("Message count: " + messages.length);
- for (POP3MessageInfo msginfo : messages) {
- BufferedReader reader = (BufferedReader) pop3.retrieveMessageTop(msginfo.number, 0);
+ for (final POP3MessageInfo msginfo : messages) {
+ final BufferedReader reader = (BufferedReader) pop3.retrieveMessageTop(msginfo.number, 0);
if (reader == null) {
System.err.println("Could not retrieve message header.");
@@ -166,7 +166,7 @@ public final class POP3Mail
pop3.logout();
pop3.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
return;
diff --git a/src/main/java/org/apache/commons/net/examples/mail/SMTPMail.java b/src/main/java/org/apache/commons/net/examples/mail/SMTPMail.java
index eac3dbc..ecdba33 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/SMTPMail.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/SMTPMail.java
@@ -42,10 +42,10 @@ import org.apache.commons.net.smtp.SimpleSMTPHeader;
public final class SMTPMail
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
String sender, recipient, subject, fileName, server, cc;
- List<String> ccList = new ArrayList<>();
+ final List<String> ccList = new ArrayList<>();
BufferedReader stdin;
FileReader fileReader = null;
Writer writer;
@@ -106,7 +106,7 @@ public final class SMTPMail
{
fileReader = new FileReader(fileName);
}
- catch (FileNotFoundException e)
+ catch (final FileNotFoundException e)
{
System.err.println("File not found. " + e.getMessage());
}
@@ -131,7 +131,7 @@ public final class SMTPMail
- for (String recpt : ccList) {
+ for (final String recpt : ccList) {
client.addRecipient(recpt);
}
@@ -153,7 +153,7 @@ public final class SMTPMail
client.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/mail/Utils.java b/src/main/java/org/apache/commons/net/examples/mail/Utils.java
index d4c6bca..996c319 100644
--- a/src/main/java/org/apache/commons/net/examples/mail/Utils.java
+++ b/src/main/java/org/apache/commons/net/examples/mail/Utils.java
@@ -46,14 +46,14 @@ class Utils {
* STDIN may require creating a temporary file which could be read by others
* Environment variables may be visible by using PS
*/
- static String getPassword(String username, String password) throws IOException {
+ static String getPassword(final String username, String password) throws IOException {
if ("-".equals(password)) { // stdin
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
password = in.readLine();
} else if ("*".equals(password)) { // console
- Console con = System.console(); // Java 1.6
+ final Console con = System.console(); // Java 1.6
if (con != null) {
- char[] pwd = con.readPassword("Password for " + username + ": ");
+ final char[] pwd = con.readPassword("Password for " + username + ": ");
password = new String(pwd);
} else {
throw new IOException("Cannot access Console");
diff --git a/src/main/java/org/apache/commons/net/examples/nntp/ArticleReader.java b/src/main/java/org/apache/commons/net/examples/nntp/ArticleReader.java
index 7145877..185c161 100644
--- a/src/main/java/org/apache/commons/net/examples/nntp/ArticleReader.java
+++ b/src/main/java/org/apache/commons/net/examples/nntp/ArticleReader.java
@@ -31,32 +31,32 @@ import org.apache.commons.net.nntp.NewsgroupInfo;
*/
public class ArticleReader {
- public static void main(String[] args) throws SocketException, IOException {
+ public static void main(final String[] args) throws SocketException, IOException {
if (args.length != 2 && args.length != 3 && args.length != 5) {
System.out.println("Usage: MessageThreading <hostname> <groupname> [<article specifier> [<user> <password>]]");
return;
}
- String hostname = args[0];
- String newsgroup = args[1];
+ final String hostname = args[0];
+ final String newsgroup = args[1];
// Article specifier can be numeric or Id in form <m....@host>
- String articleSpec = args.length >= 3 ? args[2] : null;
+ final String articleSpec = args.length >= 3 ? args[2] : null;
- NNTPClient client = new NNTPClient();
+ final NNTPClient client = new NNTPClient();
client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
client.connect(hostname);
if (args.length == 5) { // Optional auth
- String user = args[3];
- String password = args[4];
+ final String user = args[3];
+ final String password = args[4];
if(!client.authenticate(user, password)) {
System.out.println("Authentication failed for user " + user + "!");
System.exit(1);
}
}
- NewsgroupInfo group = new NewsgroupInfo();
+ final NewsgroupInfo group = new NewsgroupInfo();
client.selectNewsgroup(newsgroup, group);
BufferedReader brHdr;
@@ -64,7 +64,7 @@ public class ArticleReader {
if (articleSpec != null) {
brHdr = (BufferedReader) client.retrieveArticleHeader(articleSpec);
} else {
- long articleNum = group.getLastArticleLong();
+ final long articleNum = group.getLastArticleLong();
brHdr = client.retrieveArticleHeader(articleNum);
}
if (brHdr != null) {
@@ -77,7 +77,7 @@ public class ArticleReader {
if (articleSpec != null) {
brBody = (BufferedReader) client.retrieveArticleBody(articleSpec);
} else {
- long articleNum = group.getLastArticleLong();
+ final long articleNum = group.getLastArticleLong();
brBody = client.retrieveArticleBody(articleNum);
}
if (brBody != null) {
diff --git a/src/main/java/org/apache/commons/net/examples/nntp/ExtendedNNTPOps.java b/src/main/java/org/apache/commons/net/examples/nntp/ExtendedNNTPOps.java
index 0835f83..d0aa919 100644
--- a/src/main/java/org/apache/commons/net/examples/nntp/ExtendedNNTPOps.java
+++ b/src/main/java/org/apache/commons/net/examples/nntp/ExtendedNNTPOps.java
@@ -40,13 +40,13 @@ public class ExtendedNNTPOps {
}
- private void demo(String host, String user, String password) {
+ private void demo(final String host, final String user, final String password) {
try {
client.connect(host);
// AUTHINFO USER/AUTHINFO PASS
if (user != null && password != null) {
- boolean success = client.authenticate(user, password);
+ final boolean success = client.authenticate(user, password);
if (success) {
System.out.println("Authentication succeeded");
} else {
@@ -55,13 +55,13 @@ public class ExtendedNNTPOps {
}
// XOVER
- NewsgroupInfo testGroup = new NewsgroupInfo();
+ final NewsgroupInfo testGroup = new NewsgroupInfo();
client.selectNewsgroup("alt.test", testGroup);
- long lowArticleNumber = testGroup.getFirstArticleLong();
- long highArticleNumber = lowArticleNumber + 100;
- Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
+ final long lowArticleNumber = testGroup.getFirstArticleLong();
+ final long highArticleNumber = lowArticleNumber + 100;
+ final Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
- for (Article article : articles) {
+ for (final Article article : articles) {
if (article.isDummy()) { // Subject will contain raw response
System.out.println("Could not parse: "+article.getSubject());
} else {
@@ -70,21 +70,21 @@ public class ExtendedNNTPOps {
}
// LIST ACTIVE
- NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*");
- for (NewsgroupInfo fanGroup : fanGroups)
+ final NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*");
+ for (final NewsgroupInfo fanGroup : fanGroups)
{
System.out.println(fanGroup.getNewsgroup());
}
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
- public static void main(String[] args) {
+ public static void main(final String[] args) {
ExtendedNNTPOps ops;
- int argc = args.length;
+ final int argc = args.length;
if (argc < 1) {
System.err.println("usage: ExtendedNNTPOps nntpserver [username password]");
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/nntp/ListNewsgroups.java b/src/main/java/org/apache/commons/net/examples/nntp/ListNewsgroups.java
index 2c0cc22..fe9b167 100644
--- a/src/main/java/org/apache/commons/net/examples/nntp/ListNewsgroups.java
+++ b/src/main/java/org/apache/commons/net/examples/nntp/ListNewsgroups.java
@@ -32,7 +32,7 @@ import org.apache.commons.net.nntp.NewsgroupInfo;
public final class ListNewsgroups
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length < 1)
{
@@ -40,8 +40,8 @@ public final class ListNewsgroups
return;
}
- NNTPClient client = new NNTPClient();
- String pattern = args.length >= 2 ? args[1] : "";
+ final NNTPClient client = new NNTPClient();
+ final String pattern = args.length >= 2 ? args[1] : "";
try
{
@@ -49,23 +49,23 @@ public final class ListNewsgroups
int j = 0;
try {
- for(String s : client.iterateNewsgroupListing(pattern)) {
+ for(final String s : client.iterateNewsgroupListing(pattern)) {
j++;
System.out.println(s);
}
- } catch (IOException e1) {
+ } catch (final IOException e1) {
e1.printStackTrace();
}
System.out.println(j);
j = 0;
- for(NewsgroupInfo n : client.iterateNewsgroups(pattern)) {
+ for(final NewsgroupInfo n : client.iterateNewsgroups(pattern)) {
j++;
System.out.println(n.getNewsgroup());
}
System.out.println(j);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
}
@@ -77,7 +77,7 @@ public final class ListNewsgroups
client.disconnect();
}
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Error disconnecting from server.");
e.printStackTrace();
diff --git a/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java b/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java
index e8aae1f..7772c64 100644
--- a/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java
+++ b/src/main/java/org/apache/commons/net/examples/nntp/MessageThreading.java
@@ -34,50 +34,50 @@ public class MessageThreading {
public MessageThreading() {
}
- public static void main(String[] args) throws SocketException, IOException {
+ public static void main(final String[] args) throws SocketException, IOException {
if (args.length != 2 && args.length != 4) {
System.out.println("Usage: MessageThreading <hostname> <groupname> [<user> <password>]");
return;
}
- String hostname = args[0];
- String newsgroup = args[1];
+ final String hostname = args[0];
+ final String newsgroup = args[1];
- NNTPClient client = new NNTPClient();
+ final NNTPClient client = new NNTPClient();
client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
client.connect(hostname);
if (args.length == 4) { // Optional auth
- String user = args[2];
- String password = args[3];
+ final String user = args[2];
+ final String password = args[3];
if(!client.authenticate(user, password)) {
System.out.println("Authentication failed for user " + user + "!");
System.exit(1);
}
}
- String fmt[] = client.listOverviewFmt();
+ final String fmt[] = client.listOverviewFmt();
if (fmt != null) {
System.out.println("LIST OVERVIEW.FMT:");
- for(String s : fmt) {
+ for(final String s : fmt) {
System.out.println(s);
}
} else {
System.out.println("Failed to get OVERVIEW.FMT");
}
- NewsgroupInfo group = new NewsgroupInfo();
+ final NewsgroupInfo group = new NewsgroupInfo();
client.selectNewsgroup(newsgroup, group);
- long lowArticleNumber = group.getFirstArticleLong();
- long highArticleNumber = lowArticleNumber + 5000;
+ final long lowArticleNumber = group.getFirstArticleLong();
+ final long highArticleNumber = lowArticleNumber + 5000;
System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
- Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
+ final Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
System.out.println("Building message thread tree...");
- Threader threader = new Threader();
- Article root = (Article)threader.thread(articles);
+ final Threader threader = new Threader();
+ final Article root = (Article)threader.thread(articles);
Article.printThread(root, 0);
}
diff --git a/src/main/java/org/apache/commons/net/examples/nntp/NNTPUtils.java b/src/main/java/org/apache/commons/net/examples/nntp/NNTPUtils.java
index 2db46c4..66599a9 100644
--- a/src/main/java/org/apache/commons/net/examples/nntp/NNTPUtils.java
+++ b/src/main/java/org/apache/commons/net/examples/nntp/NNTPUtils.java
@@ -36,11 +36,11 @@ public class NNTPUtils {
* @return Article[] An array of Article
* @throws IOException on error
*/
- public static List<Article> getArticleInfo(NNTPClient client, long lowArticleNumber, long highArticleNumber)
+ public static List<Article> getArticleInfo(final NNTPClient client, final long lowArticleNumber, final long highArticleNumber)
throws IOException {
- List<Article> articles = new ArrayList<>();
- Iterable<Article> arts = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
- for(Article article : arts){
+ final List<Article> articles = new ArrayList<>();
+ final Iterable<Article> arts = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
+ for(final Article article : arts){
articles.add(article);
}
return articles;
diff --git a/src/main/java/org/apache/commons/net/examples/nntp/PostMessage.java b/src/main/java/org/apache/commons/net/examples/nntp/PostMessage.java
index 0e0061b..632ccf5 100644
--- a/src/main/java/org/apache/commons/net/examples/nntp/PostMessage.java
+++ b/src/main/java/org/apache/commons/net/examples/nntp/PostMessage.java
@@ -41,7 +41,7 @@ import org.apache.commons.net.nntp.SimpleNNTPHeader;
public final class PostMessage
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
String from, subject, newsgroup, fileName, server, organization;
String references;
@@ -128,7 +128,7 @@ public final class PostMessage
{
fileReader = new FileReader(fileName);
}
- catch (FileNotFoundException e)
+ catch (final FileNotFoundException e)
{
System.err.println("File not found. " + e.getMessage());
System.exit(1);
@@ -149,7 +149,7 @@ public final class PostMessage
if (client.isAllowedToPost())
{
- Writer writer = client.postArticle();
+ final Writer writer = client.postArticle();
if (writer != null)
{
@@ -168,7 +168,7 @@ public final class PostMessage
client.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/ntp/NTPClient.java b/src/main/java/org/apache/commons/net/examples/ntp/NTPClient.java
index 4ff4a38..4f7446f 100644
--- a/src/main/java/org/apache/commons/net/examples/ntp/NTPClient.java
+++ b/src/main/java/org/apache/commons/net/examples/ntp/NTPClient.java
@@ -53,10 +53,10 @@ public final class NTPClient
* Process <code>TimeInfo</code> object and print its details.
* @param info <code>TimeInfo</code> object.
*/
- public static void processResponse(TimeInfo info)
+ public static void processResponse(final TimeInfo info)
{
- NtpV3Packet message = info.getMessage();
- int stratum = message.getStratum();
+ final NtpV3Packet message = info.getMessage();
+ final int stratum = message.getStratum();
String refType;
if (stratum <= 0) {
refType = "(Unspecified or Unavailable)";
@@ -67,21 +67,21 @@ public final class NTPClient
}
// stratum should be 0..15...
System.out.println(" Stratum: " + stratum + " " + refType);
- int version = message.getVersion();
- int li = message.getLeapIndicator();
+ final int version = message.getVersion();
+ final int li = message.getLeapIndicator();
System.out.println(" leap=" + li + ", version="
+ version + ", precision=" + message.getPrecision());
System.out.println(" mode: " + message.getModeName() + " (" + message.getMode() + ")");
- int poll = message.getPoll();
+ final int poll = message.getPoll();
// poll value typically btwn MINPOLL (4) and MAXPOLL (14)
System.out.println(" poll: " + (poll <= 0 ? 1 : (int) Math.pow(2, poll))
+ " seconds" + " (2 ** " + poll + ")");
- double disp = message.getRootDispersionInMillisDouble();
+ final double disp = message.getRootDispersionInMillisDouble();
System.out.println(" rootdelay=" + numberFormat.format(message.getRootDelayInMillisDouble())
+ ", rootdispersion(ms): " + numberFormat.format(disp));
- int refId = message.getReferenceId();
+ final int refId = message.getReferenceId();
String refAddr = NtpUtils.getHostAddress(refId);
String refName = null;
if (refId != 0) {
@@ -93,12 +93,12 @@ public final class NTPClient
// for GENERIC DCF77 AM; see refclock.htm from the NTP software distribution.
if (!refAddr.startsWith("127.127")) {
try {
- InetAddress addr = InetAddress.getByName(refAddr);
- String name = addr.getHostName();
+ final InetAddress addr = InetAddress.getByName(refAddr);
+ final String name = addr.getHostName();
if (name != null && !name.equals(refAddr)) {
refName = name;
}
- } catch (UnknownHostException e) {
+ } catch (final UnknownHostException e) {
// some stratum-2 servers sync to ref clock device but fudge stratum level higher... (e.g. 2)
// ref not valid host maybe it's a reference clock name?
// otherwise just show the ref IP address.
@@ -116,61 +116,61 @@ public final class NTPClient
}
System.out.println(" Reference Identifier:\t" + refAddr);
- TimeStamp refNtpTime = message.getReferenceTimeStamp();
+ final TimeStamp refNtpTime = message.getReferenceTimeStamp();
System.out.println(" Reference Timestamp:\t" + refNtpTime + " " + refNtpTime.toDateString());
// Originate Time is time request sent by client (t1)
- TimeStamp origNtpTime = message.getOriginateTimeStamp();
+ final TimeStamp origNtpTime = message.getOriginateTimeStamp();
System.out.println(" Originate Timestamp:\t" + origNtpTime + " " + origNtpTime.toDateString());
- long destTime = info.getReturnTime();
+ final long destTime = info.getReturnTime();
// Receive Time is time request received by server (t2)
- TimeStamp rcvNtpTime = message.getReceiveTimeStamp();
+ final TimeStamp rcvNtpTime = message.getReceiveTimeStamp();
System.out.println(" Receive Timestamp:\t" + rcvNtpTime + " " + rcvNtpTime.toDateString());
// Transmit time is time reply sent by server (t3)
- TimeStamp xmitNtpTime = message.getTransmitTimeStamp();
+ final TimeStamp xmitNtpTime = message.getTransmitTimeStamp();
System.out.println(" Transmit Timestamp:\t" + xmitNtpTime + " " + xmitNtpTime.toDateString());
// Destination time is time reply received by client (t4)
- TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime);
+ final TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime);
System.out.println(" Destination Timestamp:\t" + destNtpTime + " " + destNtpTime.toDateString());
info.computeDetails(); // compute offset/delay if not already done
- Long offsetValue = info.getOffset();
- Long delayValue = info.getDelay();
- String delay = (delayValue == null) ? "N/A" : delayValue.toString();
- String offset = (offsetValue == null) ? "N/A" : offsetValue.toString();
+ final Long offsetValue = info.getOffset();
+ final Long delayValue = info.getDelay();
+ final String delay = (delayValue == null) ? "N/A" : delayValue.toString();
+ final String offset = (offsetValue == null) ? "N/A" : offsetValue.toString();
System.out.println(" Roundtrip delay(ms)=" + delay
+ ", clock offset(ms)=" + offset); // offset in ms
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length == 0) {
System.err.println("Usage: NTPClient <hostname-or-address-list>");
System.exit(1);
}
- NTPUDPClient client = new NTPUDPClient();
+ final NTPUDPClient client = new NTPUDPClient();
// We want to timeout if a response takes longer than 10 seconds
client.setDefaultTimeout(10000);
try {
client.open();
- for (String arg : args)
+ for (final String arg : args)
{
System.out.println();
try {
- InetAddress hostAddr = InetAddress.getByName(arg);
+ final InetAddress hostAddr = InetAddress.getByName(arg);
System.out.println("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
- TimeInfo info = client.getTime(hostAddr);
+ final TimeInfo info = client.getTime(hostAddr);
processResponse(info);
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
ioe.printStackTrace();
}
}
- } catch (SocketException e) {
+ } catch (final SocketException e) {
e.printStackTrace();
}
diff --git a/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java b/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java
index 561b212..07a0601 100644
--- a/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java
+++ b/src/main/java/org/apache/commons/net/examples/ntp/SimpleNTPServer.java
@@ -60,7 +60,7 @@ public class SimpleNTPServer implements Runnable {
* <code>zero</code> for a system selected free port.
* @throws IllegalArgumentException if port number less than 0
*/
- public SimpleNTPServer(int port)
+ public SimpleNTPServer(final int port)
{
if (port < 0) {
throw new IllegalArgumentException();
@@ -136,14 +136,14 @@ public class SimpleNTPServer implements Runnable {
public void run()
{
running = true;
- byte buffer[] = new byte[48];
+ final byte buffer[] = new byte[48];
final DatagramPacket request = new DatagramPacket(buffer, buffer.length);
do {
try {
socket.receive(request);
final long rcvTime = System.currentTimeMillis();
handlePacket(request, rcvTime);
- } catch (IOException e) {
+ } catch (final IOException e) {
if (running)
{
e.printStackTrace();
@@ -162,14 +162,14 @@ public class SimpleNTPServer implements Runnable {
*
* @throws IOException if an I/O error occurs.
*/
- protected void handlePacket(DatagramPacket request, long rcvTime) throws IOException
+ protected void handlePacket(final DatagramPacket request, final long rcvTime) throws IOException
{
- NtpV3Packet message = new NtpV3Impl();
+ final NtpV3Packet message = new NtpV3Impl();
message.setDatagramPacket(request);
System.out.printf("NTP packet from %s mode=%s%n", request.getAddress().getHostAddress(),
NtpUtils.getModeName(message.getMode()));
if (message.getMode() == NtpV3Packet.MODE_CLIENT) {
- NtpV3Packet response = new NtpV3Impl();
+ final NtpV3Packet response = new NtpV3Impl();
response.setStratum(1);
response.setMode(NtpV3Packet.MODE_SERVER);
@@ -189,7 +189,7 @@ public class SimpleNTPServer implements Runnable {
// Transmit time is time reply sent by server (t3)
response.setTransmitTime(TimeStamp.getNtpTime(System.currentTimeMillis()));
- DatagramPacket dp = response.getDatagramPacket();
+ final DatagramPacket dp = response.getDatagramPacket();
dp.setPort(request.getPort());
dp.setAddress(request.getAddress());
socket.send(dp);
@@ -211,21 +211,21 @@ public class SimpleNTPServer implements Runnable {
started = false;
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
int port = NtpV3Packet.NTP_PORT;
if (args.length != 0)
{
try {
port = Integer.parseInt(args[0]);
- } catch (NumberFormatException nfe) {
+ } catch (final NumberFormatException nfe) {
nfe.printStackTrace();
}
}
- SimpleNTPServer timeServer = new SimpleNTPServer(port);
+ final SimpleNTPServer timeServer = new SimpleNTPServer(port);
try {
timeServer.start();
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
diff --git a/src/main/java/org/apache/commons/net/examples/ntp/TimeClient.java b/src/main/java/org/apache/commons/net/examples/ntp/TimeClient.java
index df079a9..e88000d 100644
--- a/src/main/java/org/apache/commons/net/examples/ntp/TimeClient.java
+++ b/src/main/java/org/apache/commons/net/examples/ntp/TimeClient.java
@@ -38,9 +38,9 @@ import org.apache.commons.net.time.TimeUDPClient;
public final class TimeClient
{
- public static final void timeTCP(String host) throws IOException
+ public static final void timeTCP(final String host) throws IOException
{
- TimeTCPClient client = new TimeTCPClient();
+ final TimeTCPClient client = new TimeTCPClient();
try {
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
@@ -51,9 +51,9 @@ public final class TimeClient
}
}
- public static final void timeUDP(String host) throws IOException
+ public static final void timeUDP(final String host) throws IOException
{
- TimeUDPClient client = new TimeUDPClient();
+ final TimeUDPClient client = new TimeUDPClient();
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
@@ -62,7 +62,7 @@ public final class TimeClient
client.close();
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length == 1)
@@ -71,7 +71,7 @@ public final class TimeClient
{
timeTCP(args[0]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -83,7 +83,7 @@ public final class TimeClient
{
timeUDP(args[1]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/telnet/TelnetClientExample.java b/src/main/java/org/apache/commons/net/examples/telnet/TelnetClientExample.java
index 420592c..6d1caba 100644
--- a/src/main/java/org/apache/commons/net/examples/telnet/TelnetClientExample.java
+++ b/src/main/java/org/apache/commons/net/examples/telnet/TelnetClientExample.java
@@ -54,7 +54,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
* @param args input params
* @throws Exception on error
***/
- public static void main(String[] args) throws Exception
+ public static void main(final String[] args) throws Exception
{
FileOutputStream fout = null;
@@ -64,7 +64,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
System.exit(1);
}
- String remoteip = args[0];
+ final String remoteip = args[0];
int remoteport;
@@ -81,7 +81,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
{
fout = new FileOutputStream ("spy.log", true);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println(
"Exception while opening the spy file: "
@@ -90,9 +90,9 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
tc = new TelnetClient();
- TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
- EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
- SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);
+ final TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
+ final EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
+ final SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);
try
{
@@ -100,7 +100,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
tc.addOptionHandler(echoopt);
tc.addOptionHandler(gaopt);
}
- catch (InvalidTelnetOptionException e)
+ catch (final InvalidTelnetOptionException e)
{
System.err.println("Error registering option handlers: " + e.getMessage());
}
@@ -113,7 +113,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
tc.connect(remoteip, remoteport);
- Thread reader = new Thread (new TelnetClientExample());
+ final Thread reader = new Thread (new TelnetClientExample());
tc.registerNotifHandler(new TelnetClientExample());
System.out.println("TelnetClientExample");
System.out.println("Type AYT to send an AYT telnet command");
@@ -125,9 +125,9 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
System.out.println("Type ^[A-Z] to send the control character; use ^^ to send ^");
reader.start();
- OutputStream outstr = tc.getOutputStream();
+ final OutputStream outstr = tc.getOutputStream();
- byte[] buff = new byte[1024];
+ final byte[] buff = new byte[1024];
int ret_read = 0;
do
@@ -146,7 +146,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
System.out.println("AYT response:" + tc.sendAYT(5000));
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Exception waiting AYT response: " + e.getMessage());
}
@@ -161,20 +161,20 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
}
else if(line.startsWith("REGISTER"))
{
- StringTokenizer st = new StringTokenizer(new String(buff));
+ final StringTokenizer st = new StringTokenizer(new String(buff));
try
{
st.nextToken();
- int opcode = Integer.parseInt(st.nextToken());
- boolean initlocal = Boolean.parseBoolean(st.nextToken());
- boolean initremote = Boolean.parseBoolean(st.nextToken());
- boolean acceptlocal = Boolean.parseBoolean(st.nextToken());
- boolean acceptremote = Boolean.parseBoolean(st.nextToken());
- SimpleOptionHandler opthand = new SimpleOptionHandler(opcode, initlocal, initremote,
+ final int opcode = Integer.parseInt(st.nextToken());
+ final boolean initlocal = Boolean.parseBoolean(st.nextToken());
+ final boolean initremote = Boolean.parseBoolean(st.nextToken());
+ final boolean acceptlocal = Boolean.parseBoolean(st.nextToken());
+ final boolean acceptremote = Boolean.parseBoolean(st.nextToken());
+ final SimpleOptionHandler opthand = new SimpleOptionHandler(opcode, initlocal, initremote,
acceptlocal, acceptremote);
tc.addOptionHandler(opthand);
}
- catch (Exception e)
+ catch (final Exception e)
{
if(e instanceof InvalidTelnetOptionException)
{
@@ -191,14 +191,14 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
}
else if(line.startsWith("UNREGISTER"))
{
- StringTokenizer st = new StringTokenizer(new String(buff));
+ final StringTokenizer st = new StringTokenizer(new String(buff));
try
{
st.nextToken();
- int opcode = (new Integer(st.nextToken())).intValue();
+ final int opcode = (new Integer(st.nextToken())).intValue();
tc.deleteOptionHandler(opcode);
}
- catch (Exception e)
+ catch (final Exception e)
{
if(e instanceof InvalidTelnetOptionException)
{
@@ -222,7 +222,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
}
else if(line.matches("^\\^[A-Z^]\\r?\\n?$"))
{
- byte toSend = buff[1];
+ final byte toSend = buff[1];
if (toSend == '^') {
outstr.write(toSend);
} else {
@@ -237,14 +237,14 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
outstr.write(buff, 0 , ret_read);
outstr.flush();
}
- catch (IOException e)
+ catch (final IOException e)
{
end_loop = true;
}
}
}
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Exception while reading keyboard:" + e.getMessage());
end_loop = true;
@@ -256,12 +256,12 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
{
tc.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Exception while connecting:" + e.getMessage());
}
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Exception while connecting:" + e.getMessage());
System.exit(1);
@@ -279,7 +279,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
* @param option_code - code of the option negotiated
***/
@Override
- public void receivedNegotiation(int negotiation_code, int option_code)
+ public void receivedNegotiation(final int negotiation_code, final int option_code)
{
String command = null;
switch (negotiation_code) {
@@ -313,11 +313,11 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
@Override
public void run()
{
- InputStream instr = tc.getInputStream();
+ final InputStream instr = tc.getInputStream();
try
{
- byte[] buff = new byte[1024];
+ final byte[] buff = new byte[1024];
int ret_read = 0;
do
@@ -330,7 +330,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
}
while (ret_read >= 0);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Exception while reading socket:" + e.getMessage());
}
@@ -339,7 +339,7 @@ public class TelnetClientExample implements Runnable, TelnetNotificationHandler
{
tc.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Exception while closing telnet:" + e.getMessage());
}
diff --git a/src/main/java/org/apache/commons/net/examples/telnet/WeatherTelnet.java b/src/main/java/org/apache/commons/net/examples/telnet/WeatherTelnet.java
index 3e4c560..a678a28 100644
--- a/src/main/java/org/apache/commons/net/examples/telnet/WeatherTelnet.java
+++ b/src/main/java/org/apache/commons/net/examples/telnet/WeatherTelnet.java
@@ -38,7 +38,7 @@ import org.apache.commons.net.examples.util.IOUtil;
public final class WeatherTelnet
{
- public static final void main(String[] args)
+ public static final void main(final String[] args)
{
TelnetClient telnet;
@@ -48,7 +48,7 @@ public final class WeatherTelnet
{
telnet.connect("rainmaker.wunderground.com", 3000);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -61,7 +61,7 @@ public final class WeatherTelnet
{
telnet.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/chargen.java b/src/main/java/org/apache/commons/net/examples/unix/chargen.java
index 6d62479..1f8d0f5 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/chargen.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/chargen.java
@@ -42,11 +42,11 @@ import org.apache.commons.net.chargen.CharGenUDPClient;
public final class chargen
{
- public static final void chargenTCP(String host) throws IOException
+ public static final void chargenTCP(final String host) throws IOException
{
int lines = 100;
String line;
- CharGenTCPClient client = new CharGenTCPClient();
+ final CharGenTCPClient client = new CharGenTCPClient();
BufferedReader chargenInput;
// We want to timeout if a response takes longer than 60 seconds
@@ -70,7 +70,7 @@ public final class chargen
client.disconnect();
}
- public static final void chargenUDP(String host) throws IOException
+ public static final void chargenUDP(final String host) throws IOException
{
int packets = 50;
byte[] data;
@@ -97,13 +97,13 @@ public final class chargen
// because even though the JDK 1.1 docs claim that
// InterruptedIOException is thrown on a timeout, it seems
// SocketException is also thrown.
- catch (SocketException e)
+ catch (final SocketException e)
{
// We timed out and assume the packet is lost.
System.err.println("SocketException: Timed out and dropped packet");
continue;
}
- catch (InterruptedIOException e)
+ catch (final InterruptedIOException e)
{
// We timed out and assume the packet is lost.
System.err.println(
@@ -118,7 +118,7 @@ public final class chargen
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length == 1)
@@ -127,7 +127,7 @@ public final class chargen
{
chargenTCP(args[0]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -139,7 +139,7 @@ public final class chargen
{
chargenUDP(args[1]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/daytime.java b/src/main/java/org/apache/commons/net/examples/unix/daytime.java
index 6da7d7d..9fd8c4a 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/daytime.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/daytime.java
@@ -36,9 +36,9 @@ import org.apache.commons.net.daytime.DaytimeUDPClient;
public final class daytime
{
- public static final void daytimeTCP(String host) throws IOException
+ public static final void daytimeTCP(final String host) throws IOException
{
- DaytimeTCPClient client = new DaytimeTCPClient();
+ final DaytimeTCPClient client = new DaytimeTCPClient();
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
@@ -47,9 +47,9 @@ public final class daytime
client.disconnect();
}
- public static final void daytimeUDP(String host) throws IOException
+ public static final void daytimeUDP(final String host) throws IOException
{
- DaytimeUDPClient client = new DaytimeUDPClient();
+ final DaytimeUDPClient client = new DaytimeUDPClient();
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
@@ -60,7 +60,7 @@ public final class daytime
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length == 1)
@@ -69,7 +69,7 @@ public final class daytime
{
daytimeTCP(args[0]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -81,7 +81,7 @@ public final class daytime
{
daytimeUDP(args[1]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/echo.java b/src/main/java/org/apache/commons/net/examples/unix/echo.java
index c514932..c25844e 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/echo.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/echo.java
@@ -42,9 +42,9 @@ import org.apache.commons.net.echo.EchoUDPClient;
public final class echo
{
- public static final void echoTCP(String host) throws IOException
+ public static final void echoTCP(final String host) throws IOException
{
- EchoTCPClient client = new EchoTCPClient();
+ final EchoTCPClient client = new EchoTCPClient();
BufferedReader input, echoInput;
PrintWriter echoOutput;
String line;
@@ -70,7 +70,7 @@ public final class echo
client.disconnect();
}
- public static final void echoUDP(String host) throws IOException
+ public static final void echoUDP(final String host) throws IOException
{
int length, count;
byte[] data;
@@ -105,14 +105,14 @@ public final class echo
// because even though the JDK 1.1 docs claim that
// InterruptedIOException is thrown on a timeout, it seems
// SocketException is also thrown.
- catch (SocketException e)
+ catch (final SocketException e)
{
// We timed out and assume the packet is lost.
System.err.println(
"SocketException: Timed out and dropped packet");
break;
}
- catch (InterruptedIOException e)
+ catch (final InterruptedIOException e)
{
// We timed out and assume the packet is lost.
System.err.println(
@@ -131,7 +131,7 @@ public final class echo
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length == 1)
@@ -140,7 +140,7 @@ public final class echo
{
echoTCP(args[0]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -152,7 +152,7 @@ public final class echo
{
echoUDP(args[1]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/finger.java b/src/main/java/org/apache/commons/net/examples/unix/finger.java
index b7dc2c8..bb0ad68 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/finger.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/finger.java
@@ -35,7 +35,7 @@ import org.apache.commons.net.finger.FingerClient;
public final class finger
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
boolean longOutput = false;
int arg = 0, index;
@@ -68,7 +68,7 @@ public final class finger
{
address = InetAddress.getLocalHost();
}
- catch (UnknownHostException e)
+ catch (final UnknownHostException e)
{
System.err.println("Error unknown host: " + e.getMessage());
System.exit(1);
@@ -80,7 +80,7 @@ public final class finger
System.out.print(finger.query(longOutput));
finger.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Error I/O exception: " + e.getMessage());
System.exit(1);
@@ -102,7 +102,7 @@ public final class finger
{
address = InetAddress.getLocalHost();
}
- catch (UnknownHostException e)
+ catch (final UnknownHostException e)
{
System.err.println("Error unknown host: " + e.getMessage());
System.exit(1);
@@ -118,7 +118,7 @@ public final class finger
address = InetAddress.getByName(host);
System.out.println("[" + address.getHostName() + "]");
}
- catch (UnknownHostException e)
+ catch (final UnknownHostException e)
{
System.err.println("Error unknown host: " + e.getMessage());
System.exit(1);
@@ -131,7 +131,7 @@ public final class finger
System.out.print(finger.query(longOutput, handle));
finger.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Error I/O exception: " + e.getMessage());
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/fwhois.java b/src/main/java/org/apache/commons/net/examples/unix/fwhois.java
index 4b6d1e1..8455849 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/fwhois.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/fwhois.java
@@ -30,7 +30,7 @@ import org.apache.commons.net.whois.WhoisClient;
public final class fwhois
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
int index;
String handle, host;
@@ -65,7 +65,7 @@ public final class fwhois
address = InetAddress.getByName(host);
System.out.println("[" + address.getHostName() + "]");
}
- catch (UnknownHostException e)
+ catch (final UnknownHostException e)
{
System.err.println("Error unknown host: " + e.getMessage());
System.exit(1);
@@ -77,7 +77,7 @@ public final class fwhois
System.out.print(whois.query(handle));
whois.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Error I/O exception: " + e.getMessage());
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/rdate.java b/src/main/java/org/apache/commons/net/examples/unix/rdate.java
index ab6e708..a9debab 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/rdate.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/rdate.java
@@ -37,9 +37,9 @@ import org.apache.commons.net.time.TimeUDPClient;
public final class rdate
{
- public static final void timeTCP(String host) throws IOException
+ public static final void timeTCP(final String host) throws IOException
{
- TimeTCPClient client = new TimeTCPClient();
+ final TimeTCPClient client = new TimeTCPClient();
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
@@ -48,9 +48,9 @@ public final class rdate
client.disconnect();
}
- public static final void timeUDP(String host) throws IOException
+ public static final void timeUDP(final String host) throws IOException
{
- TimeUDPClient client = new TimeUDPClient();
+ final TimeUDPClient client = new TimeUDPClient();
// We want to timeout if a response takes longer than 60 seconds
client.setDefaultTimeout(60000);
@@ -60,7 +60,7 @@ public final class rdate
}
- public static void main(String[] args)
+ public static void main(final String[] args)
{
if (args.length == 1)
@@ -69,7 +69,7 @@ public final class rdate
{
timeTCP(args[0]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -81,7 +81,7 @@ public final class rdate
{
timeUDP(args[1]);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/rexec.java b/src/main/java/org/apache/commons/net/examples/unix/rexec.java
index 5b32465..60e789d 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/rexec.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/rexec.java
@@ -39,7 +39,7 @@ import org.apache.commons.net.examples.util.IOUtil;
public final class rexec
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
String server, username, password, command;
RExecClient client;
@@ -63,7 +63,7 @@ public final class rexec
{
client.connect(server);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Could not connect to server.");
e.printStackTrace();
@@ -74,13 +74,13 @@ public final class rexec
{
client.rexec(username, password, command);
}
- catch (IOException e)
+ catch (final IOException e)
{
try
{
client.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{/* ignored */}
e.printStackTrace();
System.err.println("Could not execute command.");
@@ -95,7 +95,7 @@ public final class rexec
{
client.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/rlogin.java b/src/main/java/org/apache/commons/net/examples/unix/rlogin.java
index 4247d4a..f999889 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/rlogin.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/rlogin.java
@@ -50,7 +50,7 @@ import org.apache.commons.net.examples.util.IOUtil;
public final class rlogin
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
String server, localuser, remoteuser, terminal;
RLoginClient client;
@@ -74,7 +74,7 @@ public final class rlogin
{
client.connect(server);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Could not connect to server.");
e.printStackTrace();
@@ -85,13 +85,13 @@ public final class rlogin
{
client.rlogin(localuser, remoteuser, terminal);
}
- catch (IOException e)
+ catch (final IOException e)
{
try
{
client.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{/* ignored */}
e.printStackTrace();
System.err.println("rlogin authentication failed.");
@@ -106,7 +106,7 @@ public final class rlogin
{
client.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/unix/rshell.java b/src/main/java/org/apache/commons/net/examples/unix/rshell.java
index 862a9ea..d0946d6 100644
--- a/src/main/java/org/apache/commons/net/examples/unix/rshell.java
+++ b/src/main/java/org/apache/commons/net/examples/unix/rshell.java
@@ -43,7 +43,7 @@ import org.apache.commons.net.examples.util.IOUtil;
public final class rshell
{
- public static void main(String[] args)
+ public static void main(final String[] args)
{
String server, localuser, remoteuser, command;
RCommandClient client;
@@ -67,7 +67,7 @@ public final class rshell
{
client.connect(server);
}
- catch (IOException e)
+ catch (final IOException e)
{
System.err.println("Could not connect to server.");
e.printStackTrace();
@@ -78,13 +78,13 @@ public final class rshell
{
client.rcommand(localuser, remoteuser, command);
}
- catch (IOException e)
+ catch (final IOException e)
{
try
{
client.disconnect();
}
- catch (IOException f)
+ catch (final IOException f)
{/* ignored */}
e.printStackTrace();
System.err.println("Could not execute command.");
@@ -99,7 +99,7 @@ public final class rshell
{
client.disconnect();
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
diff --git a/src/main/java/org/apache/commons/net/examples/util/IOUtil.java b/src/main/java/org/apache/commons/net/examples/util/IOUtil.java
index cedbb95..cd8738c 100644
--- a/src/main/java/org/apache/commons/net/examples/util/IOUtil.java
+++ b/src/main/java/org/apache/commons/net/examples/util/IOUtil.java
@@ -58,7 +58,7 @@ public final class IOUtil
remoteOutput.flush();
}
}
- catch (IOException e)
+ catch (final IOException e)
{
//e.printStackTrace();
}
@@ -76,7 +76,7 @@ public final class IOUtil
{
Util.copyStream(remoteInput, localOutput);
}
- catch (IOException e)
+ catch (final IOException e)
{
e.printStackTrace();
System.exit(1);
@@ -96,7 +96,7 @@ public final class IOUtil
writer.join();
reader.interrupt();
}
- catch (InterruptedException e)
+ catch (final InterruptedException e)
{
// Ignored
}
diff --git a/src/main/java/org/apache/commons/net/finger/FingerClient.java b/src/main/java/org/apache/commons/net/finger/FingerClient.java
index 7655917..11c7654 100644
--- a/src/main/java/org/apache/commons/net/finger/FingerClient.java
+++ b/src/main/java/org/apache/commons/net/finger/FingerClient.java
@@ -81,10 +81,10 @@ public class FingerClient extends SocketClient
* @return The result of the finger query.
* @throws IOException If an I/O error occurs while reading the socket.
***/
- public String query(boolean longOutput, String username) throws IOException
+ public String query(final boolean longOutput, final String username) throws IOException
{
int read;
- StringBuilder result = new StringBuilder(__buffer.length);
+ final StringBuilder result = new StringBuilder(__buffer.length);
BufferedReader input;
input =
@@ -118,7 +118,7 @@ public class FingerClient extends SocketClient
* @return The result of the finger query.
* @throws IOException If an I/O error occurs while reading the socket.
***/
- public String query(boolean longOutput) throws IOException
+ public String query(final boolean longOutput) throws IOException
{
return query(longOutput, "");
}
@@ -136,7 +136,7 @@ public class FingerClient extends SocketClient
* Can be read to obtain finger results.
* @throws IOException If an I/O error during the operation.
***/
- public InputStream getInputStream(boolean longOutput, String username)
+ public InputStream getInputStream(final boolean longOutput, final String username)
throws IOException
{
return getInputStream(longOutput, username, null);
@@ -156,11 +156,11 @@ public class FingerClient extends SocketClient
* Can be read to obtain finger results.
* @throws IOException If an I/O error during the operation.
***/
- public InputStream getInputStream(boolean longOutput, String username, String encoding)
+ public InputStream getInputStream(final boolean longOutput, final String username, final String encoding)
throws IOException
{
DataOutputStream output;
- StringBuilder buffer = new StringBuilder(64);
+ final StringBuilder buffer = new StringBuilder(64);
if (longOutput) {
buffer.append(__LONG_FLAG);
}
@@ -168,7 +168,7 @@ public class FingerClient extends SocketClient
buffer.append(SocketClient.NETASCII_EOL);
// Note: Charsets.toCharset() returns the platform default for null input
- byte[] encodedQuery = buffer.toString().getBytes(Charsets.toCharset(encoding).name()); // Java 1.6 can use charset directly
+ final byte[] encodedQuery = buffer.toString().getBytes(Charsets.toCharset(encoding).name()); // Java 1.6 can use charset directly
output = new DataOutputStream(new BufferedOutputStream(_output_, 1024));
output.write(encodedQuery, 0, encodedQuery.length);
@@ -190,7 +190,7 @@ public class FingerClient extends SocketClient
* Can be read to obtain finger results.
* @throws IOException If an I/O error during the operation.
***/
- public InputStream getInputStream(boolean longOutput) throws IOException
+ public InputStream getInputStream(final boolean longOutput) throws IOException
{
return getInputStream(longOutput, "");
}
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 8745692..21c2ee7 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTP.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTP.java
@@ -277,7 +277,7 @@ public class FTP extends SocketClient
}
// The RFC-compliant multiline termination check
- private boolean __strictCheck(String line, String code) {
+ private boolean __strictCheck(final String line, final String code) {
return (!(line.startsWith(code) && line.charAt(REPLY_CODE_LEN) == ' '));
}
@@ -286,7 +286,7 @@ 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(String line) {
+ private boolean __lenientCheck(final String line) {
return (!(line.length() > REPLY_CODE_LEN&& line.charAt(REPLY_CODE_LEN) != '-' &&
Character.isDigit(line.charAt(0))));
}
@@ -310,7 +310,7 @@ public class FTP extends SocketClient
__getReply(false);
}
- private void __getReply(boolean reportReply) throws IOException
+ private void __getReply(final boolean reportReply) throws IOException
{
int length;
@@ -338,7 +338,7 @@ public class FTP extends SocketClient
code = line.substring(0, REPLY_CODE_LEN);
_replyCode = Integer.parseInt(code);
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse response code.\nServer Reply: " + line);
@@ -348,7 +348,7 @@ public class FTP extends SocketClient
// Check the server reply type
if (length > REPLY_CODE_LEN) {
- char sep = line.charAt(REPLY_CODE_LEN);
+ final char sep = line.charAt(REPLY_CODE_LEN);
// Get extra lines if message continues.
if (sep == '-') {
do
@@ -407,7 +407,7 @@ public class FTP extends SocketClient
* @throws IOException on error
* @since 3.4
*/
- protected void _connectAction_(Reader socketIsReader) throws IOException {
+ protected void _connectAction_(final Reader socketIsReader) throws IOException {
super._connectAction_(); // sets up _input_ and _output_
if(socketIsReader == null) {
_controlInput_ =
@@ -418,7 +418,7 @@ public class FTP extends SocketClient
_controlOutput_ =
new BufferedWriter(new OutputStreamWriter(_output_, getControlEncoding()));
if (connectTimeout > 0) { // NET-385
- int original = _socket_.getSoTimeout();
+ final int original = _socket_.getSoTimeout();
_socket_.setSoTimeout(connectTimeout);
try {
__getReply();
@@ -426,8 +426,8 @@ public class FTP extends SocketClient
if (FTPReply.isPositivePreliminary(_replyCode)) {
__getReply();
}
- } catch (SocketTimeoutException e) {
- IOException ioe = new IOException("Timed out waiting for initial connect reply");
+ } catch (final SocketTimeoutException e) {
+ final IOException ioe = new IOException("Timed out waiting for initial connect reply");
ioe.initCause(e);
throw ioe;
} finally {
@@ -453,7 +453,7 @@ public class FTP extends SocketClient
*
* @param encoding The new character encoding for the control connection.
*/
- public void setControlEncoding(String encoding) {
+ public void setControlEncoding(final String encoding) {
_controlEncoding = encoding;
}
@@ -507,7 +507,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(String command, String args) throws IOException
+ public int sendCommand(final String command, final String args) throws IOException
{
if (_controlOutput_ == null) {
throw new IOException("Connection is not open");
@@ -523,7 +523,7 @@ public class FTP extends SocketClient
return _replyCode;
}
- private String __buildMessage(String command, String args) {
+ private String __buildMessage(final String command, final String args) {
final StringBuilder __commandBuffer = new StringBuilder();
__commandBuffer.append(command);
@@ -537,13 +537,13 @@ public class FTP extends SocketClient
return __commandBuffer.toString();
}
- private void __send(String message) throws IOException,
+ private void __send(final String message) throws IOException,
FTPConnectionClosedException, SocketException {
try{
_controlOutput_.write(message);
_controlOutput_.flush();
}
- catch (SocketException e)
+ catch (final SocketException e)
{
if (!isConnected())
{
@@ -564,7 +564,7 @@ public class FTP extends SocketClient
* @since 3.0
*/
protected void __noop() throws IOException {
- String msg = __buildMessage(FTPCmd.NOOP.getCommand(), null);
+ final String msg = __buildMessage(FTPCmd.NOOP.getCommand(), null);
__send(msg);
__getReplyNoReport(); // This may timeout
}
@@ -592,7 +592,7 @@ public class FTP extends SocketClient
* @deprecated (3.3) Use {@link #sendCommand(FTPCmd, String)} instead
***/
@Deprecated
- public int sendCommand(int command, String args) throws IOException
+ public int sendCommand(final int command, final String args) throws IOException
{
return sendCommand(FTPCommand.getCommand(command), args);
}
@@ -617,7 +617,7 @@ public class FTP extends SocketClient
* command or receiving the server reply.
* @since 3.3
*/
- public int sendCommand(FTPCmd command) throws IOException{
+ public int sendCommand(final FTPCmd command) throws IOException{
return sendCommand(command, null);
}
@@ -643,7 +643,7 @@ public class FTP extends SocketClient
* command or receiving the server reply.
* @since 3.3
*/
- public int sendCommand(FTPCmd command, String args) throws IOException{
+ public int sendCommand(final FTPCmd command, final String args) throws IOException{
return sendCommand(command.getCommand(), args);
}
@@ -665,7 +665,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(String command) throws IOException
+ public int sendCommand(final String command) throws IOException
{
return sendCommand(command, null);
}
@@ -690,7 +690,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(int command) throws IOException
+ public int sendCommand(final int command) throws IOException
{
return sendCommand(command, null);
}
@@ -762,7 +762,7 @@ public class FTP extends SocketClient
buffer = new StringBuilder(256);
- for (String line : _replyLines) {
+ for (final String line : _replyLines) {
buffer.append(line);
buffer.append(SocketClient.NETASCII_EOL);
}
@@ -787,7 +787,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int user(String username) throws IOException
+ public int user(final String username) throws IOException
{
return sendCommand(FTPCmd.USER, username);
}
@@ -805,7 +805,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
*/
- public int pass(String password) throws IOException
+ public int pass(final String password) throws IOException
{
return sendCommand(FTPCmd.PASS, password);
}
@@ -824,7 +824,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int acct(String account) throws IOException
+ public int acct(final String account) throws IOException
{
return sendCommand(FTPCmd.ACCT, account);
}
@@ -862,7 +862,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int cwd(String directory) throws IOException
+ public int cwd(final String directory) throws IOException
{
return sendCommand(FTPCmd.CWD, directory);
}
@@ -935,7 +935,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int smnt(String dir) throws IOException
+ public int smnt(final String dir) throws IOException
{
return sendCommand(FTPCmd.SMNT, dir);
}
@@ -955,10 +955,10 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int port(InetAddress host, int port) throws IOException
+ public int port(final InetAddress host, final int port) throws IOException
{
int num;
- StringBuilder info = new StringBuilder(24);
+ final StringBuilder info = new StringBuilder(24);
info.append(host.getHostAddress().replace('.', ','));
num = port >>> 8;
@@ -995,10 +995,10 @@ public class FTP extends SocketClient
* command or receiving the server reply.
* @since 2.2
***/
- public int eprt(InetAddress host, int port) throws IOException
+ public int eprt(final InetAddress host, final int port) throws IOException
{
int num;
- StringBuilder info = new StringBuilder();
+ final StringBuilder info = new StringBuilder();
String h;
// If IPv6, trim the zone index
@@ -1082,9 +1082,9 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
*/
- public int type(int fileType, int formatOrByteSize) throws IOException
+ public int type(final int fileType, final int formatOrByteSize) throws IOException
{
- StringBuilder arg = new StringBuilder();
+ final StringBuilder arg = new StringBuilder();
arg.append(__modes.charAt(fileType));
arg.append(' ');
@@ -1113,7 +1113,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
*/
- public int type(int fileType) throws IOException
+ public int type(final int fileType) throws IOException
{
return sendCommand(FTPCmd.TYPE,
__modes.substring(fileType, fileType + 1));
@@ -1134,7 +1134,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int stru(int structure) throws IOException
+ public int stru(final int structure) throws IOException
{
return sendCommand(FTPCmd.STRU,
__modes.substring(structure, structure + 1));
@@ -1155,7 +1155,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int mode(int mode) throws IOException
+ public int mode(final int mode) throws IOException
{
return sendCommand(FTPCmd.MODE,
__modes.substring(mode, mode + 1));
@@ -1178,7 +1178,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int retr(String pathname) throws IOException
+ public int retr(final String pathname) throws IOException
{
return sendCommand(FTPCmd.RETR, pathname);
}
@@ -1201,7 +1201,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int stor(String pathname) throws IOException
+ public int stor(final String pathname) throws IOException
{
return sendCommand(FTPCmd.STOR, pathname);
}
@@ -1245,7 +1245,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
*/
- public int stou(String pathname) throws IOException
+ public int stou(final String pathname) throws IOException
{
return sendCommand(FTPCmd.STOU, pathname);
}
@@ -1268,7 +1268,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int appe(String pathname) throws IOException
+ public int appe(final String pathname) throws IOException
{
return sendCommand(FTPCmd.APPE, pathname);
}
@@ -1287,7 +1287,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int allo(int bytes) throws IOException
+ public int allo(final int bytes) throws IOException
{
return sendCommand(FTPCmd.ALLO, Integer.toString(bytes));
}
@@ -1306,7 +1306,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int allo(long bytes) throws IOException
+ public int allo(final long bytes) throws IOException
{
return sendCommand(FTPCmd.ALLO, Long.toString(bytes));
}
@@ -1339,7 +1339,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int allo(int bytes, int recordSize) throws IOException
+ public int allo(final int bytes, final int recordSize) throws IOException
{
return sendCommand(FTPCmd.ALLO, Integer.toString(bytes) + " R " +
Integer.toString(recordSize));
@@ -1360,7 +1360,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int allo(long bytes, int recordSize) throws IOException
+ public int allo(final long bytes, final int recordSize) throws IOException
{
return sendCommand(FTPCmd.ALLO, Long.toString(bytes) + " R " +
Integer.toString(recordSize));
@@ -1380,7 +1380,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int rest(String marker) throws IOException
+ public int rest(final String marker) throws IOException
{
return sendCommand(FTPCmd.REST, marker);
}
@@ -1392,7 +1392,7 @@ public class FTP extends SocketClient
* @throws IOException on error
* @since 2.0
**/
- public int mdtm(String file) throws IOException
+ public int mdtm(final String file) throws IOException
{
return sendCommand(FTPCmd.MDTM, file);
}
@@ -1415,7 +1415,7 @@ public class FTP extends SocketClient
* @since 2.2
* @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04</a>
**/
- public int mfmt(String pathname, String timeval) throws IOException
+ public int mfmt(final String pathname, final String timeval) throws IOException
{
return sendCommand(FTPCmd.MFMT, timeval + " " + pathname);
}
@@ -1435,7 +1435,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int rnfr(String pathname) throws IOException
+ public int rnfr(final String pathname) throws IOException
{
return sendCommand(FTPCmd.RNFR, pathname);
}
@@ -1454,7 +1454,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int rnto(String pathname) throws IOException
+ public int rnto(final String pathname) throws IOException
{
return sendCommand(FTPCmd.RNTO, pathname);
}
@@ -1473,7 +1473,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int dele(String pathname) throws IOException
+ public int dele(final String pathname) throws IOException
{
return sendCommand(FTPCmd.DELE, pathname);
}
@@ -1492,7 +1492,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int rmd(String pathname) throws IOException
+ public int rmd(final String pathname) throws IOException
{
return sendCommand(FTPCmd.RMD, pathname);
}
@@ -1511,7 +1511,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int mkd(String pathname) throws IOException
+ public int mkd(final String pathname) throws IOException
{
return sendCommand(FTPCmd.MKD, pathname);
}
@@ -1573,7 +1573,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int list(String pathname) throws IOException
+ public int list(final String pathname) throws IOException
{
return sendCommand(FTPCmd.LIST, pathname);
}
@@ -1619,7 +1619,7 @@ public class FTP extends SocketClient
* command or receiving the server reply.
* @since 3.0
*/
- public int mlsd(String path) throws IOException
+ public int mlsd(final String path) throws IOException
{
return sendCommand(FTPCmd.MLSD, path);
}
@@ -1665,7 +1665,7 @@ public class FTP extends SocketClient
* command or receiving the server reply.
* @since 3.0
*/
- public int mlst(String path) throws IOException
+ public int mlst(final String path) throws IOException
{
return sendCommand(FTPCmd.MLST, path);
}
@@ -1709,7 +1709,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int nlst(String pathname) throws IOException
+ public int nlst(final String pathname) throws IOException
{
return sendCommand(FTPCmd.NLST, pathname);
}
@@ -1728,7 +1728,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int site(String parameters) throws IOException
+ public int site(final String parameters) throws IOException
{
return sendCommand(FTPCmd.SITE, parameters);
}
@@ -1748,7 +1748,7 @@ public class FTP extends SocketClient
* command or receiving the server reply.
* @since 3.7
***/
- public int size(String parameters) throws IOException
+ public int size(final String parameters) throws IOException
{
return sendCommand(FTPCmd.SIZE, parameters);
}
@@ -1803,7 +1803,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int stat(String pathname) throws IOException
+ public int stat(final String pathname) throws IOException
{
return sendCommand(FTPCmd.STAT, pathname);
}
@@ -1840,7 +1840,7 @@ public class FTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int help(String command) throws IOException
+ public int help(final String command) throws IOException
{
return sendCommand(FTPCmd.HELP, command);
}
@@ -1877,7 +1877,7 @@ public class FTP extends SocketClient
* @param strictMultilineParsing the setting
* @since 2.0
*/
- public void setStrictMultilineParsing(boolean strictMultilineParsing) {
+ public void setStrictMultilineParsing(final boolean strictMultilineParsing) {
this.strictMultilineParsing = strictMultilineParsing;
}
@@ -1907,7 +1907,7 @@ public class FTP extends SocketClient
* @param strictReplyParsing the setting
* @since 3.6
*/
- public void setStrictReplyParsing(boolean strictReplyParsing) {
+ public void setStrictReplyParsing(final boolean strictReplyParsing) {
this.strictReplyParsing = strictReplyParsing;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
index 4555e62..19d4e2b 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
@@ -435,18 +435,18 @@ implements Configurable
static final Properties PROPERTIES;
static {
- InputStream resourceAsStream = FTPClient.class.getResourceAsStream(SYSTEM_TYPE_PROPERTIES);
+ final InputStream resourceAsStream = FTPClient.class.getResourceAsStream(SYSTEM_TYPE_PROPERTIES);
Properties p = null;
if (resourceAsStream != null) {
p = new Properties();
try {
p.load(resourceAsStream);
- } catch (IOException e) {
+ } catch (final IOException e) {
// Ignored
} finally {
try {
resourceAsStream.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Ignored
}
}
@@ -528,15 +528,15 @@ implements Configurable
* (i.e. enclosing quotes are missing or embedded quotes are not doubled)
*/
// package protected for access by test cases
- static String __parsePathname(String reply)
+ static String __parsePathname(final String reply)
{
- String param = reply.substring(REPLY_CODE_LEN + 1);
+ final String param = reply.substring(REPLY_CODE_LEN + 1);
if (param.startsWith("\"")) {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
boolean quoteSeen = false;
// start after initial quote
for(int i=1; i < param.length(); i++) {
- char ch = param.charAt(i);
+ final char ch = param.charAt(i);
if (ch=='"') {
if (quoteSeen) {
sb.append(ch);
@@ -565,10 +565,10 @@ implements Configurable
* @param reply the reply to parse
* @throws MalformedServerReplyException if the server reply does not match (n,n,n,n),(n),(n)
*/
- protected void _parsePassiveModeReply(String reply)
+ protected void _parsePassiveModeReply(final String reply)
throws MalformedServerReplyException
{
- java.util.regex.Matcher m = __PARMS_PAT.matcher(reply);
+ final java.util.regex.Matcher m = __PARMS_PAT.matcher(reply);
if (!m.find()) {
throw new MalformedServerReplyException(
"Could not parse passive host information.\nServer Reply: " + reply);
@@ -579,11 +579,11 @@ implements Configurable
try
{
- int oct1 = Integer.parseInt(m.group(2));
- int oct2 = Integer.parseInt(m.group(3));
+ final int oct1 = Integer.parseInt(m.group(2));
+ final int oct2 = Integer.parseInt(m.group(3));
__passivePort = (oct1 << 8) | oct2;
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse passive port information.\nServer Reply: " + reply);
@@ -591,13 +591,13 @@ implements Configurable
if (__passiveNatWorkaroundStrategy != null) {
try {
- String passiveHost = __passiveNatWorkaroundStrategy.resolve(__passiveHost);
+ final String passiveHost = __passiveNatWorkaroundStrategy.resolve(__passiveHost);
if (!__passiveHost.equals(passiveHost)) {
fireReplyReceived(0,
"[Replacing PASV mode reply address "+__passiveHost+" with "+passiveHost+"]\n");
__passiveHost = passiveHost;
}
- } catch (UnknownHostException e) { // Should not happen as we are passing in an IP address
+ } catch (final UnknownHostException e) { // Should not happen as we are passing in an IP address
throw new MalformedServerReplyException(
"Could not parse passive host information.\nServer Reply: " + reply);
}
@@ -627,7 +627,7 @@ implements Configurable
{
port = Integer.parseInt(reply.substring(3, reply.length()-1));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse extended passive host information.\nServer Reply: " + reply);
@@ -639,7 +639,7 @@ implements Configurable
__passivePort = port;
}
- private boolean __storeFile(FTPCmd command, String remote, InputStream local)
+ private boolean __storeFile(final FTPCmd command, final String remote, final InputStream local)
throws IOException
{
return _storeFile(command.getCommand(), remote, local);
@@ -654,10 +654,10 @@ implements Configurable
* @return true if successful
* @throws IOException on error
*/
- protected boolean _storeFile(String command, String remote, InputStream local)
+ protected boolean _storeFile(final String command, final String remote, final InputStream local)
throws IOException
{
- Socket socket = _openDataConnection_(command, remote);
+ final Socket socket = _openDataConnection_(command, remote);
if (socket == null) {
return false;
@@ -688,7 +688,7 @@ implements Configurable
// Get the transfer response
return completePendingCommand();
}
- catch (IOException e)
+ catch (final IOException e)
{
Util.closeQuietly(output); // ignore close errors here
Util.closeQuietly(socket); // ignore close errors here
@@ -700,7 +700,7 @@ implements Configurable
}
}
- private OutputStream __storeFileStream(FTPCmd command, String remote)
+ private OutputStream __storeFileStream(final FTPCmd command, final String remote)
throws IOException
{
return _storeFileStream(command.getCommand(), remote);
@@ -713,10 +713,10 @@ implements Configurable
* @throws IOException on error
* @since 3.1
*/
- protected OutputStream _storeFileStream(String command, String remote)
+ protected OutputStream _storeFileStream(final String command, final String remote)
throws IOException
{
- Socket socket = _openDataConnection_(command, remote);
+ final Socket socket = _openDataConnection_(command, remote);
if (socket == null) {
return null;
@@ -759,7 +759,7 @@ implements Configurable
* @deprecated (3.3) Use {@link #_openDataConnection_(FTPCmd, String)} instead
*/
@Deprecated
- protected Socket _openDataConnection_(int command, String arg)
+ protected Socket _openDataConnection_(final int command, final String arg)
throws IOException
{
return _openDataConnection_(FTPCommand.getCommand(command), arg);
@@ -784,7 +784,7 @@ implements Configurable
* command to the server or receiving a reply from the server.
* @since 3.3
*/
- protected Socket _openDataConnection_(FTPCmd command, String arg)
+ protected Socket _openDataConnection_(final FTPCmd command, final String arg)
throws IOException
{
return _openDataConnection_(command.getCommand(), arg);
@@ -809,7 +809,7 @@ implements Configurable
* command to the server or receiving a reply from the server.
* @since 3.1
*/
- protected Socket _openDataConnection_(String command, String arg)
+ protected Socket _openDataConnection_(final String command, final String arg)
throws IOException
{
if (__dataConnectionMode != ACTIVE_LOCAL_DATA_CONNECTION_MODE &&
@@ -825,7 +825,7 @@ implements Configurable
{
// if no activePortRange was set (correctly) -> getActivePort() = 0
// -> new ServerSocket(0) -> bind to any free local port
- ServerSocket server = _serverSocketFactory_.createServerSocket(getActivePort(), 1, getHostAddress());
+ final ServerSocket server = _serverSocketFactory_.createServerSocket(getActivePort(), 1, getHostAddress());
try {
// Try EPRT only if remote server is over IPv6, if not use PORT,
@@ -886,7 +886,7 @@ implements Configurable
// and the client is coming from another internal network.
// In that case the data connection after PASV command would fail,
// while EPSV would make the client succeed by taking just the port.
- boolean attemptEPSV = isUseEPSVwithIPv4() || isInet6Address;
+ final boolean attemptEPSV = isUseEPSVwithIPv4() || isInet6Address;
if (attemptEPSV && epsv() == FTPReply.ENTERING_EPSV_MODE)
{
_parseExtendedPassiveModeReply(_replyLines.get(0));
@@ -939,7 +939,7 @@ implements Configurable
if (__remoteVerificationEnabled && !verifyRemote(socket))
{
// Grab the host before we close the socket to avoid NET-663
- InetAddress socketHost = socket.getInetAddress();
+ final InetAddress socketHost = socket.getInetAddress();
socket.close();
@@ -965,7 +965,7 @@ implements Configurable
* @since 3.4
*/
@Override
- protected void _connectAction_(Reader socketIsReader) throws IOException
+ protected void _connectAction_(final Reader socketIsReader) throws IOException
{
super._connectAction_(socketIsReader); // sets up _input_ and _output_
__initDefaults();
@@ -973,8 +973,8 @@ implements Configurable
// Exception claiming we're not connected
if ( __autodetectEncoding )
{
- ArrayList<String> oldReplyLines = new ArrayList<> (_replyLines);
- int oldReplyCode = _replyCode;
+ final ArrayList<String> oldReplyLines = new ArrayList<> (_replyLines);
+ final int oldReplyCode = _replyCode;
if ( hasFeature("UTF8") || hasFeature("UTF-8")) // UTF8 appears to be the default
{
setControlEncoding("UTF-8");
@@ -1002,7 +1002,7 @@ implements Configurable
* @param timeout The default timeout in milliseconds that is used when
* opening a data connection socket. The value 0 means an infinite timeout.
*/
- public void setDataTimeout(int timeout)
+ public void setDataTimeout(final int timeout)
{
__dataTimeout = timeout;
}
@@ -1016,7 +1016,7 @@ implements Configurable
* @see org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory
* @see org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory
*/
- public void setParserFactory(FTPFileEntryParserFactory parserFactory) {
+ public void setParserFactory(final FTPFileEntryParserFactory parserFactory) {
__parserFactory = parserFactory;
}
@@ -1044,7 +1044,7 @@ implements Configurable
*
* @param enable True to enable verification, false to disable verification.
*/
- public void setRemoteVerificationEnabled(boolean enable)
+ public void setRemoteVerificationEnabled(final boolean enable)
{
__remoteVerificationEnabled = enable;
}
@@ -1075,7 +1075,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean login(String username, String password) throws IOException
+ public boolean login(final String username, final String password) throws IOException
{
user(username);
@@ -1111,7 +1111,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean login(String username, String password, String account)
+ public boolean login(final String username, final String password, final String account)
throws IOException
{
user(username);
@@ -1170,7 +1170,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean changeWorkingDirectory(String pathname) throws IOException
+ public boolean changeWorkingDirectory(final String pathname) throws IOException
{
return FTPReply.isPositiveCompletion(cwd(pathname));
}
@@ -1207,7 +1207,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean structureMount(String pathname) throws IOException
+ public boolean structureMount(final String pathname) throws IOException
{
return FTPReply.isPositiveCompletion(smnt(pathname));
}
@@ -1310,7 +1310,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean enterRemoteActiveMode(InetAddress host, int port)
+ public boolean enterRemoteActiveMode(final InetAddress host, final int port)
throws IOException
{
if (FTPReply.isPositiveCompletion(port(host, port)))
@@ -1468,7 +1468,7 @@ implements Configurable
* @param maxPort The highest available port (inclusive).
* @since 2.2
*/
- public void setActivePortRange(int minPort, int maxPort)
+ public void setActivePortRange(final int minPort, final int maxPort)
{
this.__activeMinPort = minPort;
this.__activeMaxPort = maxPort;
@@ -1482,7 +1482,7 @@ implements Configurable
* @throws UnknownHostException if the ipAddress cannot be resolved
* @since 2.2
*/
- public void setActiveExternalIPAddress(String ipAddress) throws UnknownHostException
+ public void setActiveExternalIPAddress(final String ipAddress) throws UnknownHostException
{
this.__activeExternalHost = InetAddress.getByName(ipAddress);
}
@@ -1494,7 +1494,7 @@ implements Configurable
* @param ipAddress The local IP address of this machine.
* @throws UnknownHostException if the ipAddress cannot be resolved
*/
- public void setPassiveLocalIPAddress(String ipAddress) throws UnknownHostException
+ public void setPassiveLocalIPAddress(final String ipAddress) throws UnknownHostException
{
this.__passiveLocalHost = InetAddress.getByName(ipAddress);
}
@@ -1505,7 +1505,7 @@ implements Configurable
*
* @param inetAddress The local IP address of this machine.
*/
- public void setPassiveLocalIPAddress(InetAddress inetAddress)
+ public void setPassiveLocalIPAddress(final InetAddress inetAddress)
{
this.__passiveLocalHost = inetAddress;
}
@@ -1530,7 +1530,7 @@ implements Configurable
* @since 3.1
* @see #getReportHostAddress()
*/
- public void setReportActiveExternalIPAddress(String ipAddress) throws UnknownHostException
+ public void setReportActiveExternalIPAddress(final String ipAddress) throws UnknownHostException
{
this.__reportActiveExternalHost = InetAddress.getByName(ipAddress);
}
@@ -1562,7 +1562,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean setFileType(int fileType) throws IOException
+ public boolean setFileType(final int fileType) throws IOException
{
if (FTPReply.isPositiveCompletion(type(fileType)))
{
@@ -1610,7 +1610,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean setFileType(int fileType, int formatOrByteSize)
+ public boolean setFileType(final int fileType, final int formatOrByteSize)
throws IOException
{
if (FTPReply.isPositiveCompletion(type(fileType, formatOrByteSize)))
@@ -1639,7 +1639,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean setFileStructure(int structure) throws IOException
+ public boolean setFileStructure(final int structure) throws IOException
{
if (FTPReply.isPositiveCompletion(stru(structure)))
{
@@ -1666,7 +1666,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean setFileTransferMode(int mode) throws IOException
+ public boolean setFileTransferMode(final int mode) throws IOException
{
if (FTPReply.isPositiveCompletion(mode(mode)))
{
@@ -1692,7 +1692,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean remoteRetrieve(String fileName) throws IOException
+ public boolean remoteRetrieve(final String fileName) throws IOException
{
if (__dataConnectionMode == ACTIVE_REMOTE_DATA_CONNECTION_MODE ||
__dataConnectionMode == PASSIVE_REMOTE_DATA_CONNECTION_MODE) {
@@ -1719,7 +1719,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean remoteStore(String fileName) throws IOException
+ public boolean remoteStore(final String fileName) throws IOException
{
if (__dataConnectionMode == ACTIVE_REMOTE_DATA_CONNECTION_MODE ||
__dataConnectionMode == PASSIVE_REMOTE_DATA_CONNECTION_MODE) {
@@ -1747,7 +1747,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean remoteStoreUnique(String fileName) throws IOException
+ public boolean remoteStoreUnique(final String fileName) throws IOException
{
if (__dataConnectionMode == ACTIVE_REMOTE_DATA_CONNECTION_MODE ||
__dataConnectionMode == PASSIVE_REMOTE_DATA_CONNECTION_MODE) {
@@ -1803,7 +1803,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean remoteAppend(String fileName) throws IOException
+ public boolean remoteAppend(final String fileName) throws IOException
{
if (__dataConnectionMode == ACTIVE_REMOTE_DATA_CONNECTION_MODE ||
__dataConnectionMode == PASSIVE_REMOTE_DATA_CONNECTION_MODE) {
@@ -1887,7 +1887,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean retrieveFile(String remote, OutputStream local)
+ public boolean retrieveFile(final String remote, final OutputStream local)
throws IOException
{
return _retrieveFile(FTPCmd.RETR.getCommand(), remote, local);
@@ -1901,10 +1901,10 @@ implements Configurable
* @throws IOException on error
* @since 3.1
*/
- protected boolean _retrieveFile(String command, String remote, OutputStream local)
+ protected boolean _retrieveFile(final String command, final String remote, final OutputStream local)
throws IOException
{
- Socket socket = _openDataConnection_(command, remote);
+ final Socket socket = _openDataConnection_(command, remote);
if (socket == null) {
return false;
@@ -1969,7 +1969,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public InputStream retrieveFileStream(String remote) throws IOException
+ public InputStream retrieveFileStream(final String remote) throws IOException
{
return _retrieveFileStream(FTPCmd.RETR.getCommand(), remote);
}
@@ -1981,10 +1981,10 @@ implements Configurable
* @throws IOException on error
* @since 3.1
*/
- protected InputStream _retrieveFileStream(String command, String remote)
+ protected InputStream _retrieveFileStream(final String command, final String remote)
throws IOException
{
- Socket socket = _openDataConnection_(command, remote);
+ final Socket socket = _openDataConnection_(command, remote);
if (socket == null) {
return null;
@@ -2031,7 +2031,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean storeFile(String remote, InputStream local)
+ public boolean storeFile(final String remote, final InputStream local)
throws IOException
{
return __storeFile(FTPCmd.STOR, remote, local);
@@ -2066,7 +2066,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public OutputStream storeFileStream(String remote) throws IOException
+ public OutputStream storeFileStream(final String remote) throws IOException
{
return __storeFileStream(FTPCmd.STOR, remote);
}
@@ -2096,7 +2096,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean appendFile(String remote, InputStream local)
+ public boolean appendFile(final String remote, final InputStream local)
throws IOException
{
return __storeFile(FTPCmd.APPE, remote, local);
@@ -2130,7 +2130,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public OutputStream appendFileStream(String remote) throws IOException
+ public OutputStream appendFileStream(final String remote) throws IOException
{
return __storeFileStream(FTPCmd.APPE, remote);
}
@@ -2161,7 +2161,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean storeUniqueFile(String remote, InputStream local)
+ public boolean storeUniqueFile(final String remote, final InputStream local)
throws IOException
{
return __storeFile(FTPCmd.STOU, remote, local);
@@ -2198,7 +2198,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public OutputStream storeUniqueFileStream(String remote) throws IOException
+ public OutputStream storeUniqueFileStream(final String remote) throws IOException
{
return __storeFileStream(FTPCmd.STOU, remote);
}
@@ -2227,7 +2227,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean storeUniqueFile(InputStream local) throws IOException
+ public boolean storeUniqueFile(final InputStream local) throws IOException
{
return __storeFile(FTPCmd.STOU, null, local);
}
@@ -2278,7 +2278,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean allocate(int bytes) throws IOException
+ public boolean allocate(final int bytes) throws IOException
{
return FTPReply.isPositiveCompletion(allo(bytes));
}
@@ -2296,7 +2296,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean allocate(long bytes) throws IOException
+ public boolean allocate(final long bytes) throws IOException
{
return FTPReply.isPositiveCompletion(allo(bytes));
}
@@ -2333,11 +2333,11 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public String[] featureValues(String feature) throws IOException {
+ public String[] featureValues(final String feature) throws IOException {
if (!initFeatureMap()) {
return null;
}
- Set<String> entries = __featuresMap.get(feature.toUpperCase(Locale.ENGLISH));
+ final Set<String> entries = __featuresMap.get(feature.toUpperCase(Locale.ENGLISH));
if (entries != null) {
return entries.toArray(new String[entries.size()]);
}
@@ -2356,8 +2356,8 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public String featureValue(String feature) throws IOException {
- String [] values = featureValues(feature);
+ public String featureValue(final String feature) throws IOException {
+ final String [] values = featureValues(feature);
if (values != null) {
return values[0];
}
@@ -2376,7 +2376,7 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public boolean hasFeature(String feature) throws IOException {
+ public boolean hasFeature(final String feature) throws IOException {
if (!initFeatureMap()) {
return false;
}
@@ -2398,11 +2398,11 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public boolean hasFeature(String feature, String value) throws IOException {
+ public boolean hasFeature(final String feature, final String value) throws IOException {
if (!initFeatureMap()) {
return false;
}
- Set<String> entries = __featuresMap.get(feature.toUpperCase(Locale.ENGLISH));
+ final Set<String> entries = __featuresMap.get(feature.toUpperCase(Locale.ENGLISH));
if (entries != null) {
return entries.contains(value);
}
@@ -2419,17 +2419,17 @@ implements Configurable
if (replyCode == FTPReply.NOT_LOGGED_IN) { // 503
return false; // NET-518; don't create empy map
}
- boolean success = FTPReply.isPositiveCompletion(replyCode);
+ final boolean success = FTPReply.isPositiveCompletion(replyCode);
// we init the map here, so we don't keep trying if we know the command will fail
__featuresMap = new HashMap<>();
if (!success) {
return false;
}
- for (String l : getReplyStrings()) {
+ for (final String l : getReplyStrings()) {
if (l.startsWith(" ")) { // it's a FEAT entry
String key;
String value="";
- int varsep = l.indexOf(' ', 1);
+ final int varsep = l.indexOf(' ', 1);
if (varsep > 0) {
key = l.substring(1, varsep);
value = l.substring(varsep+1);
@@ -2463,7 +2463,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean allocate(int bytes, int recordSize) throws IOException
+ public boolean allocate(final int bytes, final int recordSize) throws IOException
{
return FTPReply.isPositiveCompletion(allo(bytes, recordSize));
}
@@ -2482,7 +2482,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean allocate(long bytes, int recordSize) throws IOException
+ public boolean allocate(final long bytes, final int recordSize) throws IOException
{
return FTPReply.isPositiveCompletion(allo(bytes, recordSize));
}
@@ -2504,7 +2504,7 @@ implements Configurable
* command to the server or receiving a reply from the server.
* @since 3.0
*/
- public boolean doCommand(String command, String params) throws IOException
+ public boolean doCommand(final String command, final String params) throws IOException
{
return FTPReply.isPositiveCompletion(sendCommand(command, params));
}
@@ -2525,9 +2525,9 @@ implements Configurable
* command to the server or receiving a reply from the server.
* @since 3.0
*/
- public String[] doCommandAsStrings(String command, String params) throws IOException
+ public String[] doCommandAsStrings(final String command, final String params) throws IOException
{
- boolean success = FTPReply.isPositiveCompletion(sendCommand(command, params));
+ final boolean success = FTPReply.isPositiveCompletion(sendCommand(command, params));
if (success){
return getReplyStrings();
} else {
@@ -2543,9 +2543,9 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public FTPFile mlistFile(String pathname) throws IOException
+ public FTPFile mlistFile(final String pathname) throws IOException
{
- boolean success = FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
+ final boolean success = FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
if (success){
String reply = getReplyStrings()[1];
// some FTP server reply not contains space before fact(s)
@@ -2558,7 +2558,7 @@ implements Configurable
throw new MalformedServerReplyException("Invalid server reply (MLST): '" + reply + "'");
}
// some FTP server reply contains more than one space before fact(s)
- String entry = reply.replaceAll("^\\s+", ""); // skip leading space for parser
+ final String entry = reply.replaceAll("^\\s+", ""); // skip leading space for parser
return MLSxEntryParser.parseEntry(entry);
} else {
return null;
@@ -2585,9 +2585,9 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public FTPFile[] mlistDir(String pathname) throws IOException
+ public FTPFile[] mlistDir(final String pathname) throws IOException
{
- FTPListParseEngine engine = initiateMListParsing( pathname);
+ final FTPListParseEngine engine = initiateMListParsing( pathname);
return engine.getFiles();
}
@@ -2600,9 +2600,9 @@ implements Configurable
* @throws IOException on error
* @since 3.0
*/
- public FTPFile[] mlistDir(String pathname, FTPFileFilter filter) throws IOException
+ public FTPFile[] mlistDir(final String pathname, final FTPFileFilter filter) throws IOException
{
- FTPListParseEngine engine = initiateMListParsing( pathname);
+ final FTPListParseEngine engine = initiateMListParsing( pathname);
return engine.getFiles(filter);
}
@@ -2625,7 +2625,7 @@ implements Configurable
* command to the server or receiving a reply from the server.
* @since 3.1 (changed from private to protected)
*/
- protected boolean restart(long offset) throws IOException
+ protected boolean restart(final long offset) throws IOException
{
__restartOffset = 0;
return FTPReply.isPositiveIntermediate(rest(Long.toString(offset)));
@@ -2647,7 +2647,7 @@ implements Configurable
* next file transfer. This must be a value greater than or
* equal to zero.
*/
- public void setRestartOffset(long offset)
+ public void setRestartOffset(final long offset)
{
if (offset >= 0) {
__restartOffset = offset;
@@ -2681,7 +2681,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean rename(String from, String to) throws IOException
+ public boolean rename(final String from, final String to) throws IOException
{
if (!FTPReply.isPositiveIntermediate(rnfr(from))) {
return false;
@@ -2721,7 +2721,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean deleteFile(String pathname) throws IOException
+ public boolean deleteFile(final String pathname) throws IOException
{
return FTPReply.isPositiveCompletion(dele(pathname));
}
@@ -2740,7 +2740,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean removeDirectory(String pathname) throws IOException
+ public boolean removeDirectory(final String pathname) throws IOException
{
return FTPReply.isPositiveCompletion(rmd(pathname));
}
@@ -2761,7 +2761,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean makeDirectory(String pathname) throws IOException
+ public boolean makeDirectory(final String pathname) throws IOException
{
return FTPReply.isPositiveCompletion(mkd(pathname));
}
@@ -2802,7 +2802,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public boolean sendSiteCommand(String arguments) throws IOException
+ public boolean sendSiteCommand(final String arguments) throws IOException
{
return FTPReply.isPositiveCompletion(site(arguments));
}
@@ -2841,7 +2841,7 @@ implements Configurable
__systemName = _replyLines.get(_replyLines.size() - 1).substring(4);
} else {
// Check if the user has provided a default for when the SYST command fails
- String systDefault = System.getProperty(FTP_SYSTEM_TYPE_DEFAULT);
+ final String systDefault = System.getProperty(FTP_SYSTEM_TYPE_DEFAULT);
if (systDefault != null) {
__systemName = systDefault;
} else {
@@ -2890,7 +2890,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public String listHelp(String command) throws IOException
+ public String listHelp(final String command) throws IOException
{
if (FTPReply.isPositiveCompletion(help(command))) {
return getReplyString();
@@ -2947,18 +2947,18 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public String[] listNames(String pathname) throws IOException
+ public String[] listNames(final String pathname) throws IOException
{
- Socket socket = _openDataConnection_(FTPCmd.NLST, getListArguments(pathname));
+ final Socket socket = _openDataConnection_(FTPCmd.NLST, getListArguments(pathname));
if (socket == null) {
return null;
}
- BufferedReader reader =
+ final BufferedReader reader =
new BufferedReader(new InputStreamReader(socket.getInputStream(), getControlEncoding()));
- ArrayList<String> results = new ArrayList<>();
+ final ArrayList<String> results = new ArrayList<>();
String line;
while ((line = reader.readLine()) != null) {
results.add(line);
@@ -2969,7 +2969,7 @@ implements Configurable
if (completePendingCommand())
{
- String[] names = new String[ results.size() ];
+ final String[] names = new String[ results.size() ];
return results.toArray(names);
}
@@ -3057,10 +3057,10 @@ implements Configurable
* @see org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory
* @see org.apache.commons.net.ftp.FTPFileEntryParser
*/
- public FTPFile[] listFiles(String pathname)
+ public FTPFile[] listFiles(final String pathname)
throws IOException
{
- FTPListParseEngine engine = initiateListParsing((String) null, pathname);
+ final FTPListParseEngine engine = initiateListParsing((String) null, pathname);
return engine.getFiles();
}
@@ -3125,10 +3125,10 @@ implements Configurable
* @throws IOException on error
* @since 2.2
*/
- public FTPFile[] listFiles(String pathname, FTPFileFilter filter)
+ public FTPFile[] listFiles(final String pathname, final FTPFileFilter filter)
throws IOException
{
- FTPListParseEngine engine = initiateListParsing((String) null, pathname);
+ final FTPListParseEngine engine = initiateListParsing((String) null, pathname);
return engine.getFiles(filter);
}
@@ -3224,7 +3224,7 @@ implements Configurable
* @see org.apache.commons.net.ftp.FTPFileEntryParser
* @since 3.0
*/
- public FTPFile[] listDirectories(String parent) throws IOException {
+ public FTPFile[] listDirectories(final String parent) throws IOException {
return listFiles(parent, FTPFileFilters.DIRECTORIES);
}
@@ -3317,7 +3317,7 @@ implements Configurable
* resolve the type of system we are connected with.
* @see FTPListParseEngine
*/
- public FTPListParseEngine initiateListParsing(String pathname)
+ public FTPListParseEngine initiateListParsing(final String pathname)
throws IOException
{
return initiateListParsing((String) null, pathname);
@@ -3379,7 +3379,7 @@ implements Configurable
* @see FTPListParseEngine
*/
public FTPListParseEngine initiateListParsing(
- String parserKey, String pathname)
+ final String parserKey, final String pathname)
throws IOException
{
__createParser(parserKey); // create and cache parser
@@ -3387,7 +3387,7 @@ implements Configurable
}
// package access for test purposes
- void __createParser(String parserKey) throws IOException {
+ void __createParser(final String parserKey) throws IOException {
// We cache the value to avoid creation of a new object every
// time a file listing is generated.
// Note: we don't check against a null parserKey (NET-544)
@@ -3414,9 +3414,9 @@ implements Configurable
String systemType = System.getProperty(FTP_SYSTEM_TYPE);
if (systemType == null) {
systemType = getSystemType(); // cannot be null
- Properties override = getOverrideProperties();
+ final Properties override = getOverrideProperties();
if (override != null) {
- String newType = override.getProperty(systemType);
+ final String newType = override.getProperty(systemType);
if (newType != null) {
systemType = newType;
}
@@ -3450,12 +3450,12 @@ implements Configurable
* @see FTPListParseEngine
*/
private FTPListParseEngine initiateListParsing(
- FTPFileEntryParser parser, String pathname)
+ final FTPFileEntryParser parser, final String pathname)
throws IOException
{
- Socket socket = _openDataConnection_(FTPCmd.LIST, getListArguments(pathname));
+ final Socket socket = _openDataConnection_(FTPCmd.LIST, getListArguments(pathname));
- FTPListParseEngine engine = new FTPListParseEngine(parser, __configuration);
+ final FTPListParseEngine engine = new FTPListParseEngine(parser, __configuration);
if (socket == null)
{
return engine;
@@ -3490,10 +3490,10 @@ implements Configurable
* @return the engine.
* @throws IOException on error
*/
- public FTPListParseEngine initiateMListParsing(String pathname) throws IOException
+ public FTPListParseEngine initiateMListParsing(final String pathname) throws IOException
{
- Socket socket = _openDataConnection_(FTPCmd.MLSD, pathname);
- FTPListParseEngine engine = new FTPListParseEngine(MLSxEntryParser.getInstance(), __configuration);
+ final Socket socket = _openDataConnection_(FTPCmd.MLSD, pathname);
+ final FTPListParseEngine engine = new FTPListParseEngine(MLSxEntryParser.getInstance(), __configuration);
if (socket == null)
{
return engine;
@@ -3514,12 +3514,12 @@ implements Configurable
* @return the adjusted string with "-a" added if necessary
* @since 2.0
*/
- protected String getListArguments(String pathname) {
+ protected String getListArguments(final String pathname) {
if (getListHiddenFiles())
{
if (pathname != null)
{
- StringBuilder sb = new StringBuilder(pathname.length() + 3);
+ final StringBuilder sb = new StringBuilder(pathname.length() + 3);
sb.append("-a ");
sb.append(pathname);
return sb.toString();
@@ -3569,7 +3569,7 @@ implements Configurable
* @throws IOException If an I/O error occurs while either sending a
* command to the server or receiving a reply from the server.
*/
- public String getStatus(String pathname) throws IOException
+ public String getStatus(final String pathname) throws IOException
{
if (FTPReply.isPositiveCompletion(stat(pathname))) {
return getReplyString();
@@ -3594,7 +3594,7 @@ implements Configurable
* command to the server or receiving a reply from the server.
* @since 3.7
*/
- public String getSize(String pathname) throws IOException
+ public String getSize(final String pathname) throws IOException
{
if (FTPReply.isPositiveCompletion(size(pathname))) {
return getReplyStrings()[0].substring(4); // skip the return code (e.g. 213) and the space
@@ -3614,7 +3614,7 @@ implements Configurable
* @throws IOException if an I/O error occurs.
* @since 2.0
*/
- public String getModificationTime(String pathname) throws IOException {
+ public String getModificationTime(final String pathname) throws IOException {
if (FTPReply.isPositiveCompletion(mdtm(pathname))) {
return getReplyStrings()[0].substring(4); // skip the return code (e.g. 213) and the space
}
@@ -3634,10 +3634,10 @@ implements Configurable
* @throws IOException if an I/O error occurs.
* @since 3.4
*/
- public FTPFile mdtmFile(String pathname) throws IOException {
+ public FTPFile mdtmFile(final String pathname) throws IOException {
if (FTPReply.isPositiveCompletion(mdtm(pathname))) {
- String reply = getReplyStrings()[0].substring(4); // skip the return code (e.g. 213) and the space
- FTPFile file = new FTPFile();
+ final String reply = getReplyStrings()[0].substring(4); // skip the return code (e.g. 213) and the space
+ final FTPFile file = new FTPFile();
file.setName(pathname);
file.setRawListing(reply);
file.setTimestamp(MLSxEntryParser.parseGMTdateTime(reply));
@@ -3664,7 +3664,7 @@ implements Configurable
* @since 2.2
* @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04</a>
*/
- public boolean setModificationTime(String pathname, String timeval) throws IOException {
+ public boolean setModificationTime(final String pathname, final String timeval) throws IOException {
return (FTPReply.isPositiveCompletion(mfmt(pathname, timeval)));
}
@@ -3674,7 +3674,7 @@ implements Configurable
*
* @param bufSize The size of the buffer. Use a non-positive value to use the default.
*/
- public void setBufferSize(int bufSize) {
+ public void setBufferSize(final int bufSize) {
__bufferSize = bufSize;
}
@@ -3693,7 +3693,7 @@ implements Configurable
* @param bufSize The size of the buffer, zero or negative means the value is ignored.
* @since 3.3
*/
- public void setSendDataSocketBufferSize(int bufSize) {
+ public void setSendDataSocketBufferSize(final int bufSize) {
__sendDataSocketBufferSize = bufSize;
}
@@ -3713,7 +3713,7 @@ implements Configurable
* @param bufSize The size of the buffer, zero or negative means the value is ignored.
* @since 3.3
*/
- public void setReceieveDataSocketBufferSize(int bufSize) {
+ public void setReceieveDataSocketBufferSize(final int bufSize) {
__receiveDataSocketBufferSize = bufSize;
}
@@ -3735,7 +3735,7 @@ implements Configurable
* @since 1.4
*/
@Override
- public void configure(FTPClientConfig config) {
+ public void configure(final FTPClientConfig config) {
this.__configuration = config;
}
@@ -3748,7 +3748,7 @@ implements Configurable
* @param listHiddenFiles true if hidden files should be listed
* @since 2.0
*/
- public void setListHiddenFiles(boolean listHiddenFiles) {
+ public void setListHiddenFiles(final boolean listHiddenFiles) {
this.__listHiddenFiles = listHiddenFiles;
}
@@ -3786,7 +3786,7 @@ implements Configurable
* @param selected value to set.
* @since 2.2
*/
- public void setUseEPSVwithIPv4(boolean selected) {
+ public void setUseEPSVwithIPv4(final boolean selected) {
this.__useEPSVwithIPv4 = selected;
}
@@ -3797,7 +3797,7 @@ implements Configurable
* @param listener to be used, may be {@code null} to disable
* @since 3.0
*/
- public void setCopyStreamListener(CopyStreamListener listener){
+ public void setCopyStreamListener(final CopyStreamListener listener){
__copyStreamListener = listener;
}
@@ -3821,7 +3821,7 @@ implements Configurable
* @since 3.0
* @see #setControlKeepAliveReplyTimeout(int)
*/
- public void setControlKeepAliveTimeout(long controlIdle){
+ public void setControlKeepAliveTimeout(final long controlIdle){
__controlKeepAliveTimeout = controlIdle * 1000;
}
@@ -3864,7 +3864,7 @@ implements Configurable
* @since 3.0
* @see #setControlKeepAliveTimeout(long)
*/
- public void setControlKeepAliveReplyTimeout(int timeout) {
+ public void setControlKeepAliveReplyTimeout(final int timeout) {
__controlKeepAliveReplyTimeout = timeout;
}
@@ -3891,7 +3891,7 @@ implements Configurable
* @deprecated (3.6) use {@link #setPassiveNatWorkaroundStrategy(HostnameResolver)} instead
*/
@Deprecated
- public void setPassiveNatWorkaround(boolean enabled) {
+ public void setPassiveNatWorkaround(final boolean enabled) {
if (enabled) {
this.__passiveNatWorkaroundStrategy = new NatServerResolverImpl(this);
} else {
@@ -3909,7 +3909,7 @@ implements Configurable
* or null to disable the workaround (i.e. use PASV mode reply address.)
* @since 3.6
*/
- public void setPassiveNatWorkaroundStrategy(HostnameResolver resolver) {
+ public void setPassiveNatWorkaroundStrategy(final HostnameResolver resolver) {
this.__passiveNatWorkaroundStrategy = resolver;
}
@@ -3929,19 +3929,19 @@ implements Configurable
* @since 3.6
*/
public static class NatServerResolverImpl implements HostnameResolver {
- private FTPClient client;
+ private final FTPClient client;
- public NatServerResolverImpl(FTPClient client) {
+ public NatServerResolverImpl(final FTPClient client) {
this.client = client;
}
@Override
- public String resolve(String hostname) throws UnknownHostException {
+ public String resolve(final String hostname) throws UnknownHostException {
String newHostname = hostname;
- InetAddress host = InetAddress.getByName(newHostname);
+ final InetAddress host = InetAddress.getByName(newHostname);
// reply is a local address, but target is not - assume NAT box changed the PASV reply
if (host.isSiteLocalAddress()) {
- InetAddress remote = this.client.getRemoteAddress();
+ final InetAddress remote = this.client.getRemoteAddress();
if (!remote.isSiteLocalAddress()){
newHostname = remote.getHostAddress();
}
@@ -3950,14 +3950,14 @@ implements Configurable
}
}
- private OutputStream getBufferedOutputStream(OutputStream outputStream) {
+ private OutputStream getBufferedOutputStream(final OutputStream outputStream) {
if (__bufferSize > 0) {
return new BufferedOutputStream(outputStream, __bufferSize);
}
return new BufferedOutputStream(outputStream);
}
- private InputStream getBufferedInputStream(InputStream inputStream) {
+ private InputStream getBufferedInputStream(final InputStream inputStream) {
if (__bufferSize > 0) {
return new BufferedInputStream(inputStream, __bufferSize);
}
@@ -3976,7 +3976,7 @@ implements Configurable
private int acksAcked;
private int ioErrors;
- CSL(FTPClient parent, long idleTime, int maxWait) throws SocketException {
+ CSL(final FTPClient parent, final long idleTime, final int maxWait) throws SocketException {
this.idle = idleTime;
this.parent = parent;
this.currentSoTimeout = parent.getSoTimeout();
@@ -3984,21 +3984,21 @@ implements Configurable
}
@Override
- public void bytesTransferred(CopyStreamEvent event) {
+ public void bytesTransferred(final CopyStreamEvent event) {
bytesTransferred(event.getTotalBytesTransferred(), event.getBytesTransferred(), event.getStreamSize());
}
@Override
- public void bytesTransferred(long totalBytesTransferred,
- int bytesTransferred, long streamSize) {
- long now = System.currentTimeMillis();
+ public void bytesTransferred(final long totalBytesTransferred,
+ final int bytesTransferred, final long streamSize) {
+ final long now = System.currentTimeMillis();
if (now - time > idle) {
try {
parent.__noop();
acksAcked++;
- } catch (SocketTimeoutException e) {
+ } catch (final SocketTimeoutException e) {
notAcked++;
- } catch (IOException e) {
+ } catch (final IOException e) {
ioErrors++;
// Ignored
}
@@ -4007,13 +4007,13 @@ implements Configurable
}
int[] cleanUp() throws IOException {
- int remain = notAcked;
+ final int remain = notAcked;
try {
while(notAcked > 0) {
parent.getReply(); // we do want to see these
notAcked--; // only decrement if actually received
}
- } catch (SocketTimeoutException e) { // NET-584
+ } catch (final SocketTimeoutException e) { // NET-584
// ignored
} finally {
parent.setSoTimeout(currentSoTimeout);
@@ -4030,7 +4030,7 @@ implements Configurable
* @return a merged listener or a single listener or null
* @since 3.0
*/
- private CopyStreamListener __mergeListeners(CopyStreamListener local) {
+ private CopyStreamListener __mergeListeners(final CopyStreamListener local) {
if (local == null) {
return __copyStreamListener;
}
@@ -4038,7 +4038,7 @@ implements Configurable
return local;
}
// Both are non-null
- CopyStreamAdapter merged = new CopyStreamAdapter();
+ final CopyStreamAdapter merged = new CopyStreamAdapter();
merged.addCopyStreamListener(local);
merged.addCopyStreamListener(__copyStreamListener);
return merged;
@@ -4051,7 +4051,7 @@ implements Configurable
*
* @param autodetect If true, automatic server encoding detection will be enabled.
*/
- public void setAutodetectUTF8(boolean autodetect)
+ public void setAutodetectUTF8(final boolean autodetect)
{
__autodetectEncoding = autodetect;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java b/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java
index 10d56eb..b1b46fb 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java
@@ -237,7 +237,7 @@ public class FTPClientConfig
* However this is not recommended for general use;
* the correct system type should be set if it is known.
*/
- public FTPClientConfig(String systemKey) {
+ public FTPClientConfig(final String systemKey) {
this.serverSystemKey = systemKey;
}
@@ -260,9 +260,9 @@ public class FTPClientConfig
* {@link #setRecentDateFormatStr(String) recentDateFormatStr}
* @since 3.6
*/
- public FTPClientConfig(String systemKey,
- String defaultDateFormatStr,
- String recentDateFormatStr)
+ public FTPClientConfig(final String systemKey,
+ final String defaultDateFormatStr,
+ final String recentDateFormatStr)
{
this(systemKey);
this.defaultDateFormatStr = defaultDateFormatStr;
@@ -285,12 +285,12 @@ public class FTPClientConfig
* @param serverTimeZoneId See
* {@link #setServerTimeZoneId(String) serverTimeZoneId}
*/
- public FTPClientConfig(String systemKey,
- String defaultDateFormatStr,
- String recentDateFormatStr,
- String serverLanguageCode,
- String shortMonthNames,
- String serverTimeZoneId)
+ public FTPClientConfig(final String systemKey,
+ final String defaultDateFormatStr,
+ final String recentDateFormatStr,
+ final String serverLanguageCode,
+ final String shortMonthNames,
+ final String serverTimeZoneId)
{
this(systemKey);
this.defaultDateFormatStr = defaultDateFormatStr;
@@ -320,14 +320,14 @@ public class FTPClientConfig
* @param saveUnparseableEntries See
* {@link #setUnparseableEntries(boolean) saveUnparseableEntries}
*/
- public FTPClientConfig(String systemKey,
- String defaultDateFormatStr,
- String recentDateFormatStr,
- String serverLanguageCode,
- String shortMonthNames,
- String serverTimeZoneId,
- boolean lenientFutureDates,
- boolean saveUnparseableEntries)
+ public FTPClientConfig(final String systemKey,
+ final String defaultDateFormatStr,
+ final String recentDateFormatStr,
+ final String serverLanguageCode,
+ final String shortMonthNames,
+ final String serverTimeZoneId,
+ final boolean lenientFutureDates,
+ final boolean saveUnparseableEntries)
{
this(systemKey);
this.defaultDateFormatStr = defaultDateFormatStr;
@@ -340,7 +340,7 @@ public class FTPClientConfig
}
// Copy constructor, intended for use by FTPClient only
- FTPClientConfig(String systemKey, FTPClientConfig config) {
+ FTPClientConfig(final String systemKey, final FTPClientConfig config) {
this.serverSystemKey = systemKey;
this.defaultDateFormatStr = config.defaultDateFormatStr;
this.lenientFutureDates = config.lenientFutureDates;
@@ -356,7 +356,7 @@ public class FTPClientConfig
* @param config source
* @since 3.6
*/
- public FTPClientConfig(FTPClientConfig config) {
+ public FTPClientConfig(final FTPClientConfig config) {
this.serverSystemKey = config.serverSystemKey;
this.defaultDateFormatStr = config.defaultDateFormatStr;
this.lenientFutureDates = config.lenientFutureDates;
@@ -483,7 +483,7 @@ public class FTPClientConfig
* </p>
* @param defaultDateFormatStr The defaultDateFormatStr to set.
*/
- public void setDefaultDateFormatStr(String defaultDateFormatStr) {
+ public void setDefaultDateFormatStr(final String defaultDateFormatStr) {
this.defaultDateFormatStr = defaultDateFormatStr;
}
@@ -504,7 +504,7 @@ public class FTPClientConfig
* </p>
* @param recentDateFormatStr The recentDateFormatStr to set.
*/
- public void setRecentDateFormatStr(String recentDateFormatStr) {
+ public void setRecentDateFormatStr(final String recentDateFormatStr) {
this.recentDateFormatStr = recentDateFormatStr;
}
@@ -528,7 +528,7 @@ public class FTPClientConfig
* @param lenientFutureDates set true to compensate for out-of-synch
* conditions.
*/
- public void setLenientFutureDates(boolean lenientFutureDates) {
+ public void setLenientFutureDates(final boolean lenientFutureDates) {
this.lenientFutureDates = lenientFutureDates;
}
/**
@@ -545,7 +545,7 @@ public class FTPClientConfig
* </p>
* @param serverTimeZoneId The serverTimeZoneId to set.
*/
- public void setServerTimeZoneId(String serverTimeZoneId) {
+ public void setServerTimeZoneId(final String serverTimeZoneId) {
this.serverTimeZoneId = serverTimeZoneId;
}
@@ -566,7 +566,7 @@ public class FTPClientConfig
* </p>
* @param shortMonthNames The value to set to the shortMonthNames property.
*/
- public void setShortMonthNames(String shortMonthNames) {
+ public void setShortMonthNames(final String shortMonthNames) {
this.shortMonthNames = shortMonthNames;
}
@@ -610,7 +610,7 @@ public class FTPClientConfig
* </p>
* @param serverLanguageCode The value to set to the serverLanguageCode property.
*/
- public void setServerLanguageCode(String serverLanguageCode) {
+ public void setServerLanguageCode(final String serverLanguageCode) {
this.serverLanguageCode = serverLanguageCode;
}
@@ -626,9 +626,9 @@ public class FTPClientConfig
* <code>Locale.US</code> if there is no corresponding entry in the internal
* table.
*/
- public static DateFormatSymbols lookupDateFormatSymbols(String languageCode)
+ public static DateFormatSymbols lookupDateFormatSymbols(final String languageCode)
{
- Object lang = LANGUAGE_CODE_MAP.get(languageCode);
+ final Object lang = LANGUAGE_CODE_MAP.get(languageCode);
if (lang != null) {
if (lang instanceof Locale) {
return new DateFormatSymbols((Locale) lang);
@@ -647,22 +647,22 @@ public class FTPClientConfig
* @return a DateFormatSymbols object configured with short month names
* as in the supplied string
*/
- public static DateFormatSymbols getDateFormatSymbols(String shortmonths)
+ public static DateFormatSymbols getDateFormatSymbols(final String shortmonths)
{
- String[] months = splitShortMonthString(shortmonths);
- DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
+ final String[] months = splitShortMonthString(shortmonths);
+ final DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
dfs.setShortMonths(months);
return dfs;
}
- private static String[] splitShortMonthString(String shortmonths) {
- StringTokenizer st = new StringTokenizer(shortmonths, "|");
- int monthcnt = st.countTokens();
+ private static String[] splitShortMonthString(final String shortmonths) {
+ final StringTokenizer st = new StringTokenizer(shortmonths, "|");
+ final int monthcnt = st.countTokens();
if (12 != monthcnt) {
throw new IllegalArgumentException(
"expecting a pipe-delimited string containing 12 tokens");
}
- String[] months = new String[13];
+ final String[] months = new String[13];
int pos = 0;
while(st.hasMoreTokens()) {
months[pos++] = st.nextToken();
@@ -691,7 +691,7 @@ public class FTPClientConfig
* @param saveUnparseable if true, then create FTPFile entries if parsing fails
* @since 3.4
*/
- public void setUnparseableEntries(boolean saveUnparseable) {
+ public void setUnparseableEntries(final boolean saveUnparseable) {
this.saveUnparseableEntries = saveUnparseable;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPCommand.java b/src/main/java/org/apache/commons/net/ftp/FTPCommand.java
index c5739d8..757044a 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPCommand.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPCommand.java
@@ -149,7 +149,7 @@ public final class FTPCommand
// default access needed for Unit test
static void checkArray(){
- int expectedLength = LAST+1;
+ final int expectedLength = LAST+1;
if (_commands.length != expectedLength) {
throw new RuntimeException("Incorrect _commands array. Should have length "
+expectedLength+" found "+_commands.length);
@@ -164,7 +164,7 @@ public final class FTPCommand
* @return The FTP protcol command string corresponding to a specified
* command code.
*/
- public static final String getCommand(int command)
+ public static final String getCommand(final int command)
{
return _commands[command];
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPConnectionClosedException.java b/src/main/java/org/apache/commons/net/ftp/FTPConnectionClosedException.java
index 079f088..e32a903 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPConnectionClosedException.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPConnectionClosedException.java
@@ -47,7 +47,7 @@ public class FTPConnectionClosedException extends IOException
*
* @param message The message explaining the reason for the exception.
***/
- public FTPConnectionClosedException(String message)
+ public FTPConnectionClosedException(final String message)
{
super(message);
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPFile.java b/src/main/java/org/apache/commons/net/ftp/FTPFile.java
index b208e27..b443dcb 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPFile.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPFile.java
@@ -88,7 +88,7 @@ public class FTPFile implements Serializable
* @param rawListing line that could not be parsed.
* @since 3.4
*/
- FTPFile(String rawListing)
+ FTPFile(final String rawListing)
{
_permissions = null; // flag that entry is invalid
_rawListing = rawListing;
@@ -110,7 +110,7 @@ public class FTPFile implements Serializable
*
* @param rawListing The raw FTP server listing.
***/
- public void setRawListing(String rawListing)
+ public void setRawListing(final String rawListing)
{
_rawListing = rawListing;
}
@@ -191,7 +191,7 @@ public class FTPFile implements Serializable
*
* @param type The integer code representing the type of the file.
***/
- public void setType(int type)
+ public void setType(final int type)
{
_type = type;
}
@@ -214,7 +214,7 @@ public class FTPFile implements Serializable
*
* @param name The name of the file.
***/
- public void setName(String name)
+ public void setName(final String name)
{
_name = name;
}
@@ -234,7 +234,7 @@ public class FTPFile implements Serializable
* Set the file size in bytes.
* @param size The file size in bytes.
*/
- public void setSize(long size)
+ public void setSize(final long size)
{
_size = size;
}
@@ -257,7 +257,7 @@ public class FTPFile implements Serializable
*
* @param links The number of hard links to this file.
***/
- public void setHardLinkCount(int links)
+ public void setHardLinkCount(final int links)
{
_hardLinkCount = links;
}
@@ -281,7 +281,7 @@ public class FTPFile implements Serializable
*
* @param group The name of the group owning the file.
***/
- public void setGroup(String group)
+ public void setGroup(final String group)
{
_group = group;
}
@@ -305,7 +305,7 @@ public class FTPFile implements Serializable
*
* @param user The name of the user owning the file.
***/
- public void setUser(String user)
+ public void setUser(final String user)
{
_user = user;
}
@@ -328,7 +328,7 @@ public class FTPFile implements Serializable
*
* @param link The file pointed to by the symbolic link.
***/
- public void setLink(String link)
+ public void setLink(final String link)
{
_link = link;
}
@@ -354,7 +354,7 @@ public class FTPFile implements Serializable
*
* @param date A Calendar instance representing the file timestamp.
***/
- public void setTimestamp(Calendar date)
+ public void setTimestamp(final Calendar date)
{
_date = date;
}
@@ -383,7 +383,7 @@ public class FTPFile implements Serializable
* @param value True if permission is allowed, false if not.
* @throws ArrayIndexOutOfBoundsException if either of the parameters is out of range
***/
- public void setPermission(int access, int permission, boolean value)
+ public void setPermission(final int access, final int permission, final boolean value)
{
_permissions[access][permission] = value;
}
@@ -402,7 +402,7 @@ public class FTPFile implements Serializable
* @return true if {@link #isValid()} is {@code true &&} the associated permission is set;
* {@code false} otherwise.
***/
- public boolean hasPermission(int access, int permission)
+ public boolean hasPermission(final int access, final int permission)
{
if (_permissions == null) {
return false;
@@ -459,8 +459,8 @@ public class FTPFile implements Serializable
if (!isValid()) {
return "[Invalid: could not parse file entry]";
}
- StringBuilder sb = new StringBuilder();
- Formatter fmt = new Formatter(sb);
+ final StringBuilder sb = new StringBuilder();
+ final Formatter fmt = new Formatter(sb);
sb.append(formatType());
sb.append(permissionToString(USER_ACCESS));
sb.append(permissionToString(GROUP_ACCESS));
@@ -471,10 +471,10 @@ public class FTPFile implements Serializable
Calendar timestamp = getTimestamp();
if (timestamp != null) {
if (timezone != null) {
- TimeZone newZone = TimeZone.getTimeZone(timezone);
+ final TimeZone newZone = TimeZone.getTimeZone(timezone);
if (!newZone.equals(timestamp.getTimeZone())){
- Date original = timestamp.getTime();
- Calendar newStamp = Calendar.getInstance(newZone);
+ final Date original = timestamp.getTime();
+ final Calendar newStamp = Calendar.getInstance(newZone);
newStamp.setTime(original);
timestamp = newStamp;
}
@@ -514,8 +514,8 @@ public class FTPFile implements Serializable
}
}
- private String permissionToString(int access ){
- StringBuilder sb = new StringBuilder();
+ private String permissionToString(final int access ){
+ final StringBuilder sb = new StringBuilder();
if (hasPermission(access, READ_PERMISSION)) {
sb.append('r');
} else {
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPFileEntryParserImpl.java b/src/main/java/org/apache/commons/net/ftp/FTPFileEntryParserImpl.java
index 7f29224..967fd5e 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPFileEntryParserImpl.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPFileEntryParserImpl.java
@@ -48,7 +48,7 @@ public abstract class FTPFileEntryParserImpl
* @throws java.io.IOException thrown on any IO Error reading from the reader.
*/
@Override
- public String readNextEntry(BufferedReader reader) throws IOException
+ public String readNextEntry(final BufferedReader reader) throws IOException
{
return reader.readLine();
}
@@ -65,7 +65,7 @@ public abstract class FTPFileEntryParserImpl
* @return <code>original</code> unmodified.
*/
@Override
- public List<String> preParse(List<String> original) {
+ public List<String> preParse(final List<String> original) {
return original;
}
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPFileFilters.java b/src/main/java/org/apache/commons/net/ftp/FTPFileFilters.java
index 29eba60..5e650b1 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPFileFilters.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPFileFilters.java
@@ -29,7 +29,7 @@ public class FTPFileFilters {
*/
public static final FTPFileFilter ALL = new FTPFileFilter() {
@Override
- public boolean accept(FTPFile file) {
+ public boolean accept(final FTPFile file) {
return true;
}
};
@@ -39,7 +39,7 @@ public class FTPFileFilters {
*/
public static final FTPFileFilter NON_NULL = new FTPFileFilter() {
@Override
- public boolean accept(FTPFile file) {
+ public boolean accept(final FTPFile file) {
return file != null;
}
};
@@ -49,7 +49,7 @@ public class FTPFileFilters {
*/
public static final FTPFileFilter DIRECTORIES = new FTPFileFilter() {
@Override
- public boolean accept(FTPFile file) {
+ public boolean accept(final FTPFile file) {
return file != null && file.isDirectory();
}
};
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
index d5f1114..bb118f0 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
@@ -59,7 +59,7 @@ public class FTPHTTPClient extends FTPClient {
* @param proxyPass the password for the proxy
* @param encoding the encoding to use
*/
- public FTPHTTPClient(String proxyHost, int proxyPort, String proxyUser, String proxyPass, Charset encoding) {
+ public FTPHTTPClient(final String proxyHost, final int proxyPort, final String proxyUser, final String proxyPass, final Charset encoding) {
this.proxyHost = proxyHost;
this.proxyPort = proxyPort;
this.proxyUsername = proxyUser;
@@ -76,7 +76,7 @@ public class FTPHTTPClient extends FTPClient {
* @param proxyUser the user name for the proxy
* @param proxyPass the password for the proxy
*/
- public FTPHTTPClient(String proxyHost, int proxyPort, String proxyUser, String proxyPass) {
+ public FTPHTTPClient(final String proxyHost, final int proxyPort, final String proxyUser, final String proxyPass) {
this(proxyHost, proxyPort, proxyUser, proxyPass, Charset.forName("UTF-8"));
}
@@ -86,7 +86,7 @@ public class FTPHTTPClient extends FTPClient {
* @param proxyHost the hostname to use
* @param proxyPort the port to use
*/
- public FTPHTTPClient(String proxyHost, int proxyPort) {
+ public FTPHTTPClient(final String proxyHost, final int proxyPort) {
this(proxyHost, proxyPort, null, null);
}
@@ -98,7 +98,7 @@ public class FTPHTTPClient extends FTPClient {
* @param proxyPort the port to use
* @param encoding the encoding to use
*/
- public FTPHTTPClient(String proxyHost, int proxyPort, Charset encoding) {
+ public FTPHTTPClient(final String proxyHost, final int proxyPort, final Charset encoding) {
this(proxyHost, proxyPort, null, null, encoding);
}
@@ -113,7 +113,7 @@ public class FTPHTTPClient extends FTPClient {
// Not strictly necessary, but Clirr complains even though there is a super-impl
@Override
@Deprecated
- protected Socket _openDataConnection_(int command, String arg)
+ protected Socket _openDataConnection_(final int command, final String arg)
throws IOException {
return super._openDataConnection_(command, arg);
}
@@ -125,7 +125,7 @@ public class FTPHTTPClient extends FTPClient {
* @since 3.1
*/
@Override
- protected Socket _openDataConnection_(String command, String arg)
+ protected Socket _openDataConnection_(final String command, final String arg)
throws IOException {
//Force local passive mode, active mode not supported by through proxy
if (getDataConnectionMode() != PASSIVE_LOCAL_DATA_CONNECTION_MODE) {
@@ -135,7 +135,7 @@ public class FTPHTTPClient extends FTPClient {
final boolean isInet6Address = getRemoteAddress() instanceof Inet6Address;
String passiveHost = null;
- boolean attemptEPSV = isUseEPSVwithIPv4() || isInet6Address;
+ final boolean attemptEPSV = isUseEPSVwithIPv4() || isInet6Address;
if (attemptEPSV && epsv() == FTPReply.ENTERING_EPSV_MODE) {
_parseExtendedPassiveModeReply(_replyLines.get(0));
passiveHost = this.tunnelHost;
@@ -151,9 +151,9 @@ public class FTPHTTPClient extends FTPClient {
passiveHost = this.getPassiveHost();
}
- Socket socket = _socketFactory_.createSocket(proxyHost, proxyPort);
- InputStream is = socket.getInputStream();
- OutputStream os = socket.getOutputStream();
+ final Socket socket = _socketFactory_.createSocket(proxyHost, proxyPort);
+ final InputStream is = socket.getInputStream();
+ final OutputStream os = socket.getOutputStream();
tunnelHandshake(passiveHost, this.getPassivePort(), is, os);
if ((getRestartOffset() > 0) && !restart(getRestartOffset())) {
socket.close();
@@ -169,7 +169,7 @@ public class FTPHTTPClient extends FTPClient {
}
@Override
- public void connect(String host, int port) throws SocketException, IOException {
+ public void connect(final String host, final int port) throws SocketException, IOException {
_socket_ = _socketFactory_.createSocket(proxyHost, proxyPort);
_input_ = _socket_.getInputStream();
@@ -178,15 +178,15 @@ public class FTPHTTPClient extends FTPClient {
try {
socketIsReader = tunnelHandshake(host, port, _input_, _output_);
}
- catch (Exception e) {
- IOException ioe = new IOException("Could not connect to " + host+ " using port " + port);
+ catch (final Exception e) {
+ final IOException ioe = new IOException("Could not connect to " + host+ " using port " + port);
ioe.initCause(e);
throw ioe;
}
super._connectAction_(socketIsReader);
}
- private BufferedReader tunnelHandshake(String host, int port, InputStream input, OutputStream output) throws IOException,
+ private BufferedReader tunnelHandshake(final String host, final int port, final InputStream input, final OutputStream output) throws IOException,
UnsupportedEncodingException {
final String connectString = "CONNECT " + host + ":" + port + " HTTP/1.1";
final String hostString = "Host: " + host + ":" + port;
@@ -205,8 +205,8 @@ public class FTPHTTPClient extends FTPClient {
}
output.write(CRLF);
- List<String> response = new ArrayList<>();
- BufferedReader reader = new BufferedReader(
+ final List<String> response = new ArrayList<>();
+ final BufferedReader reader = new BufferedReader(
new InputStreamReader(input, getCharset()));
for (String line = reader.readLine(); line != null
@@ -214,13 +214,13 @@ public class FTPHTTPClient extends FTPClient {
response.add(line);
}
- int size = response.size();
+ final int size = response.size();
if (size == 0) {
throw new IOException("No response from proxy");
}
String code = null;
- String resp = response.get(0);
+ final String resp = response.get(0);
if (resp.startsWith("HTTP/") && resp.length() >= 12) {
code = resp.substring(9, 12);
} else {
@@ -228,10 +228,10 @@ public class FTPHTTPClient extends FTPClient {
}
if (!"200".equals(code)) {
- StringBuilder msg = new StringBuilder();
+ final StringBuilder msg = new StringBuilder();
msg.append("HTTPTunnelConnector: connection failed\r\n");
msg.append("Response received from the proxy:\r\n");
- for (String line : response) {
+ for (final String line : response) {
msg.append(line);
msg.append("\r\n");
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java b/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java
index b409915..6542ea2 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java
@@ -82,7 +82,7 @@ public class FTPListParseEngine {
// Should invalid files (parse failures) be allowed?
private final boolean saveUnparseableEntries;
- public FTPListParseEngine(FTPFileEntryParser parser) {
+ public FTPListParseEngine(final FTPFileEntryParser parser) {
this(parser, null);
}
@@ -90,7 +90,7 @@ public class FTPListParseEngine {
* Intended for use by FTPClient only
* @since 3.4
*/
- FTPListParseEngine(FTPFileEntryParser parser, FTPClientConfig configuration) {
+ FTPListParseEngine(final FTPFileEntryParser parser, final FTPClientConfig configuration) {
this.parser = parser;
if (configuration != null) {
this.saveUnparseableEntries = configuration.getUnparseableEntries();
@@ -111,7 +111,7 @@ public class FTPListParseEngine {
* @throws IOException
* thrown on any failure to read from the sever.
*/
- public void readServerList(InputStream stream, String encoding)
+ public void readServerList(final InputStream stream, final String encoding)
throws IOException
{
this.entries = new LinkedList<>();
@@ -134,9 +134,9 @@ public class FTPListParseEngine {
* @throws IOException
* thrown on any failure to read the stream
*/
- private void readStream(InputStream stream, String encoding) throws IOException
+ private void readStream(final InputStream stream, final String encoding) throws IOException
{
- BufferedReader reader = new BufferedReader(
+ final BufferedReader reader = new BufferedReader(
new InputStreamReader(stream, Charsets.toCharset(encoding)));
String line = this.parser.readNextEntry(reader);
@@ -172,11 +172,11 @@ public class FTPListParseEngine {
* individual file listings failed to parse. The caller should
* check each entry for null before referencing it.
*/
- public FTPFile[] getNext(int quantityRequested) {
- List<FTPFile> tmpResults = new LinkedList<>();
+ public FTPFile[] getNext(final int quantityRequested) {
+ final List<FTPFile> tmpResults = new LinkedList<>();
int count = quantityRequested;
while (count > 0 && this._internalIterator.hasNext()) {
- String entry = this._internalIterator.next();
+ final String entry = this._internalIterator.next();
FTPFile temp = this.parser.parseFTPEntry(entry);
if (temp == null && saveUnparseableEntries) {
temp = new FTPFile(entry);
@@ -214,11 +214,11 @@ public class FTPListParseEngine {
* individual file listings failed to parse. The caller should
* check each entry for null before referencing it.
*/
- public FTPFile[] getPrevious(int quantityRequested) {
- List<FTPFile> tmpResults = new LinkedList<>();
+ public FTPFile[] getPrevious(final int quantityRequested) {
+ final List<FTPFile> tmpResults = new LinkedList<>();
int count = quantityRequested;
while (count > 0 && this._internalIterator.hasPrevious()) {
- String entry = this._internalIterator.previous();
+ final String entry = this._internalIterator.previous();
FTPFile temp = this.parser.parseFTPEntry(entry);
if (temp == null && saveUnparseableEntries) {
temp = new FTPFile(entry);
@@ -262,13 +262,13 @@ public class FTPListParseEngine {
* @since 2.2
* @throws IOException - not ever thrown, may be removed in a later release
*/
- public FTPFile[] getFiles(FTPFileFilter filter)
+ public FTPFile[] getFiles(final FTPFileFilter filter)
throws IOException // TODO remove; not actually thrown
{
- List<FTPFile> tmpResults = new ArrayList<>();
- Iterator<String> iter = this.entries.iterator();
+ final List<FTPFile> tmpResults = new ArrayList<>();
+ final Iterator<String> iter = this.entries.iterator();
while (iter.hasNext()) {
- String entry = iter.next();
+ final String entry = iter.next();
FTPFile temp = this.parser.parseFTPEntry(entry);
if (temp == null && saveUnparseableEntries) {
temp = new FTPFile(entry);
@@ -319,7 +319,7 @@ public class FTPListParseEngine {
* @deprecated use {@link #readServerList(InputStream, String)} instead
*/
@Deprecated
- public void readServerList(InputStream stream)
+ public void readServerList(final InputStream stream)
throws IOException
{
readServerList(stream, null);
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPReply.java b/src/main/java/org/apache/commons/net/ftp/FTPReply.java
index 37d5df5..3cd521d 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPReply.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPReply.java
@@ -115,7 +115,7 @@ public final class FTPReply
* @return True if a reply code is a postive preliminary response, false
* if not.
***/
- public static boolean isPositivePreliminary(int reply)
+ public static boolean isPositivePreliminary(final int reply)
{
return (reply >= 100 && reply < 200);
}
@@ -130,7 +130,7 @@ public final class FTPReply
* @return True if a reply code is a postive completion response, false
* if not.
***/
- public static boolean isPositiveCompletion(int reply)
+ public static boolean isPositiveCompletion(final int reply)
{
return (reply >= 200 && reply < 300);
}
@@ -148,7 +148,7 @@ public final class FTPReply
* @return True if a reply code is a postive intermediate response, false
* if not.
***/
- public static boolean isPositiveIntermediate(int reply)
+ public static boolean isPositiveIntermediate(final int reply)
{
return (reply >= 300 && reply < 400);
}
@@ -163,7 +163,7 @@ public final class FTPReply
* @return True if a reply code is a negative transient response, false
* if not.
***/
- public static boolean isNegativeTransient(int reply)
+ public static boolean isNegativeTransient(final int reply)
{
return (reply >= 400 && reply < 500);
}
@@ -178,7 +178,7 @@ public final class FTPReply
* @return True if a reply code is a negative permanent response, false
* if not.
***/
- public static boolean isNegativePermanent(int reply)
+ public static boolean isNegativePermanent(final int reply)
{
return (reply >= 500 && reply < 600);
}
@@ -190,7 +190,7 @@ public final class FTPReply
* if not.
* @since 3.0
*/
- public static boolean isProtectedReplyCode(int reply)
+ public static boolean isProtectedReplyCode(final int reply)
{
// actually, only 3 protected reply codes are
// defined in RFC 2228: 631, 632 and 633.
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSClient.java b/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
index 504915e..b50689e 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
@@ -134,7 +134,7 @@ public class FTPSClient extends FTPClient {
* Calls {@link #FTPSClient(String, boolean)}
* @param isImplicit The security mode (Implicit/Explicit).
*/
- public FTPSClient(boolean isImplicit) {
+ public FTPSClient(final boolean isImplicit) {
this(DEFAULT_PROTOCOL, isImplicit);
}
@@ -143,7 +143,7 @@ public class FTPSClient extends FTPClient {
*
* @param protocol the protocol to use
*/
- public FTPSClient(String protocol) {
+ public FTPSClient(final String protocol) {
this(protocol, false);
}
@@ -155,7 +155,7 @@ public class FTPSClient extends FTPClient {
* @param protocol the protocol
* @param isImplicit The security mode(Implicit/Explicit).
*/
- public FTPSClient(String protocol, boolean isImplicit) {
+ public FTPSClient(final String protocol, final boolean isImplicit) {
super();
this.protocol = protocol;
this.isImplicit = isImplicit;
@@ -170,7 +170,7 @@ public class FTPSClient extends FTPClient {
* @param isImplicit The security mode(Implicit/Explicit).
* @param context A pre-configured SSL Context
*/
- public FTPSClient(boolean isImplicit, SSLContext context) {
+ public FTPSClient(final boolean isImplicit, final SSLContext context) {
this(DEFAULT_PROTOCOL, isImplicit);
this.context = context;
}
@@ -181,7 +181,7 @@ public class FTPSClient extends FTPClient {
* Calls {@link #FTPSClient(boolean, SSLContext)}
* @param context A pre-configured SSL Context
*/
- public FTPSClient(SSLContext context) {
+ public FTPSClient(final SSLContext context) {
this(false, context);
}
@@ -191,7 +191,7 @@ public class FTPSClient extends FTPClient {
* This processing is done before connected processing.
* @param auth AUTH command use value.
*/
- public void setAuthValue(String auth) {
+ public void setAuthValue(final String auth) {
this.auth = auth;
}
@@ -233,7 +233,7 @@ public class FTPSClient extends FTPClient {
* the command.
*/
protected void execAUTH() throws SSLException, IOException {
- int replyCode = sendCommand(CMD_AUTH, auth);
+ final int replyCode = sendCommand(CMD_AUTH, auth);
if (FTPReply.SECURITY_MECHANISM_IS_OK == replyCode) {
// replyCode = 334
// I carry out an ADAT command.
@@ -260,7 +260,7 @@ public class FTPSClient extends FTPClient {
protected void sslNegotiation() throws IOException {
plainSocket = _socket_;
initSslContext();
- SSLSocket socket = (SSLSocket)createSSLSocket(_socket_);
+ final SSLSocket socket = (SSLSocket)createSSLSocket(_socket_);
socket.setEnableSessionCreation(isCreation);
socket.setUseClientMode(isClientMode);
@@ -311,7 +311,7 @@ public class FTPSClient extends FTPClient {
* @param keyManager The KeyManager implementation to set.
* @see org.apache.commons.net.util.KeyManagerUtils
*/
- public void setKeyManager(KeyManager keyManager) {
+ public void setKeyManager(final KeyManager keyManager) {
this.keyManager = keyManager;
}
@@ -319,7 +319,7 @@ public class FTPSClient extends FTPClient {
* Controls whether a new SSL session may be established by this socket.
* @param isCreation The established socket flag.
*/
- public void setEnabledSessionCreation(boolean isCreation) {
+ public void setEnabledSessionCreation(final boolean isCreation) {
this.isCreation = isCreation;
}
@@ -343,7 +343,7 @@ public class FTPSClient extends FTPClient {
* Configures the socket to require client authentication.
* @param isNeedClientAuth The need client auth flag.
*/
- public void setNeedClientAuth(boolean isNeedClientAuth) {
+ public void setNeedClientAuth(final boolean isNeedClientAuth) {
this.isNeedClientAuth = isNeedClientAuth;
}
@@ -366,7 +366,7 @@ public class FTPSClient extends FTPClient {
* suite negotiated.
* @param isWantClientAuth The want client auth flag.
*/
- public void setWantClientAuth(boolean isWantClientAuth) {
+ public void setWantClientAuth(final boolean isWantClientAuth) {
this.isWantClientAuth = isWantClientAuth;
}
@@ -388,7 +388,7 @@ public class FTPSClient extends FTPClient {
* handshake.
* @param isClientMode The use client mode flag.
*/
- public void setUseClientMode(boolean isClientMode) {
+ public void setUseClientMode(final boolean isClientMode) {
this.isClientMode = isClientMode;
}
@@ -411,7 +411,7 @@ public class FTPSClient extends FTPClient {
* connection. Called before server negotiation.
* @param cipherSuites The cipher suites.
*/
- public void setEnabledCipherSuites(String[] cipherSuites) {
+ public void setEnabledCipherSuites(final String[] cipherSuites) {
suites = new String[cipherSuites.length];
System.arraycopy(cipherSuites, 0, suites, 0, cipherSuites.length);
}
@@ -434,7 +434,7 @@ public class FTPSClient extends FTPClient {
* connection. I perform setting before a server negotiation.
* @param protocolVersions The protocol versions.
*/
- public void setEnabledProtocols(String[] protocolVersions) {
+ public void setEnabledProtocols(final String[] protocolVersions) {
protocols = new String[protocolVersions.length];
System.arraycopy(protocolVersions, 0, protocols, 0, protocolVersions.length);
}
@@ -460,11 +460,11 @@ public class FTPSClient extends FTPClient {
* the command.
* @see #parsePBSZ(long)
*/
- public void execPBSZ(long pbsz) throws SSLException, IOException {
+ public void execPBSZ(final long pbsz) throws SSLException, IOException {
if (pbsz < 0 || 4294967295L < pbsz) { // 32-bit unsigned number
throw new IllegalArgumentException();
}
- int status = sendCommand(CMD_PBSZ, String.valueOf(pbsz));
+ final int status = sendCommand(CMD_PBSZ, String.valueOf(pbsz));
if (FTPReply.COMMAND_OK != status) {
throw new SSLException(getReplyString());
}
@@ -482,12 +482,12 @@ public class FTPSClient extends FTPClient {
* @see #execPBSZ(long)
* @since 3.0
*/
- public long parsePBSZ(long pbsz) throws SSLException, IOException {
+ public long parsePBSZ(final long pbsz) throws SSLException, IOException {
execPBSZ(pbsz);
long minvalue = pbsz;
- String remainder = extractPrefixedData("PBSZ=", getReplyString());
+ final String remainder = extractPrefixedData("PBSZ=", getReplyString());
if (remainder != null) {
- long replysz = Long.parseLong(remainder);
+ final long replysz = Long.parseLong(remainder);
if (replysz < minvalue) {
minvalue = replysz;
}
@@ -537,8 +537,8 @@ public class FTPSClient extends FTPClient {
* @param prot Data Channel Protection Level.
* @return True - A set point is right / False - A set point is not right
*/
- private boolean checkPROTValue(String prot) {
- for (String element : PROT_COMMAND_VALUE)
+ private boolean checkPROTValue(final String prot) {
+ for (final String element : PROT_COMMAND_VALUE)
{
if (element.equals(prot)) {
return true;
@@ -559,8 +559,8 @@ public class FTPSClient extends FTPClient {
*/
// Would like to remove this method, but that will break any existing clients that are using CCC
@Override
- public int sendCommand(String command, String args) throws IOException {
- int repCode = super.sendCommand(command, args);
+ public int sendCommand(final String command, final String args) throws IOException {
+ final int repCode = super.sendCommand(command, args);
/* If CCC is issued, restore socket i/o streams to unsecured versions */
if (CMD_CCC.equals(command)) {
if (FTPReply.COMMAND_OK == repCode) {
@@ -597,7 +597,7 @@ public class FTPSClient extends FTPClient {
// Strictly speaking this is not needed, but it works round a Clirr bug
// So rather than invoke the parent code, we do it here
@Deprecated
- protected Socket _openDataConnection_(int command, String arg)
+ protected Socket _openDataConnection_(final int command, final String arg)
throws IOException {
return _openDataConnection_(FTPCommand.getCommand(command), arg);
}
@@ -617,12 +617,12 @@ public class FTPSClient extends FTPClient {
* @since 3.2
*/
@Override
- protected Socket _openDataConnection_(String command, String arg)
+ protected Socket _openDataConnection_(final String command, final String arg)
throws IOException {
- Socket socket = super._openDataConnection_(command, arg);
+ final Socket socket = super._openDataConnection_(command, arg);
_prepareDataSocket_(socket);
if (socket instanceof SSLSocket) {
- SSLSocket sslSocket = (SSLSocket)socket;
+ final SSLSocket sslSocket = (SSLSocket)socket;
sslSocket.setUseClientMode(isClientMode);
sslSocket.setEnableSessionCreation(isCreation);
@@ -654,7 +654,7 @@ public class FTPSClient extends FTPClient {
* @throws IOException on error
* @since 3.1
*/
- protected void _prepareDataSocket_(Socket socket)
+ protected void _prepareDataSocket_(final Socket socket)
throws IOException {
}
@@ -674,7 +674,7 @@ public class FTPSClient extends FTPClient {
* @param trustManager The TrustManager implementation to set, may be {@code null}
* @see org.apache.commons.net.util.TrustManagerUtils
*/
- public void setTrustManager(TrustManager trustManager) {
+ public void setTrustManager(final TrustManager trustManager) {
this.trustManager = trustManager;
}
@@ -695,7 +695,7 @@ public class FTPSClient extends FTPClient {
* @param newHostnameVerifier The HostnameVerifier implementation to set or <code>null</code> to disable.
* @since 3.4
*/
- public void setHostnameVerifier(HostnameVerifier newHostnameVerifier)
+ public void setHostnameVerifier(final HostnameVerifier newHostnameVerifier)
{
hostnameVerifier = newHostnameVerifier;
}
@@ -723,7 +723,7 @@ public class FTPSClient extends FTPClient {
* @param enable Enable automatic endpoint identification checking using the HTTPS algorithm on Java 1.7+.
* @since 3.4
*/
- public void setEndpointCheckingEnabled(boolean enable)
+ public void setEndpointCheckingEnabled(final boolean enable)
{
tlsEndpointChecking = enable;
}
@@ -757,7 +757,7 @@ public class FTPSClient extends FTPClient {
* the command.
* @since 3.0
*/
- public int execAUTH(String mechanism) throws IOException
+ public int execAUTH(final String mechanism) throws IOException
{
return sendCommand(CMD_AUTH, mechanism);
}
@@ -770,7 +770,7 @@ public class FTPSClient extends FTPClient {
* the command.
* @since 3.0
*/
- public int execADAT(byte[] data) throws IOException
+ public int execADAT(final byte[] data) throws IOException
{
if (data != null)
{
@@ -793,7 +793,7 @@ public class FTPSClient extends FTPClient {
*/
public int execCCC() throws IOException
{
- int repCode = sendCommand(CMD_CCC);
+ final int repCode = sendCommand(CMD_CCC);
// This will be performed by sendCommand(String, String)
// if (FTPReply.isPositiveCompletion(repCode)) {
// _socket_.close();
@@ -816,7 +816,7 @@ public class FTPSClient extends FTPClient {
* the command.
* @since 3.0
*/
- public int execMIC(byte[] data) throws IOException
+ public int execMIC(final byte[] data) throws IOException
{
if (data != null)
{
@@ -836,7 +836,7 @@ public class FTPSClient extends FTPClient {
* the command.
* @since 3.0
*/
- public int execCONF(byte[] data) throws IOException
+ public int execCONF(final byte[] data) throws IOException
{
if (data != null)
{
@@ -856,7 +856,7 @@ public class FTPSClient extends FTPClient {
* the command.
* @since 3.0
*/
- public int execENC(byte[] data) throws IOException
+ public int execENC(final byte[] data) throws IOException
{
if (data != null)
{
@@ -874,7 +874,7 @@ public class FTPSClient extends FTPClient {
* @return the data in the reply, base64-decoded.
* @since 3.0
*/
- public byte[] parseADATReply(String reply)
+ public byte[] parseADATReply(final String reply)
{
if (reply == null) {
return null;
@@ -889,8 +889,8 @@ public class FTPSClient extends FTPClient {
* @param reply where to find the prefix
* @return the remainder of the string after the prefix, or null if the prefix was not present.
*/
- private String extractPrefixedData(String prefix, String reply) {
- int idx = reply.indexOf(prefix);
+ private String extractPrefixedData(final String prefix, final String reply) {
+ final int idx = reply.indexOf(prefix);
if (idx == -1) {
return null;
}
@@ -905,9 +905,9 @@ public class FTPSClient extends FTPClient {
* @return SSL Sockect
* @throws IOException
*/
- private Socket createSSLSocket(Socket socket) throws IOException {
+ private Socket createSSLSocket(final Socket socket) throws IOException {
if (socket != null) {
- SSLSocketFactory f = context.getSocketFactory();
+ final SSLSocketFactory f = context.getSocketFactory();
return f.createSocket(socket, socket.getInetAddress().getHostAddress(), socket.getPort(), false);
} else {
return null;
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java b/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java
index c6bade3..a3dea83 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPSCommand.java
@@ -46,7 +46,7 @@ public final class FTPSCommand {
* @return The FTPS command string corresponding to a specified
* command code.
*/
- public static final String getCommand(int command) {
+ public static final String getCommand(final int command) {
return _commands[command];
}
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java b/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java
index abd382d..f227ba0 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPSServerSocketFactory.java
@@ -34,7 +34,7 @@ public class FTPSServerSocketFactory extends ServerSocketFactory {
/** Factory for secure socket factories */
private final SSLContext context;
- public FTPSServerSocketFactory(SSLContext context) {
+ public FTPSServerSocketFactory(final SSLContext context) {
this.context = context;
}
@@ -45,17 +45,17 @@ public class FTPSServerSocketFactory extends ServerSocketFactory {
}
@Override
- public ServerSocket createServerSocket(int port) throws IOException {
+ public ServerSocket createServerSocket(final int port) throws IOException {
return init(this.context.getServerSocketFactory().createServerSocket(port));
}
@Override
- public ServerSocket createServerSocket(int port, int backlog) throws IOException {
+ public ServerSocket createServerSocket(final int port, final int backlog) throws IOException {
return init(this.context.getServerSocketFactory().createServerSocket(port, backlog));
}
@Override
- public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
+ public ServerSocket createServerSocket(final int port, final int backlog, final InetAddress ifAddress) throws IOException {
return init(this.context.getServerSocketFactory().createServerSocket(port, backlog, ifAddress));
}
@@ -66,7 +66,7 @@ public class FTPSServerSocketFactory extends ServerSocketFactory {
* @return the socket
* @throws ClassCastException if socket is not an instance of SSLServerSocket
*/
- public ServerSocket init(ServerSocket socket) {
+ public ServerSocket init(final ServerSocket socket) {
((SSLServerSocket) socket).setUseClientMode(true);
return socket;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java b/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
index d24405d..bb68858 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPSSocketFactory.java
@@ -35,7 +35,7 @@ public class FTPSSocketFactory extends SocketFactory {
private final SSLContext context;
- public FTPSSocketFactory(SSLContext context) {
+ public FTPSSocketFactory(final SSLContext context) {
this.context = context;
}
@@ -46,23 +46,23 @@ public class FTPSSocketFactory extends SocketFactory {
}
@Override
- public Socket createSocket(String address, int port) throws UnknownHostException, IOException {
+ public Socket createSocket(final String address, final int port) throws UnknownHostException, IOException {
return this.context.getSocketFactory().createSocket(address, port);
}
@Override
- public Socket createSocket(InetAddress address, int port) throws IOException {
+ public Socket createSocket(final InetAddress address, final int port) throws IOException {
return this.context.getSocketFactory().createSocket(address, port);
}
@Override
- public Socket createSocket(String address, int port, InetAddress localAddress, int localPort)
+ public Socket createSocket(final String address, final int port, final InetAddress localAddress, final int localPort)
throws UnknownHostException, IOException {
return this.context.getSocketFactory().createSocket(address, port, localAddress, localPort);
}
@Override
- public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
+ public Socket createSocket(final InetAddress address, final int port, final InetAddress localAddress, final int localPort) throws IOException {
return this.context.getSocketFactory().createSocket(address, port, localAddress, localPort);
}
@@ -74,7 +74,7 @@ public class FTPSSocketFactory extends SocketFactory {
* @throws IOException on error
* @deprecated (2.2) use {@link FTPSServerSocketFactory#createServerSocket(int) instead} */
@Deprecated
- public java.net.ServerSocket createServerSocket(int port) throws IOException {
+ public java.net.ServerSocket createServerSocket(final int port) throws IOException {
return this.init(this.context.getServerSocketFactory().createServerSocket(port));
}
@@ -84,7 +84,7 @@ public class FTPSSocketFactory extends SocketFactory {
* @throws IOException on error
* @deprecated (2.2) use {@link FTPSServerSocketFactory#createServerSocket(int, int) instead} */
@Deprecated
- public java.net.ServerSocket createServerSocket(int port, int backlog) throws IOException {
+ public java.net.ServerSocket createServerSocket(final int port, final int backlog) throws IOException {
return this.init(this.context.getServerSocketFactory().createServerSocket(port, backlog));
}
@@ -95,7 +95,7 @@ public class FTPSSocketFactory extends SocketFactory {
* @throws IOException on error
* @deprecated (2.2) use {@link FTPSServerSocketFactory#createServerSocket(int, int, InetAddress) instead} */
@Deprecated
- public java.net.ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
+ public java.net.ServerSocket createServerSocket(final int port, final int backlog, final InetAddress ifAddress) throws IOException {
return this.init(this.context.getServerSocketFactory().createServerSocket(port, backlog, ifAddress));
}
@@ -104,7 +104,7 @@ public class FTPSSocketFactory extends SocketFactory {
* @throws IOException on error
* @deprecated (2.2) use {@link FTPSServerSocketFactory#init(java.net.ServerSocket)} */
@Deprecated
- public java.net.ServerSocket init(java.net.ServerSocket socket) throws IOException {
+ public java.net.ServerSocket init(final java.net.ServerSocket socket) throws IOException {
((javax.net.ssl.SSLServerSocket) socket).setUseClientMode(true);
return socket;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java b/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
index 56fbea2..c95b5f9 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
@@ -38,15 +38,15 @@ public class FTPSTrustManager implements X509TrustManager
* No-op
*/
@Override
- public void checkClientTrusted(X509Certificate[] certificates, String authType)
+ public void checkClientTrusted(final X509Certificate[] certificates, final String authType)
{
return;
}
@Override
- public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException
+ public void checkServerTrusted(final X509Certificate[] certificates, final String authType) throws CertificateException
{
- for (X509Certificate certificate : certificates)
+ for (final X509Certificate certificate : certificates)
{
certificate.checkValidity();
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
index 7c26643..b0add89 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
@@ -33,7 +33,7 @@ public class CompositeFileEntryParser extends FTPFileEntryParserImpl
private final FTPFileEntryParser[] ftpFileEntryParsers;
private FTPFileEntryParser cachedFtpFileEntryParser;
- public CompositeFileEntryParser(FTPFileEntryParser[] ftpFileEntryParsers)
+ public CompositeFileEntryParser(final FTPFileEntryParser[] ftpFileEntryParsers)
{
super();
@@ -42,11 +42,11 @@ public class CompositeFileEntryParser extends FTPFileEntryParserImpl
}
@Override
- public FTPFile parseFTPEntry(String listEntry)
+ public FTPFile parseFTPEntry(final String listEntry)
{
if (cachedFtpFileEntryParser != null)
{
- FTPFile matched = cachedFtpFileEntryParser.parseFTPEntry(listEntry);
+ final FTPFile matched = cachedFtpFileEntryParser.parseFTPEntry(listEntry);
if (matched != null)
{
return matched;
@@ -54,9 +54,9 @@ public class CompositeFileEntryParser extends FTPFileEntryParserImpl
}
else
{
- for (FTPFileEntryParser ftpFileEntryParser : ftpFileEntryParsers)
+ for (final FTPFileEntryParser ftpFileEntryParser : ftpFileEntryParsers)
{
- FTPFile matched = ftpFileEntryParser.parseFTPEntry(listEntry);
+ final FTPFile matched = ftpFileEntryParser.parseFTPEntry(listEntry);
if (matched != null)
{
cachedFtpFileEntryParser = ftpFileEntryParser;
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/ConfigurableFTPFileEntryParserImpl.java b/src/main/java/org/apache/commons/net/ftp/parser/ConfigurableFTPFileEntryParserImpl.java
index d61693e..6e30a77 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/ConfigurableFTPFileEntryParserImpl.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/ConfigurableFTPFileEntryParserImpl.java
@@ -50,7 +50,7 @@ implements Configurable
* @param regex Regular expression used main parsing of the
* file listing.
*/
- public ConfigurableFTPFileEntryParserImpl(String regex)
+ public ConfigurableFTPFileEntryParserImpl(final String regex)
{
super(regex);
this.timestampParser = new FTPTimestampParserImpl();
@@ -64,7 +64,7 @@ implements Configurable
* {@link java.util.regex.Pattern#compile(String, int) Pattern#compile(String, int)}. Use 0 for none.
* @since 3.4
*/
- public ConfigurableFTPFileEntryParserImpl(String regex, int flags)
+ public ConfigurableFTPFileEntryParserImpl(final String regex, final int flags)
{
super(regex, flags);
this.timestampParser = new FTPTimestampParserImpl();
@@ -81,7 +81,7 @@ implements Configurable
* timestamp parse.
* @throws ParseException on parse error
*/
- public Calendar parseTimestamp(String timestampStr) throws ParseException {
+ public Calendar parseTimestamp(final String timestampStr) throws ParseException {
return this.timestampParser.parseTimestamp(timestampStr);
}
@@ -99,10 +99,10 @@ implements Configurable
* each concrete subclass is used instead.
*/
@Override
- public void configure(FTPClientConfig config)
+ public void configure(final FTPClientConfig config)
{
if (this.timestampParser instanceof Configurable) {
- FTPClientConfig defaultCfg = getDefaultConfiguration();
+ final FTPClientConfig defaultCfg = getDefaultConfiguration();
if (config != null) {
if (null == config.getDefaultDateFormatStr()) {
config.setDefaultDateFormatStr(defaultCfg.getDefaultDateFormatStr());
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.java b/src/main/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.java
index 19e4c8e..196ff16 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.java
@@ -86,7 +86,7 @@ public class DefaultFTPFileEntryParserFactory
* @see FTPFileEntryParser
*/
@Override
- public FTPFileEntryParser createFileEntryParser(String key)
+ public FTPFileEntryParser createFileEntryParser(final String key)
{
if (key == null) {
throw new ParserInitializationException("Parser key cannot be null");
@@ -95,32 +95,32 @@ public class DefaultFTPFileEntryParserFactory
}
// Common method to process both key and config parameters.
- private FTPFileEntryParser createFileEntryParser(String key, FTPClientConfig config) {
+ private FTPFileEntryParser createFileEntryParser(final String key, final FTPClientConfig config) {
FTPFileEntryParser parser = null;
// Is the key a possible class name?
if (JAVA_QUALIFIED_NAME_PATTERN.matcher(key).matches()) {
try
{
- Class<?> parserClass = Class.forName(key);
+ final Class<?> parserClass = Class.forName(key);
try {
parser = (FTPFileEntryParser) parserClass.newInstance();
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
throw new ParserInitializationException(parserClass.getName()
+ " does not implement the interface "
+ "org.apache.commons.net.ftp.FTPFileEntryParser.", e);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParserInitializationException("Error initializing parser", e);
- } catch (ExceptionInInitializerError e) {
+ } catch (final ExceptionInInitializerError e) {
throw new ParserInitializationException("Error initializing parser", e);
}
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
// OK, assume it is an alias
}
}
if (parser == null) { // Now try for aliases
- String ukey = key.toUpperCase(java.util.Locale.ENGLISH);
+ final String ukey = key.toUpperCase(java.util.Locale.ENGLISH);
if (ukey.indexOf(FTPClientConfig.SYST_UNIX_TRIM_LEADING) >= 0)
{
parser = new UnixFTPEntryParser(config, true);
@@ -199,10 +199,10 @@ public class DefaultFTPFileEntryParserFactory
* @since 1.4
*/
@Override
- public FTPFileEntryParser createFileEntryParser(FTPClientConfig config)
+ public FTPFileEntryParser createFileEntryParser(final FTPClientConfig config)
throws ParserInitializationException
{
- String key = config.getServerSystemKey();
+ final String key = config.getServerSystemKey();
return createFileEntryParser(key, config);
}
@@ -233,7 +233,7 @@ public class DefaultFTPFileEntryParserFactory
* @param config the config to use, may be {@code null}
* @return the parser
*/
- private FTPFileEntryParser createNTFTPEntryParser(FTPClientConfig config)
+ private FTPFileEntryParser createNTFTPEntryParser(final FTPClientConfig config)
{
if (config != null && FTPClientConfig.SYST_NT.equals(
config.getServerSystemKey()))
@@ -268,7 +268,7 @@ public class DefaultFTPFileEntryParserFactory
* @param config the config to use, may be {@code null}
* @return the parser
*/
- private FTPFileEntryParser createOS400FTPEntryParser(FTPClientConfig config)
+ private FTPFileEntryParser createOS400FTPEntryParser(final FTPClientConfig config)
{
if (config != null &&
FTPClientConfig.SYST_OS400.equals(config.getServerSystemKey()))
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParser.java
index 28bd936..02d83fb 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/EnterpriseUnixFTPEntryParser.java
@@ -83,23 +83,23 @@ public class EnterpriseUnixFTPEntryParser extends RegexFTPFileEntryParserImpl
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry)
+ public FTPFile parseFTPEntry(final String entry)
{
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
if (matches(entry))
{
- String usr = group(14);
- String grp = group(15);
- String filesize = group(16);
- String mo = group(17);
- String da = group(18);
- String yr = group(20);
- String hr = group(21);
- String min = group(22);
- String name = group(23);
+ final String usr = group(14);
+ final String grp = group(15);
+ final String filesize = group(16);
+ final String mo = group(17);
+ final String da = group(18);
+ final String yr = group(20);
+ final String hr = group(21);
+ final String min = group(22);
+ final String name = group(23);
file.setType(FTPFile.FILE_TYPE);
file.setUser(usr);
@@ -108,19 +108,19 @@ public class EnterpriseUnixFTPEntryParser extends RegexFTPFileEntryParserImpl
{
file.setSize(Long.parseLong(filesize));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// intentionally do nothing
}
- Calendar cal = Calendar.getInstance();
+ final Calendar cal = Calendar.getInstance();
cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.HOUR_OF_DAY, 0);
- int pos = MONTHS.indexOf(mo);
- int month = pos / 4;
+ final int pos = MONTHS.indexOf(mo);
+ final int month = pos / 4;
final int missingUnit; // the first missing unit
try
{
@@ -152,7 +152,7 @@ public class EnterpriseUnixFTPEntryParser extends RegexFTPFileEntryParserImpl
cal.clear(missingUnit);
file.setTimestamp(cal);
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// do nothing, date will be uninitialized
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java b/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java
index 44cfec7..82ea58b 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImpl.java
@@ -79,13 +79,13 @@ public class FTPTimestampParserImpl implements
* unit found in the date format.
* Default is 0 (to avoid dropping precision)
*/
- private static int getEntry(SimpleDateFormat dateFormat) {
+ private static int getEntry(final SimpleDateFormat dateFormat) {
if (dateFormat == null) {
return 0;
}
final String FORMAT_CHARS="SsmHdM";
final String pattern = dateFormat.toPattern();
- for(char ch : FORMAT_CHARS.toCharArray()) {
+ for(final char ch : FORMAT_CHARS.toCharArray()) {
if (pattern.indexOf(ch) != -1){ // found the character
switch(ch) {
case 'S':
@@ -109,7 +109,7 @@ public class FTPTimestampParserImpl implements
/*
* Find the entry in the CALENDAR_UNITS array.
*/
- private static int indexOf(int calendarUnit) {
+ private static int indexOf(final int calendarUnit) {
int i;
for(i = 0; i <CALENDAR_UNITS.length; i++) {
if (calendarUnit == CALENDAR_UNITS[i]) {
@@ -124,7 +124,7 @@ public class FTPTimestampParserImpl implements
* the immediately preceeding unit (if any).
* Unfortunately the clear(int) method results in setting all other units.
*/
- private static void setPrecision(int index, Calendar working) {
+ private static void setPrecision(final int index, final Calendar working) {
if (index <= 0) { // e.g. MILLISECONDS
return;
}
@@ -165,8 +165,8 @@ public class FTPTimestampParserImpl implements
* @return a Calendar with the parsed timestamp
*/
@Override
- public Calendar parseTimestamp(String timestampStr) throws ParseException {
- Calendar now = Calendar.getInstance();
+ public Calendar parseTimestamp(final String timestampStr) throws ParseException {
+ final Calendar now = Calendar.getInstance();
return parseTimestamp(timestampStr, now);
}
@@ -186,14 +186,14 @@ public class FTPTimestampParserImpl implements
* @throws ParseException if timestamp cannot be parsed
* @since 1.5
*/
- public Calendar parseTimestamp(String timestampStr, Calendar serverTime) throws ParseException {
- Calendar working = (Calendar) serverTime.clone();
+ public Calendar parseTimestamp(final String timestampStr, final Calendar serverTime) throws ParseException {
+ final Calendar working = (Calendar) serverTime.clone();
working.setTimeZone(getServerTimeZone()); // is this needed?
Date parsed = null;
if (recentDateFormat != null) {
- Calendar now = (Calendar) serverTime.clone();// Copy this, because we may change it
+ final Calendar now = (Calendar) serverTime.clone();// Copy this, because we may change it
now.setTimeZone(this.getServerTimeZone());
if (lenientFutureDates) {
// add a day to "now" so that "slop" doesn't cause a date
@@ -209,13 +209,13 @@ public class FTPTimestampParserImpl implements
// all instances of short dates which are +- 6 months from current date.
// TODO this won't always work for systems that use short dates +0/-12months
// e.g. if today is Jan 1 2001 and the short date is Feb 29
- String year = Integer.toString(now.get(Calendar.YEAR));
- String timeStampStrPlusYear = timestampStr + " " + year;
- SimpleDateFormat hackFormatter = new SimpleDateFormat(recentDateFormat.toPattern() + " yyyy",
+ final String year = Integer.toString(now.get(Calendar.YEAR));
+ final String timeStampStrPlusYear = timestampStr + " " + year;
+ final SimpleDateFormat hackFormatter = new SimpleDateFormat(recentDateFormat.toPattern() + " yyyy",
recentDateFormat.getDateFormatSymbols());
hackFormatter.setLenient(false);
hackFormatter.setTimeZone(recentDateFormat.getTimeZone());
- ParsePosition pp = new ParsePosition(0);
+ final ParsePosition pp = new ParsePosition(0);
parsed = hackFormatter.parse(timeStampStrPlusYear, pp);
// Check if we parsed the full string, if so it must have been a short date originally
if (parsed != null && pp.getIndex() == timeStampStrPlusYear.length()) {
@@ -228,7 +228,7 @@ public class FTPTimestampParserImpl implements
}
}
- ParsePosition pp = new ParsePosition(0);
+ final ParsePosition pp = new ParsePosition(0);
parsed = defaultDateFormat.parse(timestampStr, pp);
// note, length checks are mandatory for us since
// SimpleDateFormat methods will succeed if less than
@@ -265,7 +265,7 @@ public class FTPTimestampParserImpl implements
* @param format The defaultDateFormat to be set.
* @param dfs the symbols to use (may be null)
*/
- private void setDefaultDateFormat(String format, DateFormatSymbols dfs) {
+ private void setDefaultDateFormat(final String format, final DateFormatSymbols dfs) {
if (format != null) {
if (dfs != null) {
this.defaultDateFormat = new SimpleDateFormat(format, dfs);
@@ -294,7 +294,7 @@ public class FTPTimestampParserImpl implements
* @param format The recentDateFormat to set.
* @param dfs the symbols to use (may be null)
*/
- private void setRecentDateFormat(String format, DateFormatSymbols dfs) {
+ private void setRecentDateFormat(final String format, final DateFormatSymbols dfs) {
if (format != null) {
if (dfs != null) {
this.recentDateFormat = new SimpleDateFormat(format, dfs);
@@ -329,7 +329,7 @@ public class FTPTimestampParserImpl implements
* @param serverTimeZone Time Id java.util.TimeZone id used by
* the ftp server. If null the client's local time zone is assumed.
*/
- private void setServerTimeZone(String serverTimeZoneId) {
+ private void setServerTimeZone(final String serverTimeZoneId) {
TimeZone serverTimeZone = TimeZone.getDefault();
if (serverTimeZoneId != null) {
serverTimeZone = TimeZone.getTimeZone(serverTimeZoneId);
@@ -364,11 +364,11 @@ public class FTPTimestampParserImpl implements
* </p>
*/
@Override
- public void configure(FTPClientConfig config) {
+ public void configure(final FTPClientConfig config) {
DateFormatSymbols dfs = null;
- String languageCode = config.getServerLanguageCode();
- String shortmonths = config.getShortMonthNames();
+ final String languageCode = config.getServerLanguageCode();
+ final String shortmonths = config.getShortMonthNames();
if (shortmonths != null) {
dfs = FTPClientConfig.getDateFormatSymbols(shortmonths);
} else if (languageCode != null) {
@@ -378,10 +378,10 @@ public class FTPTimestampParserImpl implements
}
- String recentFormatString = config.getRecentDateFormatStr();
+ final String recentFormatString = config.getRecentDateFormatStr();
setRecentDateFormat(recentFormatString, dfs);
- String defaultFormatString = config.getDefaultDateFormatStr();
+ final String defaultFormatString = config.getDefaultDateFormatStr();
if (defaultFormatString == null) {
throw new IllegalArgumentException("defaultFormatString cannot be null");
}
@@ -400,7 +400,7 @@ public class FTPTimestampParserImpl implements
/**
* @param lenientFutureDates The lenientFutureDates to set.
*/
- void setLenientFutureDates(boolean lenientFutureDates) {
+ void setLenientFutureDates(final boolean lenientFutureDates) {
this.lenientFutureDates = lenientFutureDates;
}
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
index e48897a..b304f24 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
@@ -94,10 +94,10 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
}
@Override
- public FTPFile parseFTPEntry(String entry) {
+ public FTPFile parseFTPEntry(final String entry) {
if (entry.startsWith(" ")) {// leading space means no facts are present
if (entry.length() > 1) { // is there a path name?
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
file.setName(entry.substring(1));
return file;
@@ -106,7 +106,7 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
}
}
- String parts[] = entry.split(" ",2); // Path may contain space
+ final String parts[] = entry.split(" ",2); // Path may contain space
if (parts.length != 2 || parts[1].length() == 0) {
return null; // no space found or no file name
}
@@ -114,25 +114,25 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
if (!factList.endsWith(";")) {
return null;
}
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
file.setName(parts[1]);
- String[] facts = factList.split(";");
- boolean hasUnixMode = parts[0].toLowerCase(Locale.ENGLISH).contains("unix.mode=");
- for(String fact : facts) {
- String []factparts = fact.split("=", -1); // Don't drop empty values
+ final String[] facts = factList.split(";");
+ final boolean hasUnixMode = parts[0].toLowerCase(Locale.ENGLISH).contains("unix.mode=");
+ for(final String fact : facts) {
+ final String []factparts = fact.split("=", -1); // Don't drop empty values
// Sample missing permission
// drwx------ 2 mirror mirror 4096 Mar 13 2010 subversion
// modify=20100313224553;perm=;type=dir;unique=811U282598;UNIX.group=500;UNIX.mode=0700;UNIX.owner=500; subversion
if (factparts.length != 2) {
return null; // invalid - there was no "=" sign
}
- String factname = factparts[0].toLowerCase(Locale.ENGLISH);
- String factvalue = factparts[1];
+ final String factname = factparts[0].toLowerCase(Locale.ENGLISH);
+ final String factvalue = factparts[1];
if (factvalue.length() == 0) {
continue; // nothing to see here
}
- String valueLowerCase = factvalue.toLowerCase(Locale.ENGLISH);
+ final String valueLowerCase = factvalue.toLowerCase(Locale.ENGLISH);
if ("size".equals(factname) || "sizd".equals(factname)) {
file.setSize(Long.parseLong(factvalue));
}
@@ -144,7 +144,7 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
file.setTimestamp(parsed);
}
else if ("type".equals(factname)) {
- Integer intType = TYPE_TO_INT.get(valueLowerCase);
+ final Integer intType = TYPE_TO_INT.get(valueLowerCase);
if (intType == null) {
file.setType(FTPFile.UNKNOWN_TYPE);
} else {
@@ -152,17 +152,17 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
}
}
else if (factname.startsWith("unix.")) {
- String unixfact = factname.substring("unix.".length()).toLowerCase(Locale.ENGLISH);
+ final String unixfact = factname.substring("unix.".length()).toLowerCase(Locale.ENGLISH);
if ("group".equals(unixfact)){
file.setGroup(factvalue);
} else if ("owner".equals(unixfact)){
file.setUser(factvalue);
} else if ("mode".equals(unixfact)){ // e.g. 0[1]755
- int off = factvalue.length()-3; // only parse last 3 digits
+ final int off = factvalue.length()-3; // only parse last 3 digits
for(int i=0; i < 3; i++){
- int ch = factvalue.charAt(off+i)-'0';
+ final int ch = factvalue.charAt(off+i)-'0';
if (ch >= 0 && ch <= 7) { // Check it's valid octal
- for(int p : UNIX_PERMS[ch]) {
+ for(final int p : UNIX_PERMS[ch]) {
file.setPermission(UNIX_GROUPS[i], p, true);
}
} else {
@@ -185,7 +185,7 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
* @return a Calendar entry, may be {@code null}
* @since 3.4
*/
- public static Calendar parseGMTdateTime(String timestamp) {
+ public static Calendar parseGMTdateTime(final String timestamp) {
final SimpleDateFormat sdf;
final boolean hasMillis;
if (timestamp.contains(".")){
@@ -195,11 +195,11 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
sdf = new SimpleDateFormat("yyyyMMddHHmmss");
hasMillis = false;
}
- TimeZone GMT = TimeZone.getTimeZone("GMT");
+ final TimeZone GMT = TimeZone.getTimeZone("GMT");
// both timezones need to be set for the parse to work OK
sdf.setTimeZone(GMT);
- GregorianCalendar gc = new GregorianCalendar(GMT);
- ParsePosition pos = new ParsePosition(0);
+ final GregorianCalendar gc = new GregorianCalendar(GMT);
+ final ParsePosition pos = new ParsePosition(0);
sdf.setLenient(false); // We want to parse the whole string
final Date parsed = sdf.parse(timestamp, pos);
if (pos.getIndex() != timestamp.length()) {
@@ -215,8 +215,8 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
// perm-fact = "Perm" "=" *pvals
// pvals = "a" / "c" / "d" / "e" / "f" /
// "l" / "m" / "p" / "r" / "w"
- private void doUnixPerms(FTPFile file, String valueLowerCase) {
- for(char c : valueLowerCase.toCharArray()) {
+ private void doUnixPerms(final FTPFile file, final String valueLowerCase) {
+ for(final char c : valueLowerCase.toCharArray()) {
// TODO these are mostly just guesses at present
switch (c) {
case 'a': // (file) may APPEnd
@@ -256,7 +256,7 @@ public class MLSxEntryParser extends FTPFileEntryParserImpl
} // each char
}
- public static FTPFile parseEntry(String entry) {
+ public static FTPFile parseEntry(final String entry) {
return PARSER.parseFTPEntry(entry);
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
index c24ca2c..f292b7f 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java
@@ -264,7 +264,7 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry) {
+ public FTPFile parseFTPEntry(final String entry) {
if (isType == FILE_LIST_TYPE) {
return parseFileList(entry);
} else if (isType == MEMBER_LIST_TYPE) {
@@ -303,12 +303,12 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @param entry zosDirectoryEntry
* @return null: entry was not parsed.
*/
- private FTPFile parseFileList(String entry) {
+ private FTPFile parseFileList(final String entry) {
if (matches(entry)) {
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
- String name = group(2);
- String dsorg = group(1);
+ final String name = group(2);
+ final String dsorg = group(1);
file.setName(name);
// DSORG
@@ -353,17 +353,17 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @param entry zosDirectoryEntry
* @return null: entry was not parsed.
*/
- private FTPFile parseMemberList(String entry) {
- FTPFile file = new FTPFile();
+ private FTPFile parseMemberList(final String entry) {
+ final FTPFile file = new FTPFile();
if (matches(entry)) {
file.setRawListing(entry);
- String name = group(1);
- String datestr = group(2) + " " + group(3);
+ final String name = group(1);
+ final String datestr = group(2) + " " + group(3);
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
try {
file.setTimestamp(super.parseTimestamp(datestr));
- } catch (ParseException e) {
+ } catch (final ParseException e) {
// just ignore parsing errors.
// TODO check this is ok
// Drop thru to try simple parser
@@ -378,7 +378,7 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
*/
if (entry != null && entry.trim().length() > 0) {
file.setRawListing(entry);
- String name = entry.split(" ")[0];
+ final String name = entry.split(" ")[0];
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return file;
@@ -405,12 +405,12 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @param entry zosDirectoryEntry
* @return null: entry was not parsed.
*/
- private FTPFile parseJeslevel1List(String entry) {
+ private FTPFile parseJeslevel1List(final String entry) {
if (matches(entry)) {
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
if (group(3).equalsIgnoreCase("OUTPUT")) {
file.setRawListing(entry);
- String name = group(2); /* Job Number, used by GET */
+ final String name = group(2); /* Job Number, used by GET */
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return file;
@@ -442,12 +442,12 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @param entry zosDirectoryEntry
* @return null: entry was not parsed.
*/
- private FTPFile parseJeslevel2List(String entry) {
+ private FTPFile parseJeslevel2List(final String entry) {
if (matches(entry)) {
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
if (group(4).equalsIgnoreCase("OUTPUT")) {
file.setRawListing(entry);
- String name = group(2); /* Job Number, used by GET */
+ final String name = group(2); /* Job Number, used by GET */
file.setName(name);
file.setType(FTPFile.FILE_TYPE);
return file;
@@ -467,12 +467,12 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @since 2.0
*/
@Override
- public List<String> preParse(List<String> orig) {
+ public List<String> preParse(final List<String> orig) {
// simply remove the header line. Composite logic will take care of the
// two different types of
// list in short order.
if (orig != null && orig.size() > 0) {
- String header = orig.get(0);
+ final String header = orig.get(0);
if (header.indexOf("Volume") >= 0 && header.indexOf("Dsname") >= 0) {
setType(FILE_LIST_TYPE);
super.setRegex(FILE_LIST_REGEX);
@@ -505,7 +505,7 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* Explicitly set the type of listing being processed.
* @param type The listing type.
*/
- void setType(int type) {
+ void setType(final int type) {
isType = type;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java
index 3223a5c..a0ee318 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/MacOsPeterFTPEntryParser.java
@@ -108,7 +108,7 @@ public class MacOsPeterFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public MacOsPeterFTPEntryParser(FTPClientConfig config)
+ public MacOsPeterFTPEntryParser(final FTPClientConfig config)
{
super(REGEX);
configure(config);
@@ -125,28 +125,28 @@ public class MacOsPeterFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry) {
- FTPFile file = new FTPFile();
+ public FTPFile parseFTPEntry(final String entry) {
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
int type;
boolean isDevice = false;
if (matches(entry))
{
- String typeStr = group(1);
- String hardLinkCount = "0";
- String usr = null;
- String grp = null;
- String filesize = group(20);
- String datestr = group(21) + " " + group(22);
+ final String typeStr = group(1);
+ final String hardLinkCount = "0";
+ final String usr = null;
+ final String grp = null;
+ final String filesize = group(20);
+ final String datestr = group(21) + " " + group(22);
String name = group(23);
- String endtoken = group(24);
+ final String endtoken = group(24);
try
{
file.setTimestamp(super.parseTimestamp(datestr));
}
- catch (ParseException e)
+ catch (final ParseException e)
{
// intentionally do nothing
}
@@ -190,7 +190,7 @@ public class MacOsPeterFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
file.setPermission(access, FTPFile.WRITE_PERMISSION,
(!group(g + 1).equals("-")));
- String execPerm = group(g + 2);
+ final String execPerm = group(g + 2);
if (!execPerm.equals("-") && !Character.isUpperCase(execPerm.charAt(0)))
{
file.setPermission(access, FTPFile.EXECUTE_PERMISSION, true);
@@ -207,7 +207,7 @@ public class MacOsPeterFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
file.setHardLinkCount(Integer.parseInt(hardLinkCount));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// intentionally do nothing
}
@@ -220,7 +220,7 @@ public class MacOsPeterFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
file.setSize(Long.parseLong(filesize));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// intentionally do nothing
}
@@ -237,7 +237,7 @@ public class MacOsPeterFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
if (type == FTPFile.SYMBOLIC_LINK_TYPE)
{
- int end = name.indexOf(" -> ");
+ final int end = name.indexOf(" -> ");
// Give up if no link indicator is present
if (end == -1)
{
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
index 0711b19..010f9fb 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
@@ -72,11 +72,11 @@ public class NTFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public NTFTPEntryParser(FTPClientConfig config)
+ public NTFTPEntryParser(final FTPClientConfig config)
{
super(REGEX, Pattern.DOTALL);
configure(config);
- FTPClientConfig config2 = new FTPClientConfig(
+ final FTPClientConfig config2 = new FTPClientConfig(
FTPClientConfig.SYST_NT,
DEFAULT_DATE_FORMAT2,
null);
@@ -96,29 +96,29 @@ public class NTFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry)
+ public FTPFile parseFTPEntry(final String entry)
{
- FTPFile f = new FTPFile();
+ final FTPFile f = new FTPFile();
f.setRawListing(entry);
if (matches(entry))
{
- String datestr = group(1)+" "+group(2);
- String dirString = group(3);
- String size = group(4);
- String name = group(5);
+ final String datestr = group(1)+" "+group(2);
+ final String dirString = group(3);
+ final String size = group(4);
+ final String name = group(5);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
- catch (ParseException e)
+ catch (final ParseException e)
{
// parsing fails, try the other date format
try
{
f.setTimestamp(timestampParser.parseTimestamp(datestr));
}
- catch (ParseException e2)
+ catch (final ParseException e2)
{
// intentionally do nothing
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParser.java
index f7997b8..ea81a5b 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/NetwareFTPEntryParser.java
@@ -78,7 +78,7 @@ public class NetwareFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public NetwareFTPEntryParser(FTPClientConfig config) {
+ public NetwareFTPEntryParser(final FTPClientConfig config) {
super(REGEX);
configure(config);
}
@@ -111,20 +111,20 @@ public class NetwareFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry) {
+ public FTPFile parseFTPEntry(final String entry) {
- FTPFile f = new FTPFile();
+ final FTPFile f = new FTPFile();
if (matches(entry)) {
- String dirString = group(1);
- String attrib = group(2);
- String user = group(3);
- String size = group(4);
- String datestr = group(5);
- String name = group(9);
+ final String dirString = group(1);
+ final String attrib = group(2);
+ final String user = group(3);
+ final String size = group(4);
+ final String datestr = group(5);
+ final String name = group(9);
try {
f.setTimestamp(super.parseTimestamp(datestr));
- } catch (ParseException e) {
+ } catch (final ParseException e) {
// intentionally do nothing
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParser.java
index 4e291f5..a5ddc5b 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/OS2FTPEntryParser.java
@@ -67,7 +67,7 @@ public class OS2FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public OS2FTPEntryParser(FTPClientConfig config)
+ public OS2FTPEntryParser(final FTPClientConfig config)
{
super(REGEX);
configure(config);
@@ -84,22 +84,22 @@ public class OS2FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry)
+ public FTPFile parseFTPEntry(final String entry)
{
- FTPFile f = new FTPFile();
+ final FTPFile f = new FTPFile();
if (matches(entry))
{
- String size = group(1);
- String attrib = group(2);
- String dirString = group(3);
- String datestr = group(4)+" "+group(5);
- String name = group(6);
+ final String size = group(1);
+ final String attrib = group(2);
+ final String dirString = group(3);
+ final String datestr = group(4)+" "+group(5);
+ final String name = group(6);
try
{
f.setTimestamp(super.parseTimestamp(datestr));
}
- catch (ParseException e)
+ catch (final ParseException e)
{
// intentionally do nothing
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java
index c45b617..74e72ab 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java
@@ -271,7 +271,7 @@ public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public OS400FTPEntryParser(FTPClientConfig config)
+ public OS400FTPEntryParser(final FTPClientConfig config)
{
super(REGEX);
configure(config);
@@ -279,23 +279,23 @@ public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
@Override
- public FTPFile parseFTPEntry(String entry)
+ public FTPFile parseFTPEntry(final String entry)
{
- FTPFile file = new FTPFile();
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
int type;
if (matches(entry))
{
- String usr = group(1);
- String filesize = group(2);
+ final String usr = group(1);
+ final String filesize = group(2);
String datestr = "";
if (!isNullOrEmpty(group(3)) || !isNullOrEmpty(group(4)))
{
datestr = group(3)+" "+group(4);
}
- String typeStr = group(5);
+ final String typeStr = group(5);
String name = group(6);
boolean mustScanForPathSeparator = true;
@@ -304,7 +304,7 @@ public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
file.setTimestamp(super.parseTimestamp(datestr));
}
- catch (ParseException e)
+ catch (final ParseException e)
{
// intentionally do nothing
}
@@ -379,7 +379,7 @@ public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
file.setSize(Long.parseLong(filesize));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// intentionally do nothing
}
@@ -390,7 +390,7 @@ public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
}
if (mustScanForPathSeparator)
{
- int pos = name.lastIndexOf('/');
+ final int pos = name.lastIndexOf('/');
if (pos > -1)
{
name = name.substring(pos + 1);
@@ -411,7 +411,7 @@ public class OS400FTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @return <code>true</code> for <code>null</code> or empty values,
* else <code>false</code>.
*/
- private boolean isNullOrEmpty(String string) {
+ private boolean isNullOrEmpty(final String string) {
if (string == null || string.length() == 0) {
return true;
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/ParserInitializationException.java b/src/main/java/org/apache/commons/net/ftp/parser/ParserInitializationException.java
index 080f809..e4a7ad1 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/ParserInitializationException.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/ParserInitializationException.java
@@ -31,7 +31,7 @@ public class ParserInitializationException extends RuntimeException {
*
* @param message Exception message
*/
- public ParserInitializationException(String message) {
+ public ParserInitializationException(final String message) {
super(message);
}
@@ -43,7 +43,7 @@ public class ParserInitializationException extends RuntimeException {
* @param rootCause root cause throwable that caused
* this to be thrown
*/
- public ParserInitializationException(String message, Throwable rootCause) {
+ public ParserInitializationException(final String message, final Throwable rootCause) {
super(message, rootCause);
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java b/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java
index 50ef365..b7a46ca 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java
@@ -66,7 +66,7 @@ public abstract class RegexFTPFileEntryParserImpl extends
* from this will bomb very quickly, leading to easy detection.
*/
- public RegexFTPFileEntryParserImpl(String regex) {
+ public RegexFTPFileEntryParserImpl(final String regex) {
super();
compileRegex(regex, 0);
}
@@ -86,7 +86,7 @@ public abstract class RegexFTPFileEntryParserImpl extends
* from this will bomb very quickly, leading to easy detection.
* @since 3.4
*/
- public RegexFTPFileEntryParserImpl(String regex, final int flags) {
+ public RegexFTPFileEntryParserImpl(final String regex, final int flags) {
super();
compileRegex(regex, flags);
}
@@ -99,7 +99,7 @@ public abstract class RegexFTPFileEntryParserImpl extends
* @return true if s matches this object's regular expression.
*/
- public boolean matches(String s) {
+ public boolean matches(final String s) {
this.result = null;
_matcher_ = pattern.matcher(s);
if (_matcher_.matches()) {
@@ -131,7 +131,7 @@ public abstract class RegexFTPFileEntryParserImpl extends
* match or null if this method is called without a match having
* been made.
*/
- public String group(int matchnum) {
+ public String group(final int matchnum) {
if (this.result == null) {
return null;
}
@@ -146,7 +146,7 @@ public abstract class RegexFTPFileEntryParserImpl extends
*/
public String getGroupsAsString() {
- StringBuilder b = new StringBuilder();
+ final StringBuilder b = new StringBuilder();
for (int i = 1; i <= this.result.groupCount(); i++) {
b.append(i).append(") ").append(this.result.group(i)).append(
System.getProperty("line.separator"));
@@ -195,7 +195,7 @@ public abstract class RegexFTPFileEntryParserImpl extends
private void compileRegex(final String regex, final int flags) {
try {
pattern = Pattern.compile(regex, flags);
- } catch (PatternSyntaxException pse) {
+ } catch (final PatternSyntaxException pse) {
throw new IllegalArgumentException("Unparseable regex supplied: " + regex);
}
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
index 2f12fe2..625e322 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
@@ -174,7 +174,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public UnixFTPEntryParser(FTPClientConfig config)
+ public UnixFTPEntryParser(final FTPClientConfig config)
{
this(config, false);
}
@@ -192,7 +192,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 3.4
*/
- public UnixFTPEntryParser(FTPClientConfig config, boolean trimLeadingSpaces)
+ public UnixFTPEntryParser(final FTPClientConfig config, final boolean trimLeadingSpaces)
{
super(REGEX);
configure(config);
@@ -203,10 +203,10 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* Preparse the list to discard "total nnn" lines
*/
@Override
- public List<String> preParse(List<String> original) {
- ListIterator<String> iter = original.listIterator();
+ public List<String> preParse(final List<String> original) {
+ final ListIterator<String> iter = original.listIterator();
while (iter.hasNext()) {
- String entry = iter.next();
+ final String entry = iter.next();
if (entry.matches("^total \\d+$")) { // NET-389
iter.remove();
}
@@ -225,20 +225,20 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry) {
- FTPFile file = new FTPFile();
+ public FTPFile parseFTPEntry(final String entry) {
+ final FTPFile file = new FTPFile();
file.setRawListing(entry);
int type;
boolean isDevice = false;
if (matches(entry))
{
- String typeStr = group(1);
- String hardLinkCount = group(15);
- String usr = group(16);
- String grp = group(17);
- String filesize = group(18);
- String datestr = group(19) + " " + group(20);
+ final String typeStr = group(1);
+ final String hardLinkCount = group(15);
+ final String usr = group(16);
+ final String grp = group(17);
+ final String filesize = group(18);
+ final String datestr = group(19) + " " + group(20);
String name = group(21);
if (trimLeadingSpaces) {
name = name.replaceFirst("^\\s+", "");
@@ -247,7 +247,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
try
{
if (group(19).contains(JA_MONTH)) { // special processing for Japanese format
- FTPTimestampParserImpl jaParser = new FTPTimestampParserImpl();
+ final FTPTimestampParserImpl jaParser = new FTPTimestampParserImpl();
jaParser.configure(new FTPClientConfig(
FTPClientConfig.SYST_UNIX, DEFAULT_DATE_FORMAT_JA, DEFAULT_RECENT_DATE_FORMAT_JA));
file.setTimestamp(jaParser.parseTimestamp(datestr));
@@ -255,7 +255,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
file.setTimestamp(super.parseTimestamp(datestr));
}
}
- catch (ParseException e)
+ catch (final ParseException e)
{
// intentionally do nothing
}
@@ -299,7 +299,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
file.setPermission(access, FTPFile.WRITE_PERMISSION,
(!group(g + 1).equals("-")));
- String execPerm = group(g + 2);
+ final String execPerm = group(g + 2);
if (!execPerm.equals("-") && !Character.isUpperCase(execPerm.charAt(0)))
{
file.setPermission(access, FTPFile.EXECUTE_PERMISSION, true);
@@ -316,7 +316,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
file.setHardLinkCount(Integer.parseInt(hardLinkCount));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// intentionally do nothing
}
@@ -329,7 +329,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
file.setSize(Long.parseLong(filesize));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// intentionally do nothing
}
@@ -339,7 +339,7 @@ public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
if (type == FTPFile.SYMBOLIC_LINK_TYPE)
{
- int end = name.indexOf(" -> ");
+ final int end = name.indexOf(" -> ");
// Give up if no link indicator is present
if (end == -1)
{
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java
index 2ac815d..3756181 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java
@@ -86,7 +86,7 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public VMSFTPEntryParser(FTPClientConfig config)
+ public VMSFTPEntryParser(final FTPClientConfig config)
{
super(REGEX);
configure(config);
@@ -103,20 +103,20 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @return An FTPFile instance corresponding to the supplied entry
*/
@Override
- public FTPFile parseFTPEntry(String entry)
+ public FTPFile parseFTPEntry(final String entry)
{
//one block in VMS equals 512 bytes
- long longBlock = 512;
+ final long longBlock = 512;
if (matches(entry))
{
- FTPFile f = new FTPFile();
+ final FTPFile f = new FTPFile();
f.setRawListing(entry);
String name = group(1);
- String size = group(2);
- String datestr = group(3)+" "+group(4);
- String owner = group(5);
- String permissions[] = new String[3];
+ final String size = group(2);
+ final String datestr = group(3)+" "+group(4);
+ final String owner = group(5);
+ final String permissions[] = new String[3];
permissions[0]= group(9);
permissions[1]= group(10);
permissions[2]= group(11);
@@ -124,7 +124,7 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
{
f.setTimestamp(super.parseTimestamp(datestr));
}
- catch (ParseException e)
+ catch (final ParseException e)
{
// intentionally do nothing
}
@@ -132,7 +132,7 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
String grp;
String user;
- StringTokenizer t = new StringTokenizer(owner, ",");
+ final StringTokenizer t = new StringTokenizer(owner, ",");
switch (t.countTokens()) {
case 1:
grp = null;
@@ -168,7 +168,7 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
}
//size is retreived in blocks and needs to be put in bytes
//for us humans and added to the FTPFile array
- long sizeInBytes = Long.parseLong(size) * longBlock;
+ final long sizeInBytes = Long.parseLong(size) * longBlock;
f.setSize(sizeInBytes);
f.setGroup(grp);
@@ -182,7 +182,7 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
//iterate for OWNER GROUP WORLD permissions
for (int access = 0; access < 3; access++)
{
- String permission = permissions[access];
+ final String permission = permissions[access];
f.setPermission(access, FTPFile.READ_PERMISSION, permission.indexOf('R')>=0);
f.setPermission(access, FTPFile.WRITE_PERMISSION, permission.indexOf('W')>=0);
@@ -208,10 +208,10 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @throws IOException thrown on any IO Error reading from the reader.
*/
@Override
- public String readNextEntry(BufferedReader reader) throws IOException
+ public String readNextEntry(final BufferedReader reader) throws IOException
{
String line = reader.readLine();
- StringBuilder entry = new StringBuilder();
+ final StringBuilder entry = new StringBuilder();
while (line != null)
{
if (line.startsWith("Directory") || line.startsWith("Total")) {
@@ -257,8 +257,8 @@ public class VMSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
* @deprecated (2.2) No other FTPFileEntryParser implementations have this method.
*/
@Deprecated
- public FTPFile[] parseFileList(java.io.InputStream listStream) throws IOException {
- org.apache.commons.net.ftp.FTPListParseEngine engine = new org.apache.commons.net.ftp.FTPListParseEngine(this);
+ public FTPFile[] parseFileList(final java.io.InputStream listStream) throws IOException {
+ final org.apache.commons.net.ftp.FTPListParseEngine engine = new org.apache.commons.net.ftp.FTPListParseEngine(this);
engine.readServerList(listStream, null);
return engine.getFiles();
}
diff --git a/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java b/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java
index 2e2619a..07e65ce 100644
--- a/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java
+++ b/src/main/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java
@@ -74,7 +74,7 @@ public class VMSVersioningFTPEntryParser extends VMSFTPEntryParser
* <code>REGEX</code> is not a valid regular expression.
* @since 1.4
*/
- public VMSVersioningFTPEntryParser(FTPClientConfig config)
+ public VMSVersioningFTPEntryParser(final FTPClientConfig config)
{
super();
configure(config);
@@ -83,7 +83,7 @@ public class VMSVersioningFTPEntryParser extends VMSFTPEntryParser
//_preparse_matcher_ = new Perl5Matcher();
_preparse_pattern_ = Pattern.compile(PRE_PARSE_REGEX);
}
- catch (PatternSyntaxException pse)
+ catch (final PatternSyntaxException pse)
{
throw new IllegalArgumentException (
"Unparseable regex supplied: " + PRE_PARSE_REGEX);
@@ -101,19 +101,19 @@ public class VMSVersioningFTPEntryParser extends VMSFTPEntryParser
* @return Original list purged of duplicates
*/
@Override
- public List<String> preParse(List<String> original) {
- HashMap<String, Integer> existingEntries = new HashMap<>();
- ListIterator<String> iter = original.listIterator();
+ public List<String> preParse(final List<String> original) {
+ final HashMap<String, Integer> existingEntries = new HashMap<>();
+ final ListIterator<String> iter = original.listIterator();
while (iter.hasNext()) {
- String entry = iter.next().trim();
+ final String entry = iter.next().trim();
MatchResult result = null;
- Matcher _preparse_matcher_ = _preparse_pattern_.matcher(entry);
+ final Matcher _preparse_matcher_ = _preparse_pattern_.matcher(entry);
if (_preparse_matcher_.matches()) {
result = _preparse_matcher_.toMatchResult();
- String name = result.group(1);
- String version = result.group(2);
- Integer nv = Integer.valueOf(version);
- Integer existing = existingEntries.get(name);
+ final String name = result.group(1);
+ final String version = result.group(2);
+ final Integer nv = Integer.valueOf(version);
+ final Integer existing = existingEntries.get(name);
if (null != existing) {
if (nv.intValue() < existing.intValue()) {
iter.remove(); // removes older version from original list.
@@ -129,15 +129,15 @@ public class VMSVersioningFTPEntryParser extends VMSFTPEntryParser
// we now must remove those with smaller than the largest version number
// for each name that were found before the largest
while (iter.hasPrevious()) {
- String entry = iter.previous().trim();
+ final String entry = iter.previous().trim();
MatchResult result = null;
- Matcher _preparse_matcher_ = _preparse_pattern_.matcher(entry);
+ final Matcher _preparse_matcher_ = _preparse_pattern_.matcher(entry);
if (_preparse_matcher_.matches()) {
result = _preparse_matcher_.toMatchResult();
- String name = result.group(1);
- String version = result.group(2);
- Integer nv = Integer.valueOf(version);
- Integer existing = existingEntries.get(name);
+ final String name = result.group(1);
+ final String version = result.group(2);
+ final Integer nv = Integer.valueOf(version);
+ final Integer existing = existingEntries.get(name);
if (null != existing) {
if (nv.intValue() < existing.intValue()) {
iter.remove(); // removes older version from original list.
diff --git a/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java b/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
index 036015f..9f08147 100644
--- a/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
+++ b/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
@@ -46,7 +46,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* Constructor for AuthenticatingIMAPClient that delegates to IMAPSClient.
* @param implicit The security mode (Implicit/Explicit).
*/
- public AuthenticatingIMAPClient(boolean implicit)
+ public AuthenticatingIMAPClient(final boolean implicit)
{
this(DEFAULT_PROTOCOL, implicit);
}
@@ -55,7 +55,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* Constructor for AuthenticatingIMAPClient that delegates to IMAPSClient.
* @param proto the protocol.
*/
- public AuthenticatingIMAPClient(String proto)
+ public AuthenticatingIMAPClient(final String proto)
{
this(proto, false);
}
@@ -65,7 +65,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* @param proto the protocol.
* @param implicit The security mode(Implicit/Explicit).
*/
- public AuthenticatingIMAPClient(String proto, boolean implicit)
+ public AuthenticatingIMAPClient(final String proto, final boolean implicit)
{
this(proto, implicit, null);
}
@@ -76,7 +76,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* @param implicit The security mode(Implicit/Explicit).
* @param ctx the context
*/
- public AuthenticatingIMAPClient(String proto, boolean implicit, SSLContext ctx)
+ public AuthenticatingIMAPClient(final String proto, final boolean implicit, final SSLContext ctx)
{
super(proto, implicit, ctx);
}
@@ -86,7 +86,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* @param implicit The security mode(Implicit/Explicit).
* @param ctx A pre-configured SSL Context.
*/
- public AuthenticatingIMAPClient(boolean implicit, SSLContext ctx)
+ public AuthenticatingIMAPClient(final boolean implicit, final SSLContext ctx)
{
this(DEFAULT_PROTOCOL, implicit, ctx);
}
@@ -95,7 +95,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* Constructor for AuthenticatingIMAPClient that delegates to IMAPSClient.
* @param context A pre-configured SSL Context.
*/
- public AuthenticatingIMAPClient(SSLContext context)
+ public AuthenticatingIMAPClient(final SSLContext context)
{
this(false, context);
}
@@ -117,8 +117,8 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* @throws InvalidKeySpecException If the CRAM hash algorithm
* failed to use the given password.
*/
- public boolean authenticate(AuthenticatingIMAPClient.AUTH_METHOD method,
- String username, String password)
+ public boolean authenticate(final AuthenticatingIMAPClient.AUTH_METHOD method,
+ final String username, final String password)
throws IOException, NoSuchAlgorithmException,
InvalidKeyException, InvalidKeySpecException
{
@@ -142,8 +142,8 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* @throws InvalidKeySpecException If the CRAM hash algorithm
* failed to use the given password.
*/
- public boolean auth(AuthenticatingIMAPClient.AUTH_METHOD method,
- String username, String password)
+ public boolean auth(final AuthenticatingIMAPClient.AUTH_METHOD method,
+ final String username, final String password)
throws IOException, NoSuchAlgorithmException,
InvalidKeyException, InvalidKeySpecException
{
@@ -156,7 +156,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
case PLAIN:
{
// the server sends an empty response ("+ "), so we don't have to read it.
- int result = sendData(
+ final int result = sendData(
Base64.encodeBase64StringUnChunked(("\000" + username + "\000" + password)
.getBytes(getCharset())));
if (result == IMAPReply.OK)
@@ -168,20 +168,20 @@ public class AuthenticatingIMAPClient extends IMAPSClient
case CRAM_MD5:
{
// get the CRAM challenge (after "+ ")
- byte[] serverChallenge = Base64.decodeBase64(getReplyString().substring(2).trim());
+ final byte[] serverChallenge = Base64.decodeBase64(getReplyString().substring(2).trim());
// get the Mac instance
- Mac hmac_md5 = Mac.getInstance("HmacMD5");
+ final Mac hmac_md5 = Mac.getInstance("HmacMD5");
hmac_md5.init(new SecretKeySpec(password.getBytes(getCharset()), "HmacMD5"));
// compute the result:
- byte[] hmacResult = _convertToHexString(hmac_md5.doFinal(serverChallenge)).getBytes(getCharset());
+ final byte[] hmacResult = _convertToHexString(hmac_md5.doFinal(serverChallenge)).getBytes(getCharset());
// join the byte arrays to form the reply
- byte[] usernameBytes = username.getBytes(getCharset());
- byte[] toEncode = new byte[usernameBytes.length + 1 /* the space */ + hmacResult.length];
+ final byte[] usernameBytes = username.getBytes(getCharset());
+ final byte[] toEncode = new byte[usernameBytes.length + 1 /* the space */ + hmacResult.length];
System.arraycopy(usernameBytes, 0, toEncode, 0, usernameBytes.length);
toEncode[usernameBytes.length] = ' ';
System.arraycopy(hmacResult, 0, toEncode, usernameBytes.length + 1, hmacResult.length);
// send the reply and read the server code:
- int result = sendData(Base64.encodeBase64StringUnChunked(toEncode));
+ final int result = sendData(Base64.encodeBase64StringUnChunked(toEncode));
if (result == IMAPReply.OK)
{
setState(IMAP.IMAPState.AUTH_STATE);
@@ -196,7 +196,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
{
return false;
}
- int result = sendData(Base64.encodeBase64StringUnChunked(password.getBytes(getCharset())));
+ final int result = sendData(Base64.encodeBase64StringUnChunked(password.getBytes(getCharset())));
if (result == IMAPReply.OK)
{
setState(IMAP.IMAPState.AUTH_STATE);
@@ -206,7 +206,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
case XOAUTH:
case XOAUTH2:
{
- int result = sendData(username);
+ final int result = sendData(username);
if (result == IMAPReply.OK)
{
setState(IMAP.IMAPState.AUTH_STATE);
@@ -224,10 +224,10 @@ public class AuthenticatingIMAPClient extends IMAPSClient
* @param a The byte array to convert.
* @return The resulting String of hex codes.
*/
- private String _convertToHexString(byte[] a)
+ private String _convertToHexString(final byte[] a)
{
- StringBuilder result = new StringBuilder(a.length*2);
- for (byte element : a)
+ final StringBuilder result = new StringBuilder(a.length*2);
+ for (final byte element : a)
{
if ( (element & 0x0FF) <= 15 ) {
result.append("0");
@@ -255,7 +255,7 @@ public class AuthenticatingIMAPClient extends IMAPSClient
private final String authName;
- private AUTH_METHOD(String name){
+ private AUTH_METHOD(final String name){
this.authName=name;
}
/**
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 9ac0290..3650a95 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAP.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAP.java
@@ -102,7 +102,7 @@ public class IMAP extends SocketClient
*/
public static final IMAPChunkListener TRUE_CHUNK_LISTENER = new IMAPChunkListener(){
@Override
- public boolean chunkReceived(IMAP imap) {
+ public boolean chunkReceived(final IMAP imap) {
return true;
}
@@ -142,7 +142,7 @@ public class IMAP extends SocketClient
* @param wantTag {@code true} if the command expects a tagged response.
* @throws IOException
*/
- private void __getReply(boolean wantTag) throws IOException
+ private void __getReply(final boolean wantTag) throws IOException
{
_replyLines.clear();
String line = _reader.readLine();
@@ -166,9 +166,9 @@ public class IMAP extends SocketClient
literalCount -= (line.length() + 2); // Allow for CRLF
}
if (isMultiLine) {
- IMAPChunkListener il = __chunkListener;
+ final IMAPChunkListener il = __chunkListener;
if (il != null) {
- boolean clear = il.chunkReceived(this);
+ final boolean clear = il.chunkReceived(this);
if (clear) {
fireReplyReceived(IMAPReply.PARTIAL, getReplyString());
_replyLines.clear();
@@ -200,7 +200,7 @@ public class IMAP extends SocketClient
* @since 3.4
*/
@Override
- protected void fireReplyReceived(int replyCode, String ignored) {
+ protected void fireReplyReceived(final int replyCode, final String ignored) {
if (getCommandSupport().getListenerCount() > 0) {
getCommandSupport().fireReplyReceived(replyCode, getReplyString());
}
@@ -220,7 +220,7 @@ public class IMAP extends SocketClient
__writer =
new BufferedWriter(new OutputStreamWriter(_output_,
__DEFAULT_ENCODING));
- int tmo = getSoTimeout();
+ final int tmo = getSoTimeout();
if (tmo <= 0) { // none set currently
setSoTimeout(connectTimeout); // use connect timeout to ensure we don't block forever
}
@@ -237,7 +237,7 @@ public class IMAP extends SocketClient
*
* @param state The new state.
*/
- protected void setState(IMAP.IMAPState state)
+ protected void setState(final IMAP.IMAPState state)
{
__state = state;
}
@@ -280,9 +280,9 @@ public class IMAP extends SocketClient
* @param args The command arguments.
* @return The server reply code (either IMAPReply.OK, IMAPReply.NO or IMAPReply.BAD).
*/
- private int sendCommandWithID(String commandID, String command, String args) throws IOException
+ private int sendCommandWithID(final String commandID, final String command, final String args) throws IOException
{
- StringBuilder __commandBuffer = new StringBuilder();
+ final StringBuilder __commandBuffer = new StringBuilder();
if (commandID != null)
{
__commandBuffer.append(commandID);
@@ -297,7 +297,7 @@ public class IMAP extends SocketClient
}
__commandBuffer.append(SocketClient.NETASCII_EOL);
- String message = __commandBuffer.toString();
+ final String message = __commandBuffer.toString();
__writer.write(message);
__writer.flush();
@@ -315,7 +315,7 @@ public class IMAP extends SocketClient
* @return The server reply code (see IMAPReply).
* @throws IOException on error
*/
- public int sendCommand(String command, String args) throws IOException
+ public int sendCommand(final String command, final String args) throws IOException
{
return sendCommandWithID(generateCommandID(), command, args);
}
@@ -328,7 +328,7 @@ public class IMAP extends SocketClient
* @return The server reply code (see IMAPReply).
* @throws IOException on error
*/
- public int sendCommand(String command) throws IOException
+ public int sendCommand(final String command) throws IOException
{
return sendCommand(command, null);
}
@@ -342,7 +342,7 @@ public class IMAP extends SocketClient
* @return The server reply code (see IMAPReply).
* @throws IOException on error
*/
- public int sendCommand(IMAPCommand command, String args) throws IOException
+ public int sendCommand(final IMAPCommand command, final String args) throws IOException
{
return sendCommand(command.getIMAPCommand(), args);
}
@@ -356,7 +356,7 @@ public class IMAP extends SocketClient
* @return {@code true} if the command was successful
* @throws IOException on error
*/
- public boolean doCommand(IMAPCommand command, String args) throws IOException
+ public boolean doCommand(final IMAPCommand command, final String args) throws IOException
{
return IMAPReply.isSuccess(sendCommand(command, args));
}
@@ -370,7 +370,7 @@ public class IMAP extends SocketClient
* @return The server reply code (see IMAPReply).
* @throws IOException on error
**/
- public int sendCommand(IMAPCommand command) throws IOException
+ public int sendCommand(final IMAPCommand command) throws IOException
{
return sendCommand(command, null);
}
@@ -383,7 +383,7 @@ public class IMAP extends SocketClient
* @return {@code true} if the command was successful
* @throws IOException on error
*/
- public boolean doCommand(IMAPCommand command) throws IOException
+ public boolean doCommand(final IMAPCommand command) throws IOException
{
return IMAPReply.isSuccess(sendCommand(command));
}
@@ -395,7 +395,7 @@ public class IMAP extends SocketClient
* @return The server reply code (see IMAPReply).
* @throws IOException on error
*/
- public int sendData(String command) throws IOException
+ public int sendData(final String command) throws IOException
{
return sendCommandWithID(null, command, null);
}
@@ -419,8 +419,8 @@ public class IMAP extends SocketClient
*/
public String getReplyString()
{
- StringBuilder buffer = new StringBuilder(256);
- for (String s : _replyLines)
+ final StringBuilder buffer = new StringBuilder(256);
+ for (final String s : _replyLines)
{
buffer.append(s);
buffer.append(SocketClient.NETASCII_EOL);
@@ -440,7 +440,7 @@ public class IMAP extends SocketClient
* @see #TRUE_CHUNK_LISTENER
* @since 3.4
*/
- public void setChunkListener(IMAPChunkListener listener) {
+ public void setChunkListener(final IMAPChunkListener listener) {
__chunkListener = listener;
}
@@ -450,7 +450,7 @@ public class IMAP extends SocketClient
*/
protected String generateCommandID()
{
- String res = new String (_initialID);
+ final String res = new String (_initialID);
// "increase" the ID for the next call
boolean carry = true; // want to increment initially
for (int i = _initialID.length-1; carry && i>=0; i--)
@@ -480,7 +480,7 @@ public class IMAP extends SocketClient
* @param input the value to be quoted, may be null
* @return the quoted value
*/
- static String quoteMailboxName(String input) {
+ static String quoteMailboxName(final String input) {
if (input == null) { // Don't throw NPE here
return null;
}
diff --git a/src/main/java/org/apache/commons/net/imap/IMAPClient.java b/src/main/java/org/apache/commons/net/imap/IMAPClient.java
index 51e306f..4494bc8 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAPClient.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAPClient.java
@@ -85,7 +85,7 @@ public class IMAPClient extends IMAP
* @throws IOException If a network I/O error occurs in the process of
* logging in.
*/
- public boolean login(String username, String password) throws IOException
+ public boolean login(final String username, final String password) throws IOException
{
if (getState() != IMAP.IMAPState.NOT_AUTH_STATE)
{
@@ -110,7 +110,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean select(String mailboxName) throws IOException
+ public boolean select(final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.SELECT, quoteMailboxName(mailboxName));
}
@@ -121,7 +121,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean examine(String mailboxName) throws IOException
+ public boolean examine(final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.EXAMINE, quoteMailboxName(mailboxName));
}
@@ -132,7 +132,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean create(String mailboxName) throws IOException
+ public boolean create(final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.CREATE, quoteMailboxName(mailboxName));
}
@@ -143,7 +143,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean delete(String mailboxName) throws IOException
+ public boolean delete(final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.DELETE, quoteMailboxName(mailboxName));
}
@@ -155,7 +155,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean rename(String oldMailboxName, String newMailboxName) throws IOException
+ public boolean rename(final String oldMailboxName, final String newMailboxName) throws IOException
{
return doCommand (IMAPCommand.RENAME, quoteMailboxName(oldMailboxName) + " " + quoteMailboxName(newMailboxName));
}
@@ -166,7 +166,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean subscribe(String mailboxName) throws IOException
+ public boolean subscribe(final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.SUBSCRIBE, quoteMailboxName(mailboxName));
}
@@ -177,7 +177,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean unsubscribe(String mailboxName) throws IOException
+ public boolean unsubscribe(final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.UNSUBSCRIBE, quoteMailboxName(mailboxName));
}
@@ -194,7 +194,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean list(String refName, String mailboxName) throws IOException
+ public boolean list(final String refName, final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.LIST, quoteMailboxName(refName) + " " + quoteMailboxName(mailboxName));
}
@@ -207,7 +207,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean lsub(String refName, String mailboxName) throws IOException
+ public boolean lsub(final String refName, final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.LSUB, quoteMailboxName(refName) + " " + quoteMailboxName(mailboxName));
}
@@ -219,13 +219,13 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean status(String mailboxName, String[] itemNames) throws IOException
+ public boolean status(final String mailboxName, final String[] itemNames) throws IOException
{
if (itemNames == null || itemNames.length < 1) {
throw new IllegalArgumentException("STATUS command requires at least one data item name");
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append(quoteMailboxName(mailboxName));
sb.append(" (");
@@ -251,9 +251,9 @@ public class IMAPClient extends IMAP
* @throws IOException If a network I/O error occurs.
* @since 3.4
*/
- public boolean append(String mailboxName, String flags, String datetime, String message) throws IOException
+ public boolean append(final String mailboxName, final String flags, final String datetime, final String message) throws IOException
{
- StringBuilder args = new StringBuilder(quoteMailboxName(mailboxName));
+ final StringBuilder args = new StringBuilder(quoteMailboxName(mailboxName));
if (flags != null) {
args.append(" ").append(flags);
}
@@ -288,7 +288,7 @@ public class IMAPClient extends IMAP
* Use {@link #append(String, String, String, String)} instead.
*/
@Deprecated
- public boolean append(String mailboxName, String flags, String datetime) throws IOException
+ public boolean append(final String mailboxName, final String flags, final String datetime) throws IOException
{
String args = mailboxName;
if (flags != null) {
@@ -313,7 +313,7 @@ public class IMAPClient extends IMAP
* Use {@link #append(String, String, String, String)} instead.
*/
@Deprecated
- public boolean append(String mailboxName) throws IOException
+ public boolean append(final String mailboxName) throws IOException
{
return append(mailboxName, null, null);
}
@@ -357,7 +357,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean search(String charset, String criteria) throws IOException
+ public boolean search(final String charset, final String criteria) throws IOException
{
String args = "";
if (charset != null) {
@@ -373,7 +373,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean search(String criteria) throws IOException
+ public boolean search(final String criteria) throws IOException
{
return search(null, criteria);
}
@@ -389,7 +389,7 @@ public class IMAPClient extends IMAP
* @see #getReplyString()
* @see #getReplyStrings()
*/
- public boolean fetch(String sequenceSet, String itemNames) throws IOException
+ public boolean fetch(final String sequenceSet, final String itemNames) throws IOException
{
return doCommand (IMAPCommand.FETCH, sequenceSet + " " + itemNames);
}
@@ -402,7 +402,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean store(String sequenceSet, String itemNames, String itemValues)
+ public boolean store(final String sequenceSet, final String itemNames, final String itemValues)
throws IOException
{
return doCommand (IMAPCommand.STORE, sequenceSet + " " + itemNames + " " + itemValues);
@@ -415,7 +415,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean copy(String sequenceSet, String mailboxName) throws IOException
+ public boolean copy(final String sequenceSet, final String mailboxName) throws IOException
{
return doCommand (IMAPCommand.COPY, sequenceSet + " " + quoteMailboxName(mailboxName));
}
@@ -427,7 +427,7 @@ public class IMAPClient extends IMAP
* @return {@code true} if the command was successful,{@code false} if not.
* @throws IOException If a network I/O error occurs.
*/
- public boolean uid(String command, String commandArgs) throws IOException
+ public boolean uid(final String command, final String commandArgs) throws IOException
{
return doCommand (IMAPCommand.UID, command + " " + commandArgs);
}
diff --git a/src/main/java/org/apache/commons/net/imap/IMAPCommand.java b/src/main/java/org/apache/commons/net/imap/IMAPCommand.java
index 764800e..545ae92 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAPCommand.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAPCommand.java
@@ -73,23 +73,23 @@ public enum IMAPCommand
this(null);
}
- IMAPCommand(String name){
+ IMAPCommand(final String name){
this(name, 0);
}
- IMAPCommand(int paramCount){
+ IMAPCommand(final int paramCount){
this(null, paramCount, paramCount);
}
- IMAPCommand(int minCount, int maxCount){
+ IMAPCommand(final int minCount, final int maxCount){
this(null, minCount, maxCount);
}
- IMAPCommand(String name, int paramCount){
+ IMAPCommand(final String name, final int paramCount){
this(name, paramCount, paramCount);
}
- IMAPCommand(String name, int minCount, int maxCount){
+ IMAPCommand(final String name, final int minCount, final int maxCount){
this.imapCommand = name;
this.minParamCount = minCount;
this.maxParamCount = maxCount;
@@ -101,7 +101,7 @@ public enum IMAPCommand
* @param command the IMAPCommand whose command string is required.
* @return The IMAP protocol string command corresponding to a command code.
*/
- public static final String getCommand(IMAPCommand command) {
+ public static final String getCommand(final IMAPCommand command) {
return command.getIMAPCommand();
}
diff --git a/src/main/java/org/apache/commons/net/imap/IMAPReply.java b/src/main/java/org/apache/commons/net/imap/IMAPReply.java
index d7a739d..753dd81 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAPReply.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAPReply.java
@@ -73,7 +73,7 @@ public final class IMAPReply
* @param line to be checked
* @return {@code true} if the line is untagged
*/
- public static boolean isUntagged(String line) {
+ public static boolean isUntagged(final String line) {
return line.startsWith(IMAP_UNTAGGED_PREFIX);
}
@@ -82,7 +82,7 @@ public final class IMAPReply
* @param line the line to be checked
* @return {@code true} if the line is untagged
*/
- public static boolean isContinuation(String line) {
+ public static boolean isContinuation(final String line) {
return line.startsWith(IMAP_CONTINUATION_PREFIX);
}
@@ -97,7 +97,7 @@ public final class IMAPReply
* @return {@link #OK} or {@link #NO} or {@link #BAD} or {@link #CONT}
* @throws IOException if the input has an unexpected format
*/
- public static int getReplyCode(String line) throws IOException {
+ public static int getReplyCode(final String line) throws IOException {
return getReplyCode(line, TAGGED_PATTERN);
}
@@ -112,8 +112,8 @@ public final class IMAPReply
*
* @return the literal count, or -1 if there was no literal.
*/
- public static int literalCount(String line) {
- Matcher m = LITERAL_PATTERN.matcher(line);
+ public static int literalCount(final String line) {
+ final Matcher m = LITERAL_PATTERN.matcher(line);
if (m.find()) {
return Integer.parseInt(m.group(1)); // Should always parse because we matched \d+
}
@@ -127,18 +127,18 @@ public final class IMAPReply
* @return {@link #OK} or {@link #NO} or {@link #BAD} or {@link #CONT}
* @throws IOException if the input has an unexpected format
*/
- public static int getUntaggedReplyCode(String line) throws IOException {
+ public static int getUntaggedReplyCode(final String line) throws IOException {
return getReplyCode(line, UNTAGGED_PATTERN);
}
// Helper method to process both tagged and untagged replies.
- private static int getReplyCode(String line, Pattern pattern) throws IOException{
+ private static int getReplyCode(final String line, final Pattern pattern) throws IOException{
if (isContinuation(line)) {
return CONT;
}
- Matcher m = pattern.matcher(line);
+ final Matcher m = pattern.matcher(line);
if (m.matches()) { // TODO would lookingAt() be more efficient? If so, then drop trailing .* from patterns
- String code = m.group(1);
+ final String code = m.group(1);
if (code.equals(IMAP_OK)) {
return OK;
}
@@ -159,7 +159,7 @@ public final class IMAPReply
* @param replyCode the code to check
* @return {@code true} if the code equals {@link #OK}
*/
- public static boolean isSuccess(int replyCode) {
+ public static boolean isSuccess(final int replyCode) {
return replyCode == OK;
}
/**
@@ -167,7 +167,7 @@ public final class IMAPReply
* @param replyCode the code to be checked
* @return {@code true} if the response was a continuation
*/
- public static boolean isContinuation(int replyCode) {
+ public static boolean isContinuation(final int replyCode) {
return replyCode == CONT;
}
diff --git a/src/main/java/org/apache/commons/net/imap/IMAPSClient.java b/src/main/java/org/apache/commons/net/imap/IMAPSClient.java
index dde3b35..70de0ac 100644
--- a/src/main/java/org/apache/commons/net/imap/IMAPSClient.java
+++ b/src/main/java/org/apache/commons/net/imap/IMAPSClient.java
@@ -99,7 +99,7 @@ public class IMAPSClient extends IMAPClient
* Constructor for IMAPSClient.
* @param implicit The security mode (Implicit/Explicit).
*/
- public IMAPSClient(boolean implicit)
+ public IMAPSClient(final boolean implicit)
{
this(DEFAULT_PROTOCOL, implicit);
}
@@ -108,7 +108,7 @@ public class IMAPSClient extends IMAPClient
* Constructor for IMAPSClient.
* @param proto the protocol.
*/
- public IMAPSClient(String proto)
+ public IMAPSClient(final String proto)
{
this(proto, false);
}
@@ -118,7 +118,7 @@ public class IMAPSClient extends IMAPClient
* @param proto the protocol.
* @param implicit The security mode(Implicit/Explicit).
*/
- public IMAPSClient(String proto, boolean implicit)
+ public IMAPSClient(final String proto, final boolean implicit)
{
this(proto, implicit, null);
}
@@ -129,7 +129,7 @@ public class IMAPSClient extends IMAPClient
* @param implicit The security mode(Implicit/Explicit).
* @param ctx the SSL context
*/
- public IMAPSClient(String proto, boolean implicit, SSLContext ctx)
+ public IMAPSClient(final String proto, final boolean implicit, final SSLContext ctx)
{
super();
setDefaultPort(DEFAULT_IMAPS_PORT);
@@ -143,7 +143,7 @@ public class IMAPSClient extends IMAPClient
* @param implicit The security mode(Implicit/Explicit).
* @param ctx A pre-configured SSL Context.
*/
- public IMAPSClient(boolean implicit, SSLContext ctx)
+ public IMAPSClient(final boolean implicit, final SSLContext ctx)
{
this(DEFAULT_PROTOCOL, implicit, ctx);
}
@@ -152,7 +152,7 @@ public class IMAPSClient extends IMAPClient
* Constructor for IMAPSClient.
* @param context A pre-configured SSL Context.
*/
- public IMAPSClient(SSLContext context)
+ public IMAPSClient(final SSLContext context)
{
this(false, context);
}
@@ -197,10 +197,10 @@ public class IMAPSClient extends IMAPClient
{
initSSLContext();
- SSLSocketFactory ssf = context.getSocketFactory();
- String host = (_hostname_ != null) ? _hostname_ : getRemoteAddress().getHostAddress();
- int port = getRemotePort();
- SSLSocket socket =
+ final SSLSocketFactory ssf = context.getSocketFactory();
+ final String host = (_hostname_ != null) ? _hostname_ : getRemoteAddress().getHostAddress();
+ final int port = getRemotePort();
+ final SSLSocket socket =
(SSLSocket) ssf.createSocket(_socket_, host, port, true);
socket.setEnableSessionCreation(true);
socket.setUseClientMode(true);
@@ -247,7 +247,7 @@ public class IMAPSClient extends IMAPClient
* @param newKeyManager The KeyManager implementation to set.
* @see org.apache.commons.net.util.KeyManagerUtils
*/
- public void setKeyManager(KeyManager newKeyManager)
+ public void setKeyManager(final KeyManager newKeyManager)
{
keyManager = newKeyManager;
}
@@ -257,7 +257,7 @@ public class IMAPSClient extends IMAPClient
* connection. Called before server negotiation.
* @param cipherSuites The cipher suites.
*/
- public void setEnabledCipherSuites(String[] cipherSuites)
+ public void setEnabledCipherSuites(final String[] cipherSuites)
{
suites = new String[cipherSuites.length];
System.arraycopy(cipherSuites, 0, suites, 0, cipherSuites.length);
@@ -283,7 +283,7 @@ public class IMAPSClient extends IMAPClient
* connection. I perform setting before a server negotiation.
* @param protocolVersions The protocol versions.
*/
- public void setEnabledProtocols(String[] protocolVersions)
+ public void setEnabledProtocols(final String[] protocolVersions)
{
protocols = new String[protocolVersions.length];
System.arraycopy(protocolVersions, 0, protocols, 0, protocolVersions.length);
@@ -336,7 +336,7 @@ public class IMAPSClient extends IMAPClient
* @param newTrustManager The TrustManager implementation to set.
* @see org.apache.commons.net.util.TrustManagerUtils
*/
- public void setTrustManager(TrustManager newTrustManager)
+ public void setTrustManager(final TrustManager newTrustManager)
{
trustManager = newTrustManager;
}
@@ -356,7 +356,7 @@ public class IMAPSClient extends IMAPClient
* @param newHostnameVerifier The HostnameVerifier implementation to set or <code>null</code> to disable.
* @since 3.4
*/
- public void setHostnameVerifier(HostnameVerifier newHostnameVerifier)
+ public void setHostnameVerifier(final HostnameVerifier newHostnameVerifier)
{
hostnameVerifier = newHostnameVerifier;
}
@@ -380,7 +380,7 @@ public class IMAPSClient extends IMAPClient
* @param enable Enable automatic endpoint identification checking using the HTTPS algorithm on Java 1.7+.
* @since 3.4
*/
- public void setEndpointCheckingEnabled(boolean enable)
+ public void setEndpointCheckingEnabled(final boolean enable)
{
tlsEndpointChecking = enable;
}
diff --git a/src/main/java/org/apache/commons/net/io/CRLFLineReader.java b/src/main/java/org/apache/commons/net/io/CRLFLineReader.java
index 9ba51a9..89c1a60 100644
--- a/src/main/java/org/apache/commons/net/io/CRLFLineReader.java
+++ b/src/main/java/org/apache/commons/net/io/CRLFLineReader.java
@@ -38,7 +38,7 @@ public final class CRLFLineReader extends BufferedReader
* input source.
* @param reader The Reader input source.
*/
- public CRLFLineReader(Reader reader)
+ public CRLFLineReader(final Reader reader)
{
super(reader);
}
@@ -51,7 +51,7 @@ public final class CRLFLineReader extends BufferedReader
*/
@Override
public String readLine() throws IOException {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
int intch;
boolean prevWasCR = false;
synchronized(lock) { // make thread-safe (hopefully!)
@@ -68,7 +68,7 @@ public final class CRLFLineReader extends BufferedReader
sb.append((char) intch);
}
}
- String string = sb.toString();
+ final String string = sb.toString();
if (string.length() == 0) { // immediate EOF
return null;
}
diff --git a/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java b/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java
index ccf5c21..745f532 100644
--- a/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java
+++ b/src/main/java/org/apache/commons/net/io/CopyStreamAdapter.java
@@ -60,9 +60,9 @@ public class CopyStreamAdapter implements CopyStreamListener
* bytes.
*/
@Override
- public void bytesTransferred(CopyStreamEvent event)
+ public void bytesTransferred(final CopyStreamEvent event)
{
- for (EventListener listener : internalListeners)
+ for (final EventListener listener : internalListeners)
{
((CopyStreamListener) (listener)).bytesTransferred(event);
}
@@ -84,10 +84,10 @@ public class CopyStreamAdapter implements CopyStreamListener
* the size is unknown.
*/
@Override
- public void bytesTransferred(long totalBytesTransferred,
- int bytesTransferred, long streamSize)
+ public void bytesTransferred(final long totalBytesTransferred,
+ final int bytesTransferred, final long streamSize)
{
- for (EventListener listener : internalListeners)
+ for (final EventListener listener : internalListeners)
{
((CopyStreamListener) (listener)).bytesTransferred(
totalBytesTransferred, bytesTransferred, streamSize);
@@ -100,7 +100,7 @@ public class CopyStreamAdapter implements CopyStreamListener
* implemented in a thread safe manner.
* @param listener The CopyStreamlistener to register.
*/
- public void addCopyStreamListener(CopyStreamListener listener)
+ public void addCopyStreamListener(final CopyStreamListener listener)
{
internalListeners.addListener(listener);
}
@@ -110,7 +110,7 @@ public class CopyStreamAdapter implements CopyStreamListener
* synchronized, it is implemented in a thread safe manner.
* @param listener The CopyStreamlistener to unregister.
*/
- public void removeCopyStreamListener(CopyStreamListener listener)
+ public void removeCopyStreamListener(final CopyStreamListener listener)
{
internalListeners.removeListener(listener);
}
diff --git a/src/main/java/org/apache/commons/net/io/CopyStreamEvent.java b/src/main/java/org/apache/commons/net/io/CopyStreamEvent.java
index 586e10a..6e5b461 100644
--- a/src/main/java/org/apache/commons/net/io/CopyStreamEvent.java
+++ b/src/main/java/org/apache/commons/net/io/CopyStreamEvent.java
@@ -54,8 +54,8 @@ public class CopyStreamEvent extends EventObject
* This may be set to <code>UNKNOWN_STREAM_SIZE</code> if the
* size is unknown.
*/
- public CopyStreamEvent(Object source, long totalBytesTransferred,
- int bytesTransferred, long streamSize)
+ public CopyStreamEvent(final Object source, final long totalBytesTransferred,
+ final int bytesTransferred, final long streamSize)
{
super(source);
this.bytesTransferred = bytesTransferred;
diff --git a/src/main/java/org/apache/commons/net/io/CopyStreamException.java b/src/main/java/org/apache/commons/net/io/CopyStreamException.java
index d9ed210..6122d57 100644
--- a/src/main/java/org/apache/commons/net/io/CopyStreamException.java
+++ b/src/main/java/org/apache/commons/net/io/CopyStreamException.java
@@ -39,9 +39,9 @@ public class CopyStreamException extends IOException
* an exception was thrown in a copy operation.
* @param exception The IOException thrown during a copy operation.
*/
- public CopyStreamException(String message,
- long bytesTransferred,
- IOException exception)
+ public CopyStreamException(final String message,
+ final long bytesTransferred,
+ final IOException exception)
{
super(message);
initCause(exception); // merge this into super() call once we need 1.6+
diff --git a/src/main/java/org/apache/commons/net/io/DotTerminatedMessageReader.java b/src/main/java/org/apache/commons/net/io/DotTerminatedMessageReader.java
index 5db985a..a02ab26 100644
--- a/src/main/java/org/apache/commons/net/io/DotTerminatedMessageReader.java
+++ b/src/main/java/org/apache/commons/net/io/DotTerminatedMessageReader.java
@@ -51,7 +51,7 @@ public final class DotTerminatedMessageReader extends BufferedReader
* input source.
* @param reader The Reader input source containing the message.
*/
- public DotTerminatedMessageReader(Reader reader)
+ public DotTerminatedMessageReader(final Reader reader)
{
super(reader);
// Assumes input is at start of message
@@ -143,7 +143,7 @@ public final class DotTerminatedMessageReader extends BufferedReader
* stream.
*/
@Override
- public int read(char[] buffer) throws IOException
+ public int read(final char[] buffer) throws IOException
{
return read(buffer, 0, buffer.length);
}
@@ -163,7 +163,7 @@ public final class DotTerminatedMessageReader extends BufferedReader
* stream.
*/
@Override
- public int read(char[] buffer, int offset, int length) throws IOException
+ public int read(final char[] buffer, int offset, int length) throws IOException
{
if (length < 1)
{
@@ -177,7 +177,7 @@ public final class DotTerminatedMessageReader extends BufferedReader
return -1;
}
- int off = offset;
+ final int off = offset;
do
{
@@ -228,7 +228,7 @@ public final class DotTerminatedMessageReader extends BufferedReader
*/
@Override
public String readLine() throws IOException {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
int intch;
synchronized(lock) { // make thread-safe (hopefully!)
while((intch = read()) != -1)
@@ -239,7 +239,7 @@ public final class DotTerminatedMessageReader extends BufferedReader
sb.append((char) intch);
}
}
- String string = sb.toString();
+ final String string = sb.toString();
if (string.length() == 0) { // immediate EOF
return null;
}
diff --git a/src/main/java/org/apache/commons/net/io/DotTerminatedMessageWriter.java b/src/main/java/org/apache/commons/net/io/DotTerminatedMessageWriter.java
index cb98cb8..c709073 100644
--- a/src/main/java/org/apache/commons/net/io/DotTerminatedMessageWriter.java
+++ b/src/main/java/org/apache/commons/net/io/DotTerminatedMessageWriter.java
@@ -52,7 +52,7 @@ public final class DotTerminatedMessageWriter extends Writer
*
* @param output The Writer output destination to write the message.
***/
- public DotTerminatedMessageWriter(Writer output)
+ public DotTerminatedMessageWriter(final Writer output)
{
super(output);
__output = output;
@@ -72,7 +72,7 @@ public final class DotTerminatedMessageWriter extends Writer
* underlying output.
***/
@Override
- public void write(int ch) throws IOException
+ public void write(final int ch) throws IOException
{
synchronized (lock)
{
@@ -115,7 +115,7 @@ public final class DotTerminatedMessageWriter extends Writer
* output.
***/
@Override
- public void write(char[] buffer, int offset, int length) throws IOException
+ public void write(final char[] buffer, int offset, int length) throws IOException
{
synchronized (lock)
{
@@ -134,7 +134,7 @@ public final class DotTerminatedMessageWriter extends Writer
* output.
***/
@Override
- public void write(char[] buffer) throws IOException
+ public void write(final char[] buffer) throws IOException
{
write(buffer, 0, buffer.length);
}
@@ -148,7 +148,7 @@ public final class DotTerminatedMessageWriter extends Writer
* output.
***/
@Override
- public void write(String string) throws IOException
+ public void write(final String string) throws IOException
{
write(string.toCharArray());
}
@@ -164,7 +164,7 @@ public final class DotTerminatedMessageWriter extends Writer
* output.
***/
@Override
- public void write(String string, int offset, int length) throws IOException
+ public void write(final String string, final int offset, final int length) throws IOException
{
write(string.toCharArray(), offset, length);
}
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 3d1b231..80df25f 100644
--- a/src/main/java/org/apache/commons/net/io/FromNetASCIIInputStream.java
+++ b/src/main/java/org/apache/commons/net/io/FromNetASCIIInputStream.java
@@ -43,7 +43,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
_noConversionRequired = _lineSeparator.equals("\r\n");
try {
_lineSeparatorBytes = _lineSeparator.getBytes("US-ASCII");
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
throw new RuntimeException("Broken JVM - cannot find US-ASCII charset!",e);
}
}
@@ -69,7 +69,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
* InputStream.
* @param input the stream to wrap
***/
- public FromNetASCIIInputStream(InputStream input)
+ public FromNetASCIIInputStream(final InputStream input)
{
super(input, _lineSeparatorBytes.length + 1);
}
@@ -140,7 +140,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
* stream.
***/
@Override
- public int read(byte buffer[]) throws IOException
+ public int read(final byte buffer[]) throws IOException
{
return read(buffer, 0, buffer.length);
}
@@ -161,7 +161,7 @@ public final class FromNetASCIIInputStream extends PushbackInputStream
* stream.
***/
@Override
- public int read(byte buffer[], int offset, int length) throws IOException
+ public int read(final byte buffer[], int offset, final int length) throws IOException
{
if (_noConversionRequired) {
return super.read(buffer, offset, length);
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 412addc..6721198 100644
--- a/src/main/java/org/apache/commons/net/io/FromNetASCIIOutputStream.java
+++ b/src/main/java/org/apache/commons/net/io/FromNetASCIIOutputStream.java
@@ -46,14 +46,14 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
*
* @param output The OutputStream to wrap.
***/
- public FromNetASCIIOutputStream(OutputStream output)
+ public FromNetASCIIOutputStream(final OutputStream output)
{
super(output);
__lastWasCR = false;
}
- private void __write(int ch) throws IOException
+ private void __write(final int ch) throws IOException
{
switch (ch)
{
@@ -96,7 +96,7 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public synchronized void write(int ch)
+ public synchronized void write(final int ch)
throws IOException
{
if (FromNetASCIIInputStream._noConversionRequired)
@@ -117,7 +117,7 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public synchronized void write(byte buffer[])
+ public synchronized void write(final byte buffer[])
throws IOException
{
write(buffer, 0, buffer.length);
@@ -135,7 +135,7 @@ public final class FromNetASCIIOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public synchronized void write(byte buffer[], int offset, int length)
+ public synchronized void write(final byte buffer[], int offset, int length)
throws IOException
{
if (FromNetASCIIInputStream._noConversionRequired)
diff --git a/src/main/java/org/apache/commons/net/io/SocketInputStream.java b/src/main/java/org/apache/commons/net/io/SocketInputStream.java
index b84a4a2..ace3e2a 100644
--- a/src/main/java/org/apache/commons/net/io/SocketInputStream.java
+++ b/src/main/java/org/apache/commons/net/io/SocketInputStream.java
@@ -46,7 +46,7 @@ public class SocketInputStream extends FilterInputStream
* @param socket The socket to close on closing the stream.
* @param stream The input stream to wrap.
***/
- public SocketInputStream(Socket socket, InputStream stream)
+ public SocketInputStream(final Socket socket, final InputStream stream)
{
super(stream);
__socket = socket;
diff --git a/src/main/java/org/apache/commons/net/io/SocketOutputStream.java b/src/main/java/org/apache/commons/net/io/SocketOutputStream.java
index 6af8f54..ed2da63 100644
--- a/src/main/java/org/apache/commons/net/io/SocketOutputStream.java
+++ b/src/main/java/org/apache/commons/net/io/SocketOutputStream.java
@@ -46,7 +46,7 @@ public class SocketOutputStream extends FilterOutputStream
* @param socket The socket to close on closing the stream.
* @param stream The input stream to wrap.
***/
- public SocketOutputStream(Socket socket, OutputStream stream)
+ public SocketOutputStream(final Socket socket, final OutputStream stream)
{
super(stream);
__socket = socket;
@@ -66,7 +66,7 @@ public class SocketOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public void write(byte buffer[], int offset, int length) throws IOException
+ public void write(final byte buffer[], final int offset, final int length) throws IOException
{
out.write(buffer, offset, length);
}
diff --git a/src/main/java/org/apache/commons/net/io/ToNetASCIIInputStream.java b/src/main/java/org/apache/commons/net/io/ToNetASCIIInputStream.java
index f0ec930..ca559c6 100644
--- a/src/main/java/org/apache/commons/net/io/ToNetASCIIInputStream.java
+++ b/src/main/java/org/apache/commons/net/io/ToNetASCIIInputStream.java
@@ -45,7 +45,7 @@ public final class ToNetASCIIInputStream extends FilterInputStream
*
* @param input The InputStream to wrap.
***/
- public ToNetASCIIInputStream(InputStream input)
+ public ToNetASCIIInputStream(final InputStream input)
{
super(input);
__status = __NOTHING_SPECIAL;
@@ -107,7 +107,7 @@ public final class ToNetASCIIInputStream extends FilterInputStream
* stream.
***/
@Override
- public int read(byte buffer[]) throws IOException
+ public int read(final byte buffer[]) throws IOException
{
return read(buffer, 0, buffer.length);
}
@@ -128,7 +128,7 @@ public final class ToNetASCIIInputStream extends FilterInputStream
* stream.
***/
@Override
- public int read(byte buffer[], int offset, int length) throws IOException
+ public int read(final byte buffer[], int offset, int length) throws IOException
{
int ch, off;
diff --git a/src/main/java/org/apache/commons/net/io/ToNetASCIIOutputStream.java b/src/main/java/org/apache/commons/net/io/ToNetASCIIOutputStream.java
index 989bfc3..f96ca97 100644
--- a/src/main/java/org/apache/commons/net/io/ToNetASCIIOutputStream.java
+++ b/src/main/java/org/apache/commons/net/io/ToNetASCIIOutputStream.java
@@ -42,7 +42,7 @@ public final class ToNetASCIIOutputStream extends FilterOutputStream
*
* @param output The OutputStream to wrap.
***/
- public ToNetASCIIOutputStream(OutputStream output)
+ public ToNetASCIIOutputStream(final OutputStream output)
{
super(output);
__lastWasCR = false;
@@ -61,7 +61,7 @@ public final class ToNetASCIIOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public synchronized void write(int ch)
+ public synchronized void write(final int ch)
throws IOException
{
switch (ch)
@@ -91,7 +91,7 @@ public final class ToNetASCIIOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public synchronized void write(byte buffer[])
+ public synchronized void write(final byte buffer[])
throws IOException
{
write(buffer, 0, buffer.length);
@@ -109,7 +109,7 @@ public final class ToNetASCIIOutputStream extends FilterOutputStream
* stream.
***/
@Override
- public synchronized void write(byte buffer[], int offset, int length)
+ public synchronized void write(final byte buffer[], int offset, int length)
throws IOException
{
while (length-- > 0) {
diff --git a/src/main/java/org/apache/commons/net/io/Util.java b/src/main/java/org/apache/commons/net/io/Util.java
index 1f4e5b5..2cd3661 100644
--- a/src/main/java/org/apache/commons/net/io/Util.java
+++ b/src/main/java/org/apache/commons/net/io/Util.java
@@ -87,15 +87,15 @@ public final class Util
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
- public static final long copyStream(InputStream source, OutputStream dest,
- int bufferSize, long streamSize,
- CopyStreamListener listener,
- boolean flush)
+ public static final long copyStream(final InputStream source, final OutputStream dest,
+ final int bufferSize, final long streamSize,
+ final CopyStreamListener listener,
+ final boolean flush)
throws CopyStreamException
{
int numBytes;
long total = 0;
- byte[] buffer = new byte[bufferSize > 0 ? bufferSize : DEFAULT_COPY_BUFFER_SIZE];
+ final byte[] buffer = new byte[bufferSize > 0 ? bufferSize : DEFAULT_COPY_BUFFER_SIZE];
try
{
@@ -106,7 +106,7 @@ public final class Util
if (numBytes == 0)
{
- int singleByte = source.read();
+ final int singleByte = source.read();
if (singleByte < 0) {
break;
}
@@ -131,7 +131,7 @@ public final class Util
}
}
}
- catch (IOException e)
+ catch (final IOException e)
{
throw new CopyStreamException("IOException caught while copying.",
total, e);
@@ -175,9 +175,9 @@ public final class Util
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
- public static final long copyStream(InputStream source, OutputStream dest,
- int bufferSize, long streamSize,
- CopyStreamListener listener)
+ public static final long copyStream(final InputStream source, final OutputStream dest,
+ final int bufferSize, final long streamSize,
+ final CopyStreamListener listener)
throws CopyStreamException
{
return copyStream(source, dest, bufferSize, streamSize, listener,
@@ -207,8 +207,8 @@ public final class Util
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
- public static final long copyStream(InputStream source, OutputStream dest,
- int bufferSize)
+ public static final long copyStream(final InputStream source, final OutputStream dest,
+ final int bufferSize)
throws CopyStreamException
{
return copyStream(source, dest, bufferSize,
@@ -223,7 +223,7 @@ public final class Util
* @return number of bytes copied
* @throws CopyStreamException on error
***/
- public static final long copyStream(InputStream source, OutputStream dest)
+ public static final long copyStream(final InputStream source, final OutputStream dest)
throws CopyStreamException
{
return copyStream(source, dest, DEFAULT_COPY_BUFFER_SIZE);
@@ -263,14 +263,14 @@ public final class Util
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
- public static final long copyReader(Reader source, Writer dest,
- int bufferSize, long streamSize,
- CopyStreamListener listener)
+ public static final long copyReader(final Reader source, final Writer dest,
+ final int bufferSize, final long streamSize,
+ final CopyStreamListener listener)
throws CopyStreamException
{
int numChars;
long total = 0;
- char[] buffer = new char[bufferSize > 0 ? bufferSize : DEFAULT_COPY_BUFFER_SIZE];
+ final char[] buffer = new char[bufferSize > 0 ? bufferSize : DEFAULT_COPY_BUFFER_SIZE];
try
{
@@ -280,7 +280,7 @@ public final class Util
// accept that as an indication of EOF.
if (numChars == 0)
{
- int singleChar = source.read();
+ final int singleChar = source.read();
if (singleChar < 0) {
break;
}
@@ -301,7 +301,7 @@ public final class Util
}
}
}
- catch (IOException e)
+ catch (final IOException e)
{
throw new CopyStreamException("IOException caught while copying.",
total, e);
@@ -332,8 +332,8 @@ public final class Util
* the CopyStreamException getTotalBytesTransferred() and
* getIOException() methods.
***/
- public static final long copyReader(Reader source, Writer dest,
- int bufferSize)
+ public static final long copyReader(final Reader source, final Writer dest,
+ final int bufferSize)
throws CopyStreamException
{
return copyReader(source, dest, bufferSize,
@@ -348,7 +348,7 @@ public final class Util
* @return number of bytes copied
* @throws CopyStreamException on error
***/
- public static final long copyReader(Reader source, Writer dest)
+ public static final long copyReader(final Reader source, final Writer dest)
throws CopyStreamException
{
return copyReader(source, dest, DEFAULT_COPY_BUFFER_SIZE);
@@ -361,11 +361,11 @@ public final class Util
* @param closeable the object to close, may be {@code null}
* @since 3.0
*/
- public static void closeQuietly(Closeable closeable) {
+ public static void closeQuietly(final Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Ignored
}
}
@@ -378,11 +378,11 @@ public final class Util
* @param socket the socket to close, may be {@code null}
* @since 3.0
*/
- public static void closeQuietly(Socket socket) {
+ public static void closeQuietly(final Socket socket) {
if (socket != null) {
try {
socket.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// Ignored
}
}
diff --git a/src/main/java/org/apache/commons/net/nntp/Article.java b/src/main/java/org/apache/commons/net/nntp/Article.java
index a2ad1b9..1e8a058 100644
--- a/src/main/java/org/apache/commons/net/nntp/Article.java
+++ b/src/main/java/org/apache/commons/net/nntp/Article.java
@@ -44,7 +44,7 @@ public class Article implements Threadable {
* Adds a message-id to the list of messages that this message references (i.e. replies to)
* @param msgId the message id to add
*/
- public void addReference(String msgId) {
+ public void addReference(final String msgId) {
if (msgId == null || msgId.length() == 0) {
return;
}
@@ -52,7 +52,7 @@ public class Article implements Threadable {
references = new ArrayList<>();
}
isReply = true;
- for(String s : msgId.split(" ")) {
+ for(final String s : msgId.split(" ")) {
references.add(s);
}
}
@@ -74,8 +74,8 @@ public class Article implements Threadable {
*/
private void simplifySubject() {
int start = 0;
- String subject = getSubject();
- int len = subject.length();
+ final String subject = getSubject();
+ final int len = subject.length();
boolean done = false;
@@ -140,7 +140,7 @@ public class Article implements Threadable {
* @param article the root of the article 'tree'
* @since 3.4
*/
- public static void printThread(Article article) {
+ public static void printThread(final Article article) {
printThread(article, 0, System.out);
}
@@ -151,7 +151,7 @@ public class Article implements Threadable {
* @param ps the PrintStream to use
* @since 3.4
*/
- public static void printThread(Article article, PrintStream ps) {
+ public static void printThread(final Article article, final PrintStream ps) {
printThread(article, 0, ps);
}
@@ -161,7 +161,7 @@ public class Article implements Threadable {
* @param article the root of the article 'tree'
* @param depth the current tree depth
*/
- public static void printThread(Article article, int depth) {
+ public static void printThread(final Article article, final int depth) {
printThread(article, depth, System.out);
}
@@ -173,7 +173,7 @@ public class Article implements Threadable {
* @param ps the PrintStream to use
* @since 3.4
*/
- public static void printThread(Article article, int depth, PrintStream ps) {
+ public static void printThread(final Article article, final int depth, final PrintStream ps) {
for (int i = 0; i < depth; ++i) {
ps.print("==>");
}
@@ -206,23 +206,23 @@ public class Article implements Threadable {
return subject;
}
- public void setArticleId(String string) {
+ public void setArticleId(final String string) {
articleId = string;
}
- public void setArticleNumber(long l) {
+ public void setArticleNumber(final long l) {
articleNumber = l;
}
- public void setDate(String string) {
+ public void setDate(final String string) {
date = string;
}
- public void setFrom(String string) {
+ public void setFrom(final String string) {
from = string;
}
- public void setSubject(String string) {
+ public void setSubject(final String string) {
subject = string;
}
@@ -258,7 +258,7 @@ public class Article implements Threadable {
@Override
- public void setChild(Threadable child) {
+ public void setChild(final Threadable child) {
this.kid = (Article) child;
flushSubjectCache();
}
@@ -269,7 +269,7 @@ public class Article implements Threadable {
@Override
- public void setNext(Threadable next) {
+ public void setNext(final Threadable next) {
this.next = (Article)next;
flushSubjectCache();
}
@@ -293,12 +293,12 @@ public class Article implements Threadable {
}
@Deprecated
- public void setArticleNumber(int a) {
+ public void setArticleNumber(final int a) {
articleNumber = a;
}
@Deprecated
- public void addHeaderField(String name, String val) {
+ public void addHeaderField(final String name, final String val) {
}
}
diff --git a/src/main/java/org/apache/commons/net/nntp/ArticleIterator.java b/src/main/java/org/apache/commons/net/nntp/ArticleIterator.java
index ef82ba6..272a870 100644
--- a/src/main/java/org/apache/commons/net/nntp/ArticleIterator.java
+++ b/src/main/java/org/apache/commons/net/nntp/ArticleIterator.java
@@ -28,7 +28,7 @@ class ArticleIterator implements Iterator<Article>, Iterable<Article> {
private final Iterator<String> stringIterator;
- public ArticleIterator(Iterable<String> iterableString) {
+ public ArticleIterator(final Iterable<String> iterableString) {
stringIterator = iterableString.iterator();
}
@@ -44,7 +44,7 @@ class ArticleIterator implements Iterator<Article>, Iterable<Article> {
*/
@Override
public Article next() {
- String line = stringIterator.next();
+ final String line = stringIterator.next();
return NNTPClient.__parseArticleEntry(line);
}
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 f5b2fa3..a871099 100644
--- a/src/main/java/org/apache/commons/net/nntp/NNTP.java
+++ b/src/main/java/org/apache/commons/net/nntp/NNTP.java
@@ -148,7 +148,7 @@ public class NNTP extends SocketClient
{
_replyCode = Integer.parseInt(_replyString.substring(0, 3));
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse response code.\nServer Reply: " + _replyString);
@@ -234,9 +234,9 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(String command, String args) throws IOException
+ public int sendCommand(final String command, final String args) throws IOException
{
- StringBuilder __commandBuffer = new StringBuilder();
+ final StringBuilder __commandBuffer = new StringBuilder();
__commandBuffer.append(command);
if (args != null)
@@ -278,7 +278,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(int command, String args) throws IOException
+ public int sendCommand(final int command, final String args) throws IOException
{
return sendCommand(NNTPCommand.getCommand(command), args);
}
@@ -302,7 +302,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(String command) throws IOException
+ public int sendCommand(final String command) throws IOException
{
return sendCommand(command, null);
}
@@ -327,7 +327,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int sendCommand(int command) throws IOException
+ public int sendCommand(final int command) throws IOException
{
return sendCommand(command, null);
}
@@ -397,7 +397,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int article(String messageId) throws IOException
+ public int article(final String messageId) throws IOException
{
return sendCommand(NNTPCommand.ARTICLE, messageId);
}
@@ -417,7 +417,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int article(long articleNumber) throws IOException
+ public int article(final long articleNumber) throws IOException
{
return sendCommand(NNTPCommand.ARTICLE, Long.toString(articleNumber));
}
@@ -457,7 +457,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int body(String messageId) throws IOException
+ public int body(final String messageId) throws IOException
{
return sendCommand(NNTPCommand.BODY, messageId);
}
@@ -477,7 +477,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int body(long articleNumber) throws IOException
+ public int body(final long articleNumber) throws IOException
{
return sendCommand(NNTPCommand.BODY, Long.toString(articleNumber));
}
@@ -517,7 +517,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int head(String messageId) throws IOException
+ public int head(final String messageId) throws IOException
{
return sendCommand(NNTPCommand.HEAD, messageId);
}
@@ -537,7 +537,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int head(long articleNumber) throws IOException
+ public int head(final long articleNumber) throws IOException
{
return sendCommand(NNTPCommand.HEAD, Long.toString(articleNumber));
}
@@ -577,7 +577,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int stat(String messageId) throws IOException
+ public int stat(final String messageId) throws IOException
{
return sendCommand(NNTPCommand.STAT, messageId);
}
@@ -597,7 +597,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int stat(long articleNumber) throws IOException
+ public int stat(final long articleNumber) throws IOException
{
return sendCommand(NNTPCommand.STAT, Long.toString(articleNumber));
}
@@ -635,7 +635,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int group(String newsgroup) throws IOException
+ public int group(final String newsgroup) throws IOException
{
return sendCommand(NNTPCommand.GROUP, newsgroup);
}
@@ -675,7 +675,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int ihave(String messageId) throws IOException
+ public int ihave(final String messageId) throws IOException
{
return sendCommand(NNTPCommand.IHAVE, messageId);
}
@@ -760,10 +760,10 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int newgroups(String date, String time, boolean GMT,
- String distributions) throws IOException
+ public int newgroups(final String date, final String time, final boolean GMT,
+ final String distributions) throws IOException
{
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
buffer.append(date);
buffer.append(' ');
@@ -808,10 +808,10 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int newnews(String newsgroups, String date, String time, boolean GMT,
- String distributions) throws IOException
+ public int newnews(final String newsgroups, final String date, final String time, final boolean GMT,
+ final String distributions) throws IOException
{
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
buffer.append(newsgroups);
buffer.append(' ');
@@ -890,8 +890,8 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int authinfoUser(String username) throws IOException {
- String userParameter = "USER " + username;
+ public int authinfoUser(final String username) throws IOException {
+ final String userParameter = "USER " + username;
return sendCommand(NNTPCommand.AUTHINFO, userParameter);
}
@@ -912,8 +912,8 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int authinfoPass(String password) throws IOException {
- String passParameter = "PASS " + password;
+ public int authinfoPass(final String password) throws IOException {
+ final String passParameter = "PASS " + password;
return sendCommand(NNTPCommand.AUTHINFO, passParameter);
}
@@ -937,7 +937,7 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int xover(String selectedArticles) throws IOException {
+ public int xover(final String selectedArticles) throws IOException {
return sendCommand(NNTPCommand.XOVER, selectedArticles);
}
@@ -963,8 +963,8 @@ public class NNTP extends SocketClient
* @throws IOException If an I/O error occurs while either sending the
* command or receiving the server reply.
***/
- public int xhdr(String header, String selectedArticles) throws IOException {
- StringBuilder command = new StringBuilder(header);
+ public int xhdr(final String header, final String selectedArticles) throws IOException {
+ final StringBuilder command = new StringBuilder(header);
command.append(" ");
command.append(selectedArticles);
return sendCommand(NNTPCommand.XHDR, command.toString());
@@ -979,8 +979,8 @@ public class NNTP extends SocketClient
* @return the reply code received from the server.
* @throws IOException if the command fails
*/
- public int listActive(String wildmat) throws IOException {
- StringBuilder command = new StringBuilder("ACTIVE ");
+ public int listActive(final String wildmat) throws IOException {
+ final StringBuilder command = new StringBuilder("ACTIVE ");
command.append(wildmat);
return sendCommand(NNTPCommand.LIST, command.toString());
}
@@ -994,7 +994,7 @@ public class NNTP extends SocketClient
* @deprecated - for API compatibility only - DO NOT USE
*/
@Deprecated
- public int article(int a) throws IOException
+ public int article(final int a) throws IOException
{
return article((long) a);
}
@@ -1006,7 +1006,7 @@ public class NNTP extends SocketClient
* @deprecated - for API compatibility only - DO NOT USE
*/
@Deprecated
- public int body(int a) throws IOException
+ public int body(final int a) throws IOException
{
return body((long) a);
}
@@ -1018,7 +1018,7 @@ public class NNTP extends SocketClient
* @deprecated - for API compatibility only - DO NOT USE
*/
@Deprecated
- public int head(int a) throws IOException
+ public int head(final int a) throws IOException
{
return head((long) a);
}
@@ -1030,7 +1030,7 @@ public class NNTP extends SocketClient
* @deprecated - for API compatibility only - DO NOT USE
*/
@Deprecated
- public int stat(int a) throws IOException
+ public int stat(final int a) throws IOException
{
return stat((long) a);
}
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 53e4fd8..82504ef 100644
--- a/src/main/java/org/apache/commons/net/nntp/NNTPClient.java
+++ b/src/main/java/org/apache/commons/net/nntp/NNTPClient.java
@@ -94,10 +94,10 @@ public class NNTPClient extends NNTP
*
* @throws MalformedServerReplyException if response could not be parsed
*/
- private void __parseArticlePointer(String reply, ArticleInfo pointer)
+ private void __parseArticlePointer(final String reply, final ArticleInfo pointer)
throws MalformedServerReplyException
{
- String tokens[] = reply.split(" ");
+ final String tokens[] = reply.split(" ");
if (tokens.length >= 3) { // OK, we can parset the line
int i = 1; // skip reply code
try
@@ -108,7 +108,7 @@ public class NNTPClient extends NNTP
pointer.articleId = tokens[i++];
return; // done
}
- catch (NumberFormatException e)
+ catch (final NumberFormatException e)
{
// drop through and raise exception
}
@@ -125,10 +125,10 @@ public class NNTPClient extends NNTP
* s = name of the group.)
*/
- private static void __parseGroupReply(String reply, NewsgroupInfo info)
+ private static void __parseGroupReply(final String reply, final NewsgroupInfo info)
throws MalformedServerReplyException
{
- String tokens[] = reply.split(" ");
+ final String tokens[] = reply.split(" ");
if (tokens.length >= 5) {
int i = 1; // Skip numeric response value
try
@@ -144,7 +144,7 @@ public class NNTPClient extends NNTP
info._setPostingPermission(NewsgroupInfo.UNKNOWN_POSTING_PERMISSION);
return ;
- } catch (NumberFormatException e)
+ } catch (final NumberFormatException e)
{
// drop through to report error
}
@@ -156,13 +156,13 @@ public class NNTPClient extends NNTP
// Format: group last first p
- static NewsgroupInfo __parseNewsgroupListEntry(String entry)
+ static NewsgroupInfo __parseNewsgroupListEntry(final String entry)
{
- String tokens[] = entry.split(" ");
+ final String tokens[] = entry.split(" ");
if (tokens.length < 4) {
return null;
}
- NewsgroupInfo result = new NewsgroupInfo();
+ final NewsgroupInfo result = new NewsgroupInfo();
int i = 0;
@@ -170,8 +170,8 @@ public class NNTPClient extends NNTP
try
{
- long lastNum = Long.parseLong(tokens[i++]);
- long firstNum = Long.parseLong(tokens[i++]);
+ final long lastNum = Long.parseLong(tokens[i++]);
+ final long firstNum = Long.parseLong(tokens[i++]);
result._setFirstArticle(firstNum);
result._setLastArticle(lastNum);
if ((firstNum == 0) && (lastNum == 0)) {
@@ -179,7 +179,7 @@ public class NNTPClient extends NNTP
} else {
result._setArticleCount(lastNum - firstNum + 1);
}
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
@@ -217,14 +217,14 @@ public class NNTPClient extends NNTP
* will be true, and the subject will contain the raw info.
* @since 3.0
*/
- static Article __parseArticleEntry(String line) {
+ static Article __parseArticleEntry(final String line) {
// Extract the article information
// Mandatory format (from NNTP RFC 2980) is :
// articleNumber\tSubject\tAuthor\tDate\tID\tReference(s)\tByte Count\tLine Count
- Article article = new Article();
+ final Article article = new Article();
article.setSubject(line); // in case parsing fails
- String parts[] = line.split("\t");
+ final String parts[] = line.split("\t");
if (parts.length > 6) {
int i = 0;
try {
@@ -234,7 +234,7 @@ public class NNTPClient extends NNTP
article.setDate(parts[i++]);
article.setArticleId(parts[i++]);
article.addReference(parts[i++]);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
// ignored, already handled
}
}
@@ -244,15 +244,15 @@ public class NNTPClient extends NNTP
private NewsgroupInfo[] __readNewsgroupListing() throws IOException
{
- BufferedReader reader = new DotTerminatedMessageReader(_reader_);
+ final BufferedReader reader = new DotTerminatedMessageReader(_reader_);
// Start of with a big vector because we may be reading a very large
// amount of groups.
- Vector<NewsgroupInfo> list = new Vector<>(2048);
+ final Vector<NewsgroupInfo> list = new Vector<>(2048);
String line;
try {
while ((line = reader.readLine()) != null) {
- NewsgroupInfo tmp = __parseNewsgroupListEntry(line);
+ final NewsgroupInfo tmp = __parseNewsgroupListEntry(line);
if (tmp != null) {
list.addElement(tmp);
} else {
@@ -267,14 +267,14 @@ public class NNTPClient extends NNTP
return new NewsgroupInfo[0];
}
- NewsgroupInfo[] info = new NewsgroupInfo[size];
+ final NewsgroupInfo[] info = new NewsgroupInfo[size];
list.copyInto(info);
return info;
}
- private BufferedReader __retrieve(int command, String articleId, ArticleInfo pointer)
+ private BufferedReader __retrieve(final int command, final String articleId, final ArticleInfo pointer)
throws IOException
{
if (articleId != null)
@@ -299,7 +299,7 @@ public class NNTPClient extends NNTP
}
... 11210 lines suppressed ...