Skip to content
Permalink
Browse files
Combine nested 'if' statement in 'else' block to 'else if'.
  • Loading branch information
garydgregory committed Feb 22, 2021
1 parent cbd2623 commit 243449bd6998f84cf3169954c3a9d3b41888f9ac
Showing 6 changed files with 72 additions and 102 deletions.
@@ -63,14 +63,12 @@ public static void main(final String[] args) throws Throwable {
" exampleClass>,<exampleClass parameters> (comma-separated, no spaces)");
System.out.println("Or : mvn -q exec:java -Dexec.args=\"<alias" +
" or exampleClass> <exampleClass parameters>\" (space separated)");
} else if (fromJar()) {
System.out.println(
"Usage: java -jar commons-net-examples-m.n.jar <alias or exampleClass> <exampleClass parameters>");
} else {
if (fromJar()) {
System.out.println(
"Usage: java -jar commons-net-examples-m.n.jar <alias or exampleClass> <exampleClass parameters>");
} else {
System.out.println(
"Usage: java -cp target/classes examples/Main <alias or exampleClass> <exampleClass parameters>");
}
System.out.println(
"Usage: java -cp target/classes examples/Main <alias or exampleClass> <exampleClass parameters>");
}
@SuppressWarnings("unchecked") // property names are Strings
final
@@ -481,12 +481,10 @@ else if (feat)
if (remote != null) { // See if the command is present
if (ftp.hasFeature(remote)) {
System.out.println("Has feature: "+remote);
} else if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
System.out.println("FEAT "+remote+" was not detected");
} else {
if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
System.out.println("FEAT "+remote+" was not detected");
} else {
System.out.println("Command failed: "+ftp.getReplyString());
}
System.out.println("Command failed: "+ftp.getReplyString());
}

// Strings feature check
@@ -495,19 +493,15 @@ else if (feat)
for(final String f : features) {
System.out.println("FEAT "+remote+"="+f+".");
}
} else if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
System.out.println("FEAT "+remote+" is not present");
} else {
if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
System.out.println("FEAT "+remote+" is not present");
} else {
System.out.println("Command failed: "+ftp.getReplyString());
}
System.out.println("Command failed: "+ftp.getReplyString());
}
} else {
if (ftp.features()) {
} else if (ftp.features()) {
// Command listener has already printed the output
} else {
System.out.println("Failed: "+ftp.getReplyString());
}
} else {
System.out.println("Failed: "+ftp.getReplyString());
}
}
else if (doCommand != null)
@@ -786,10 +786,8 @@ protected Socket _openDataConnection_(final String command, final String arg)
if (!FTPReply.isPositiveCompletion(eprt(getReportHostAddress(), server.getLocalPort()))) {
return null;
}
} else {
if (!FTPReply.isPositiveCompletion(port(getReportHostAddress(), server.getLocalPort()))) {
return null;
}
} else if (!FTPReply.isPositiveCompletion(port(getReportHostAddress(), server.getLocalPort()))) {
return null;
}

if ((restartOffset > 0) && !restart(restartOffset)) {
@@ -1396,36 +1394,34 @@ void createParser(final String parserKey) throws IOException {
parserFactory.createFileEntryParser(parserKey);
entryParserKey = parserKey;

} else // if no parserKey was supplied, check for a configuration
// in the params, and if it has a non-empty system type, use that.
if (null != configuration && configuration.getServerSystemKey().length() > 0) {
entryParser =
parserFactory.createFileEntryParser(configuration);
entryParserKey = configuration.getServerSystemKey();
} else {
// if no parserKey was supplied, check for a configuration
// in the params, and if it has a non-empty system type, use that.
if (null != configuration && configuration.getServerSystemKey().length() > 0) {
entryParser =
parserFactory.createFileEntryParser(configuration);
entryParserKey = configuration.getServerSystemKey();
} else {
// if a parserKey hasn't been supplied, and a configuration
// hasn't been supplied, and the override property is not set
// then autodetect by calling
// the SYST command and use that to choose the parser.
String systemType = System.getProperty(FTP_SYSTEM_TYPE);
if (systemType == null) {
systemType = getSystemType(); // cannot be null
final Properties override = getOverrideProperties();
if (override != null) {
final String newType = override.getProperty(systemType);
if (newType != null) {
systemType = newType;
}
// if a parserKey hasn't been supplied, and a configuration
// hasn't been supplied, and the override property is not set
// then autodetect by calling
// the SYST command and use that to choose the parser.
String systemType = System.getProperty(FTP_SYSTEM_TYPE);
if (systemType == null) {
systemType = getSystemType(); // cannot be null
final Properties override = getOverrideProperties();
if (override != null) {
final String newType = override.getProperty(systemType);
if (newType != null) {
systemType = newType;
}
}
if (null != configuration) { // system type must have been empty above
entryParser = parserFactory.createFileEntryParser(new FTPClientConfig(systemType, configuration));
} else {
entryParser = parserFactory.createFileEntryParser(systemType);
}
entryParserKey = systemType;
}
if (null != configuration) { // system type must have been empty above
entryParser = parserFactory.createFileEntryParser(new FTPClientConfig(systemType, configuration));
} else {
entryParser = parserFactory.createFileEntryParser(systemType);
}
entryParserKey = systemType;
}
}
}
@@ -831,12 +831,8 @@ private BufferedReader retrieve(final int command, final String articleId, final
if (!NNTPReply.isPositiveCompletion(sendCommand(command, articleId))) {
return null;
}
}
else
{
if (!NNTPReply.isPositiveCompletion(sendCommand(command))) {
return null;
}
} else if (!NNTPReply.isPositiveCompletion(sendCommand(command))) {
return null;
}


@@ -1675,10 +1671,8 @@ public boolean selectArticle(final String articleId, final ArticleInfo pointer)
if (!NNTPReply.isPositiveCompletion(stat(articleId))) {
return false;
}
} else {
if (!NNTPReply.isPositiveCompletion(stat())) {
return false;
}
} else if (!NNTPReply.isPositiveCompletion(stat())) {
return false;
}

if (pointer != null) {
@@ -216,22 +216,19 @@ public void computeDetails()
if (deltaMillis <= delayValueMillis)
{
delayValueMillis -= deltaMillis; // delay = (t4 - t1) - (t3 - t2)
} else
} else // if delta - delayValue == 1 ms then it's a round-off error
// e.g. delay=3ms, processing=4ms
if (deltaMillis - delayValueMillis == 1)
{
// if delta - delayValue == 1 ms then it's a round-off error
// e.g. delay=3ms, processing=4ms
if (deltaMillis - delayValueMillis == 1)
// delayValue == 0 -> local clock saw no tick change but destination clock did
if (delayValueMillis != 0)
{
// delayValue == 0 -> local clock saw no tick change but destination clock did
if (delayValueMillis != 0)
{
comments.add("Info: processing time > total network time by 1 ms -> assume zero delay");
delayValueMillis = 0;
}
} else {
comments.add("Warning: processing time > total network time");
}
}
comments.add("Info: processing time > total network time by 1 ms -> assume zero delay");
delayValueMillis = 0;
}
} else {
comments.add("Warning: processing time > total network time");
}
}
delayMillis = Long.valueOf(delayValueMillis);
if (origTimeMillis > returnTimeMillis) {
@@ -465,22 +465,17 @@ void processDo(final int option) throws IOException
if (optionHandlers[option] != null)
{
acceptNewState = optionHandlers[option].getAcceptLocal();
}
else
} else /* open TelnetOptionHandler functionality (end)*/
/* TERMINAL-TYPE option (start)*/
if (option == TERMINAL_TYPE)
{
/* open TelnetOptionHandler functionality (end)*/
/* TERMINAL-TYPE option (start)*/
if (option == TERMINAL_TYPE)
if (terminalType != null && !terminalType.isEmpty())
{
if (terminalType != null && !terminalType.isEmpty())
{
acceptNewState = true;
}
acceptNewState = true;
}
/* TERMINAL-TYPE option (end)*/
/* open TelnetOptionHandler functionality (start)*/
}
/* open TelnetOptionHandler functionality (end)*/
/* TERMINAL-TYPE option (end)*/
/* open TelnetOptionHandler functionality (start)*/

if (willResponse[option] > 0)
{
@@ -611,25 +606,21 @@ void processSuboption(final int[] suboption, final int suboptionLength)
optionHandlers[suboption[0]].answerSubnegotiation(suboption,
suboptionLength);
_sendSubnegotiation(responseSuboption);
}
else
} else if (suboptionLength > 1)
{
if (suboptionLength > 1)
if (debug)
{
if (debug)
{
for (int ii = 0; ii < suboptionLength; ii++)
{
System.err.println("SUB[" + ii + "]: "
+ suboption[ii]);
}
}
if (suboption[0] == TERMINAL_TYPE
&& suboption[1] == TERMINAL_TYPE_SEND)
for (int ii = 0; ii < suboptionLength; ii++)
{
sendTerminalType();
System.err.println("SUB[" + ii + "]: "
+ suboption[ii]);
}
}
if (suboption[0] == TERMINAL_TYPE
&& suboption[1] == TERMINAL_TYPE_SEND)
{
sendTerminalType();
}
}
}
/* open TelnetOptionHandler functionality (end)*/

0 comments on commit 243449b

Please sign in to comment.