Переглянути джерело

Fix a bunch of warnings in DCCManager.

pull/174/head
Chris Smith 9 роки тому
джерело
коміт
51dec62043
1 змінених файлів з 28 додано та 30 видалено
  1. 28
    30
      dcc/src/com/dmdirc/addons/dcc/DCCManager.java

+ 28
- 30
dcc/src/com/dmdirc/addons/dcc/DCCManager.java Переглянути файл

@@ -191,8 +191,7 @@ public class DCCManager {
191 191
             final Parser parser, final boolean reverse, final String token) {
192 192
         // New thread to ask the user where to save in to stop us locking the UI
193 193
         new Thread(() -> {
194
-            final JFileChooser jc = KFileChooser.getFileChooser(config,
195
-                    DCCManager.this,
194
+            final JFileChooser jc = KFileChooser.getFileChooser(config, this,
196 195
                     config.getOption(getDomain(), "receive.savelocation"));
197 196
             final int result;
198 197
             if (config.getOptionBool(getDomain(), "receive.autoaccept")) {
@@ -209,7 +208,7 @@ public class DCCManager {
209 208
             }
210 209
             final boolean resume = handleResume(jc);
211 210
             if (reverse && !token.isEmpty()) {
212
-                final TransferContainer container1 = new TransferContainer(DCCManager.this, send,
211
+                final TransferContainer container1 = new TransferContainer(this, send,
213 212
                         config, backBufferFactory, "*Receive: " + nickname, nickname, null,
214 213
                         urlBuilder, eventBus);
215 214
                 windowManager.addWindow(getContainer(), container1);
@@ -219,7 +218,7 @@ public class DCCManager {
219 218
                             "receive.reverse.sendtoken")) {
220 219
                         parser.sendCTCP(nickname, "DCC", "RESUME "
221 220
                                 + send.getShortFileName() + " 0 "
222
-                                + jc.getSelectedFile().length() + " "
221
+                                + jc.getSelectedFile().length() + ' '
223 222
                                 + token);
224 223
                     } else {
225 224
                         parser.sendCTCP(nickname, "DCC", "RESUME "
@@ -229,10 +228,10 @@ public class DCCManager {
229 228
                 } else {
230 229
                     if (listen(send)) {
231 230
                         parser.sendCTCP(nickname, "DCC", "SEND "
232
-                                + send.getShortFileName() + " "
231
+                                + send.getShortFileName() + ' '
233 232
                                 + DCC.ipToLong(getListenIP(parser))
234
-                                + " " + send.getPort() + " "
235
-                                + send.getFileSize() + " " + token);
233
+                                + ' ' + send.getPort() + ' '
234
+                                + send.getFileSize() + ' ' + token);
236 235
                     }
237 236
                 }
238 237
             } else {
@@ -242,8 +241,8 @@ public class DCCManager {
242 241
                 windowManager.addWindow(getContainer(), container1);
243 242
                 if (resume) {
244 243
                     parser.sendCTCP(nickname, "DCC", "RESUME "
245
-                            + send.getShortFileName() + " "
246
-                            + send.getPort() + " "
244
+                            + send.getShortFileName() + ' '
245
+                            + send.getPort() + ' '
247 246
                             + jc.getSelectedFile().length());
248 247
                 } else {
249 248
                     send.connect();
@@ -447,7 +446,6 @@ public class DCCManager {
447 446
     private void handleSend(final boolean dontAsk, final String[] ctcpData, final ClientInfo client,
448 447
             final Connection connection) {
449 448
         final String nickname = client.getNickname();
450
-        final String filename;
451 449
         String tmpFilename;
452 450
         // Clients tend to put files with spaces in the name in ""
453 451
         final StringBuilder filenameBits = new StringBuilder();
@@ -480,7 +478,7 @@ public class DCCManager {
480 478
             tmpFilename = tmpFilename.replace('/', File.separatorChar);
481 479
         }
482 480
         // Then get just the name of the file.
483
-        filename = new File(tmpFilename).getName();
481
+        final String filename = new File(tmpFilename).getName();
484 482
 
485 483
         final String ip = ctcpData[++i];
486 484
         final String port = ctcpData[++i];
@@ -494,8 +492,8 @@ public class DCCManager {
494 492
         } else {
495 493
             size = -1;
496 494
         }
497
-        final String token = (ctcpData.length - 1 > i
498
-                && !ctcpData[i + 1].equals("T")) ? ctcpData[++i] : "";
495
+        final String token = ctcpData.length - 1 > i
496
+                && !"T".equals(ctcpData[i + 1]) ? ctcpData[++i] : "";
499 497
 
500 498
         // Ignore incorrect ports, or non-numeric IP/Port
501 499
         final long ipLong;
@@ -511,7 +509,7 @@ public class DCCManager {
511 509
         }
512 510
 
513 511
         if (DCCTransfer.findByToken(token) == null && !dontAsk &&
514
-                (token.isEmpty() || port.equals("0"))) {
512
+                (token.isEmpty() || "0".equals(port))) {
515 513
             // Make sure this is not a reverse DCC Send that we no longer care about.
516 514
             eventBus.publish(new DccSendRequestEvent(connection, nickname, filename));
517 515
             final long passedSize = size;
@@ -582,22 +580,22 @@ public class DCCManager {
582 580
         } catch (NumberFormatException nfe) {
583 581
             return;
584 582
         }
585
-        final String token = (ctcpData.length - 1 > i) ? " "
583
+        final String token = ctcpData.length - 1 > i ? ' '
586 584
                 + ctcpData[++i] : "";
587 585
 
588 586
         // Now look for a dcc that matches.
589 587
         for (DCCTransfer send : DCCTransfer.getTransfers()) {
590
-            if (send.getPort() == port && (new File(send.getFileName()))
588
+            if (send.getPort() == port && new File(send.getFileName())
591 589
                     .getName().equalsIgnoreCase(filename)) {
592
-                if ((!token.isEmpty() && !send.getToken().isEmpty())
593
-                        && (!token.equals(send.getToken()))) {
590
+                if (!token.isEmpty() && !send.getToken().isEmpty() &&
591
+                        !token.equals(send.getToken())) {
594 592
                     continue;
595 593
                 }
596 594
                 final Parser parser = connection.getParser();
597 595
                 final String nick = client.getNickname();
598
-                if (ctcpData[0].equalsIgnoreCase("resume")) {
599
-                    parser.sendCTCP(nick, "DCC", "ACCEPT " + ((quoted) ? "\""
600
-                            + filename + "\"" : filename) + " " + port + " "
596
+                if ("resume".equalsIgnoreCase(ctcpData[0])) {
597
+                    parser.sendCTCP(nick, "DCC", "ACCEPT " + (quoted ? '"'
598
+                            + filename + '"' : filename) + ' ' + port + ' '
601 599
                             + send.setFileStart(position) + token);
602 600
                 } else {
603 601
                     send.setFileStart(position);
@@ -606,18 +604,18 @@ public class DCCManager {
606 604
                         if (listen(send)) {
607 605
                             if (send.getToken().isEmpty()) {
608 606
                                 parser.sendCTCP(nick, "DCC", "SEND "
609
-                                        + ((quoted) ? "\"" + filename
610
-                                        + "\"" : filename) + " "
607
+                                        + (quoted ? '"' + filename
608
+                                        + '"' : filename) + ' '
611 609
                                         + DCC.ipToLong(send.getHost())
612
-                                        + " " + send.getPort()
613
-                                        + " " + send.getFileSize());
610
+                                        + ' ' + send.getPort()
611
+                                        + ' ' + send.getFileSize());
614 612
                             } else {
615 613
                                 parser.sendCTCP(nick, "DCC", "SEND "
616
-                                        + ((quoted) ? "\"" + filename
617
-                                        + "\"" : filename)
618
-                                        + " " + DCC.ipToLong(send.getHost())
619
-                                        + " " + send.getPort()
620
-                                        + " " + send.getFileSize() + " "
614
+                                        + (quoted ? '"' + filename
615
+                                        + '"' : filename)
616
+                                        + ' ' + DCC.ipToLong(send.getHost())
617
+                                        + ' ' + send.getPort()
618
+                                        + ' ' + send.getFileSize() + ' '
621 619
                                         + send.getToken());
622 620
                             }
623 621
                         }

Завантаження…
Відмінити
Зберегти