Selaa lähdekoodia

PMD violation fixes

git-svn-id: http://svn.dmdirc.com/trunk@3639 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 vuotta sitten
vanhempi
commit
50a5664219

+ 2
- 0
src/com/dmdirc/ChannelEventHandler.java Näytä tiedosto

@@ -52,6 +52,8 @@ public final class ChannelEventHandler extends EventHandler implements
52 52
      * @param owner The channel that owns this event handler.
53 53
      */
54 54
     public ChannelEventHandler(final Channel owner) {
55
+        super();
56
+        
55 57
         this.owner = owner;
56 58
     }
57 59
 

+ 2
- 0
src/com/dmdirc/actions/ActionGroup.java Näytä tiedosto

@@ -64,6 +64,8 @@ public class ActionGroup extends ArrayList<Action> {
64 64
      * @param name The name of this action group
65 65
      */
66 66
     public ActionGroup(final String name) {
67
+        super();
68
+        
67 69
         this.name = name;
68 70
     }
69 71
 

+ 7
- 11
src/com/dmdirc/addons/audio/AudioPlayer.java Näytä tiedosto

@@ -26,11 +26,7 @@ import java.io.File;
26 26
 import java.applet.AudioClip;
27 27
 import java.applet.Applet;
28 28
 
29
-import javax.sound.sampled.AudioInputStream;
30 29
 import javax.sound.sampled.AudioSystem;
31
-import javax.sound.sampled.AudioFormat;
32
-import javax.sound.sampled.SourceDataLine;
33
-import javax.sound.sampled.DataLine;
34 30
 
35 31
 /**
36 32
  * The AudioPlayer handles the playing of the audio
@@ -111,7 +107,7 @@ public final class AudioPlayer implements Runnable {
111 107
 	 */
112 108
 	private void playWav() {
113 109
 		try {
114
-			final AudioClip ac = (new Applet()).newAudioClip(myFile.toURI().toURL());
110
+			final AudioClip ac = Applet.newAudioClip(myFile.toURI().toURL());
115 111
 			if (ac != null) { ac.play(); }
116 112
 		} catch (Exception e) { /* Bad File, can't play */ }
117 113
 	}
@@ -120,16 +116,16 @@ public final class AudioPlayer implements Runnable {
120 116
 	 * Play the file as a wav file.
121 117
 	 * Based on http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml
122 118
 	 */
123
-	private void oldPlayWav() {
119
+	/*private void oldPlayWav() {
124 120
 		final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb
125 121
 		AudioInputStream audioInputStream = null;
126 122
 		try {
127 123
 			audioInputStream = AudioSystem.getAudioInputStream(myFile);
128 124
 		} catch (Exception e) { return; }
129
-		AudioFormat format = audioInputStream.getFormat();
125
+		final AudioFormat format = audioInputStream.getFormat();
130 126
 		
131 127
 		SourceDataLine auline = null;
132
-		DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
128
+		final DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
133 129
 		
134 130
 		try {
135 131
 			auline = (SourceDataLine) AudioSystem.getLine(info);
@@ -138,7 +134,7 @@ public final class AudioPlayer implements Runnable {
138 134
 		
139 135
 		auline.start();
140 136
 		int nBytesRead = 0;
141
-		byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
137
+		final byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
142 138
 		
143 139
 		try {
144 140
 			while (nBytesRead != -1) {
@@ -149,7 +145,7 @@ public final class AudioPlayer implements Runnable {
149 145
 				}
150 146
 			}
151 147
 		} catch (Exception e) {
152
-			/** Do Nothing */
148
+			/** Do Nothing *
153 149
 		} finally {
154 150
 			auline.drain();
155 151
 			auline.close();
@@ -157,5 +153,5 @@ public final class AudioPlayer implements Runnable {
157 153
 		try {
158 154
 			audioInputStream.close();
159 155
 		} catch (Exception e) { }
160
-	}
156
+	}*/
161 157
 }

+ 1
- 1
src/com/dmdirc/addons/dcc/DCCSendWindow.java Näytä tiedosto

@@ -59,7 +59,7 @@ public class DCCSendWindow extends DCCFrame implements DCCSendInterface {
59 59
 		nickname = nick;
60 60
 		otherNickname = targetNick;
61 61
 		
62
-		JWrappingLabel label = new JWrappingLabel("This is a placeholder dcc send window.", SwingConstants.CENTER);
62
+		final JWrappingLabel label = new JWrappingLabel("This is a placeholder dcc send window.", SwingConstants.CENTER);
63 63
 		
64 64
 		((TextFrame)getFrame()).getContentPane().add(label);
65 65
 		plugin.addWindow(this);

+ 9
- 10
src/com/dmdirc/addons/identd/IdentClient.java Näytä tiedosto

@@ -66,7 +66,7 @@ public final class IdentClient implements Runnable {
66 66
 	 * Process this connection
67 67
 	 */
68 68
 	public void run() {
69
-		Thread thisThread = Thread.currentThread();
69
+		final Thread thisThread = Thread.currentThread();
70 70
 		PrintWriter out = null;
71 71
 		BufferedReader in = null;
72 72
 		try {
@@ -116,10 +116,9 @@ public final class IdentClient implements Runnable {
116 116
 		}
117 117
 		
118 118
 		final Server server = getServerByPort(myPort);
119
-		if (!IdentityManager.getGlobalConfig().getOptionBool(IdentdPlugin.getDomain(), "advanced.alwaysOn")) {
120
-			if (server == null || IdentityManager.getGlobalConfig().getOptionBool(IdentdPlugin.getDomain(), "advanced.isNoUser")) {
121
-				return String.format("%d , %d : ERROR : NO-USER", myPort, theirPort);
122
-			}
119
+		if (!IdentityManager.getGlobalConfig().getOptionBool(IdentdPlugin.getDomain(), "advanced.alwaysOn")
120
+                && (server == null || IdentityManager.getGlobalConfig().getOptionBool(IdentdPlugin.getDomain(), "advanced.isNoUser"))) {
121
+			return String.format("%d , %d : ERROR : NO-USER", myPort, theirPort);
123 122
 		}
124 123
 		
125 124
 		if (IdentityManager.getGlobalConfig().getOptionBool(IdentdPlugin.getDomain(), "advanced.isHiddenUser")) {
@@ -140,10 +139,10 @@ public final class IdentClient implements Runnable {
140 139
 			if (osName.startsWith("windows")) { os = "WIN32"; }
141 140
 			else if (osName.startsWith("mac")) { os = "MACOS"; }
142 141
 			else if (osName.startsWith("linux")) { os = "UNIX"; }
143
-			else if (osName.indexOf("bsd") != -1) { os = "UNIX-BSD"; }
144
-			else if (osName.equals("os/2")) { os = "OS/2"; }
145
-			else if (osName.indexOf("unix") != -1) { os = "UNIX"; }
146
-			else if (osName.equals("irix")) { os = "IRIX"; }
142
+			else if (osName.indexOf("bsd") > -1) { os = "UNIX-BSD"; }
143
+			else if ("os/2".equals(osName)) { os = "OS/2"; }
144
+			else if (osName.indexOf("unix") > -1) { os = "UNIX"; }
145
+			else if ("irix".equals(osName)) { os = "IRIX"; }
147 146
 			else { os = "UNKNOWN"; }
148 147
 		}
149 148
 		
@@ -166,7 +165,7 @@ public final class IdentClient implements Runnable {
166 165
 	 */
167 166
 	public void close() {
168 167
 		if (myThread != null) {
169
-			Thread tmpThread = myThread;
168
+			final Thread tmpThread = myThread;
170 169
 			myThread = null;
171 170
 			if (tmpThread != null) { tmpThread.interrupt(); }
172 171
 			try { mySocket.close(); } catch (IOException e) { }

+ 5
- 7
src/com/dmdirc/addons/identd/IdentdPlugin.java Näytä tiedosto

@@ -67,7 +67,7 @@ public class IdentdPlugin extends Plugin implements ActionListener {
67 67
 		ActionManager.addListener(this, CoreActionType.SERVER_CONNECTED, CoreActionType.SERVER_CONNECTING, CoreActionType.SERVER_CONNECTERROR);
68 68
 
69 69
 		// Set defaults
70
-		Properties defaults = new Properties();
70
+		final Properties defaults = new Properties();
71 71
 		defaults.setProperty(getDomain() + ".general.useUsername", "false");
72 72
 		defaults.setProperty(getDomain() + ".general.useNickname", "false");
73 73
 		defaults.setProperty(getDomain() + ".general.useCustomName", "false");
@@ -83,7 +83,7 @@ public class IdentdPlugin extends Plugin implements ActionListener {
83 83
 		defaults.setProperty("identity.name", "Identd Plugin Defaults");
84 84
 		IdentityManager.addIdentity(new Identity(defaults));
85 85
 		
86
-		myServer = new IdentdServer(this);
86
+		myServer = new IdentdServer();
87 87
 		if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "advanced.alwaysOn")) {
88 88
 			myServer.startServer();
89 89
 		}
@@ -110,7 +110,7 @@ public class IdentdPlugin extends Plugin implements ActionListener {
110 110
 	public void processEvent(final ActionType type, final StringBuffer format, final Object... arguments) {
111 111
 		if (type == CoreActionType.SERVER_CONNECTING) {
112 112
 			synchronized (servers) {
113
-				if (servers.size() == 0) {
113
+				if (servers.isEmpty()) {
114 114
 					myServer.startServer();
115 115
 				}
116 116
 				servers.add((Server) arguments[0]);
@@ -119,10 +119,8 @@ public class IdentdPlugin extends Plugin implements ActionListener {
119 119
 			synchronized (servers) {
120 120
 				servers.remove(arguments[0]);
121 121
 			
122
-				if (servers.size() == 0) {
123
-					if (!IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "advanced.alwaysOn")) {
124
-						myServer.stopServer();
125
-					}
122
+				if (servers.isEmpty() && !IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "advanced.alwaysOn")) {
123
+					myServer.stopServer();
126 124
 				}
127 125
 			}
128 126
 		}

+ 10
- 13
src/com/dmdirc/addons/identd/IdentdServer.java Näytä tiedosto

@@ -39,9 +39,8 @@ import java.util.List;
39 39
  * @version $Id: IdentdServer.java 969 2007-04-30 18:38:20Z ShaneMcC $
40 40
  */
41 41
 public final class IdentdServer implements Runnable {
42
-	/** The IdentdPlugin that owns this Server */
43
-	private final IdentdPlugin myIdentdPlugin;
44
-	/** The Thread in use for this server */
42
+
43
+    /** The Thread in use for this server */
45 44
 	private volatile Thread myThread = null;
46 45
 	/** The current socket in use for this server */
47 46
 	private ServerSocket serverSocket;
@@ -49,23 +48,21 @@ public final class IdentdServer implements Runnable {
49 48
 	private final List<IdentClient> clientList = new ArrayList<IdentClient>();
50 49
 	
51 50
 	/**
52
-	 * Create the IdentdServer
53
-	 *
54
-	 * @param plugin The plugin that owns this Server
51
+	 * Create the IdentdServer.
55 52
 	 */
56
-	public IdentdServer(final IdentdPlugin plugin) {
57
-		myIdentdPlugin = plugin;
53
+	public IdentdServer() {
54
+        super();
58 55
 	}
59 56
 	
60 57
 	/**
61
-	 * Run this IdentdServer
58
+	 * Run this IdentdServer.
62 59
 	 */
63 60
 	public void run() {
64
-		Thread thisThread = Thread.currentThread();
61
+		final Thread thisThread = Thread.currentThread();
65 62
 		while (myThread == thisThread) {
66 63
 			try {
67
-				Socket clientSocket = serverSocket.accept();
68
-				IdentClient client = new IdentClient(this, clientSocket);
64
+				final Socket clientSocket = serverSocket.accept();
65
+				final IdentClient client = new IdentClient(this, clientSocket);
69 66
 				addClient(client);
70 67
 			} catch (IOException e) {
71 68
 				if (myThread == thisThread) {
@@ -132,7 +129,7 @@ public final class IdentdServer implements Runnable {
132 129
 	 */
133 130
 	public void stopServer() {
134 131
 		if (myThread != null) {
135
-			Thread tmpThread = myThread;
132
+			final Thread tmpThread = myThread;
136 133
 			myThread = null;
137 134
 			if (tmpThread != null) { tmpThread.interrupt(); }
138 135
 			try { serverSocket.close(); } catch (IOException e) { }

+ 1
- 1
src/com/dmdirc/addons/logging/LoggingCommand.java Näytä tiedosto

@@ -65,7 +65,7 @@ public final class LoggingCommand extends ServerCommand implements IntelligentCo
65 65
 		}
66 66
 		final Plugin gotPlugin = pluginInfo.getPlugin();
67 67
 		
68
-		if (gotPlugin == null || !(gotPlugin instanceof LoggingPlugin)) {
68
+		if (!(gotPlugin instanceof LoggingPlugin)) {
69 69
 			sendLine(origin, isSilent, FORMAT_ERROR, "Logging Plugin is not loaded.");
70 70
 			return;
71 71
 		}

+ 25
- 23
src/com/dmdirc/addons/logging/LoggingPlugin.java Näytä tiedosto

@@ -61,6 +61,7 @@ import java.text.DateFormat;
61 61
 import java.text.SimpleDateFormat;
62 62
 import java.util.Date;
63 63
 import java.util.Hashtable;
64
+import java.util.Map;
64 65
 import java.util.Properties;
65 66
 import java.util.Stack;
66 67
 
@@ -72,14 +73,15 @@ import java.util.Stack;
72 73
  * @version $Id: LoggingPlugin.java 969 2007-04-30 18:38:20Z ShaneMcC $
73 74
  */
74 75
 public final class LoggingPlugin extends Plugin implements ActionListener {
75
-	/** What domain do we store all settings in the global config under. */
76
+
77
+    /** What domain do we store all settings in the global config under. */
76 78
 	private static final String MY_DOMAIN = "plugin-Logging";
77 79
 
78
-	/** The command we registered */
80
+	/** The command we registered. */
79 81
 	private LoggingCommand command;
80 82
 
81
-	/** Hashtable of open files */
82
-	Hashtable<String,BufferedWriter> openFiles = new Hashtable<String,BufferedWriter>();
83
+	/** Hashtable of open files. */
84
+	private final Map<String,BufferedWriter> openFiles = new Hashtable<String,BufferedWriter>();
83 85
 
84 86
 	/**
85 87
 	 * Creates a new instance of the Logging Plugin.
@@ -92,7 +94,7 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
92 94
 	@Override
93 95
 	public void onLoad() {
94 96
 		// Set defaults
95
-		Properties defaults = new Properties();
97
+		final Properties defaults = new Properties();
96 98
 		defaults.setProperty(MY_DOMAIN + ".general.directory", Main.getConfigDir() + "logs" + System.getProperty("file.separator"));
97 99
 		defaults.setProperty(MY_DOMAIN + ".general.networkfolders", "true");
98 100
 		defaults.setProperty(MY_DOMAIN + ".advanced.filenamehash", "false");
@@ -109,17 +111,17 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
109 111
 		IdentityManager.addIdentity(new Identity(defaults));
110 112
 
111 113
 		final File dir = new File(IdentityManager.getGlobalConfig().getOption(MY_DOMAIN, "general.directory"));
112
-		if (!dir.exists()) {
114
+		if (dir.exists()) {
115
+			if (!dir.isDirectory()) {
116
+				Logger.userError(ErrorLevel.LOW, "Unable to create logging dir (file exists instead)");
117
+			}            
118
+		} else {
113 119
 			try {
114 120
 				dir.mkdirs();
115 121
 				dir.createNewFile();
116 122
 			} catch (IOException ex) {
117 123
 				Logger.userError(ErrorLevel.LOW, "Unable to create logging dir");
118 124
 			}
119
-		} else {
120
-			if (!dir.isDirectory()) {
121
-				Logger.userError(ErrorLevel.LOW, "Unable to create logging dir (file exists instead)");
122
-			}
123 125
 		}
124 126
 
125 127
 		command = new LoggingCommand();
@@ -260,7 +262,7 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
260 262
 					line = getLogFile(client);
261 263
 					if (openFiles.containsKey(line)) {
262 264
 						appendLine(line, "*** Query closed at: " + openedAtFormat.format(new Date()));
263
-						BufferedWriter file = openFiles.get(line);
265
+						final BufferedWriter file = openFiles.get(line);
264 266
 						try {
265 267
 							file.close();
266 268
 						} catch (IOException e) {
@@ -276,7 +278,7 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
276 278
 					line = getLogFile(channel);
277 279
 					if (openFiles.containsKey(line)) {
278 280
 						appendLine(line, "*** Channel closed at: " + openedAtFormat.format(new Date()));
279
-						BufferedWriter file = openFiles.get(line);
281
+						final BufferedWriter file = openFiles.get(line);
280 282
 						try {
281 283
 							file.close();
282 284
 						} catch (IOException e) {
@@ -457,15 +459,15 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
457 459
 			return;
458 460
 		}
459 461
 
460
-		File testFile = new File(filename);
462
+		final File testFile = new File(filename);
461 463
 		if (testFile.exists()) {
462 464
 			try {
463
-				ReverseFileReader file = new ReverseFileReader(testFile);
465
+				final ReverseFileReader file = new ReverseFileReader(testFile);
464 466
 				// Because the file includes a newline char at the end, an empty line
465 467
 				// is returned by getLines. To counter this, we call getLines(1) and do
466 468
 				// nothing with the output.
467 469
 				file.getLines(1);
468
-				Stack<String> lines = file.getLines(numLines);
470
+				final Stack<String> lines = file.getLines(numLines);
469 471
 				while (!lines.empty()) {
470 472
 					frame.addLine(getColouredString(colour,lines.pop()), showTimestamp);
471 473
 				}
@@ -485,7 +487,7 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
485 487
 	 * @param line the line to colour
486 488
 	 * @return The given line with the appropriate irc codes appended/prepended to colour it.
487 489
 	 */
488
-	private String getColouredString(String colour, String line) {
490
+	private String getColouredString(final String colour, final String line) {
489 491
 		String res = null;
490 492
 		if (colour.length() < 3) {
491 493
 			int num;
@@ -699,7 +701,13 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
699 701
 			result = result + sanitise(networkName.toLowerCase()) + System.getProperty("file.separator");
700 702
 			// Check dir exists
701 703
 			final File dir = new File(result);
702
-			if (!dir.exists()) {
704
+			if (dir.exists()) {
705
+				if (!dir.isDirectory()) {
706
+					Logger.userError(ErrorLevel.LOW, "Unable to create networkfolders dir (file exists instead)");
707
+					// Prepend network name instead.
708
+					result = input + sanitise(networkName.toLowerCase()) + " -- ";
709
+				}
710
+			} else {
703 711
 				try {
704 712
 					dir.mkdirs();
705 713
 					dir.createNewFile();
@@ -708,12 +716,6 @@ public final class LoggingPlugin extends Plugin implements ActionListener {
708 716
 					// Prepend network name instead.
709 717
 					result = input + sanitise(networkName.toLowerCase()) + " -- ";
710 718
 				}
711
-			} else {
712
-				if (!dir.isDirectory()) {
713
-					Logger.userError(ErrorLevel.LOW, "Unable to create networkfolders dir (file exists instead)");
714
-					// Prepend network name instead.
715
-					result = input + sanitise(networkName.toLowerCase()) + " -- ";
716
-				}
717 719
 			}
718 720
 		}
719 721
 		return result;

+ 10
- 8
src/com/dmdirc/addons/logging/ReverseFileReader.java Näytä tiedosto

@@ -30,6 +30,7 @@ import java.io.EOFException;
30 30
 import java.nio.charset.Charset;
31 31
 import java.util.Stack;
32 32
 import java.util.ArrayList;
33
+import java.util.List;
33 34
 
34 35
 /**
35 36
  * Reads a file in reverse.
@@ -41,9 +42,9 @@ public class ReverseFileReader {
41 42
 	/** File to manipulate. */
42 43
 	private RandomAccessFile file;
43 44
 	/** \r Character */
44
-	private static final byte r = 0X0D;
45
+	private static final byte R = 0X0D;
45 46
 	/** \n Character */
46
-	private static final byte n = 0X0A;
47
+	private static final byte N = 0X0A;
47 48
 	/** Number of bytes to skip backwards at a time. */
48 49
 	private byte seekLength = 50;
49 50
 
@@ -97,7 +98,7 @@ public class ReverseFileReader {
97 98
 	 *
98 99
 	 * @param newValue New value for seekLength
99 100
 	 */
100
-	public void setSeekLength(byte newValue) {
101
+	public void setSeekLength(final byte newValue) {
101 102
 		seekLength = newValue;
102 103
 	}
103 104
 	
@@ -124,7 +125,7 @@ public class ReverseFileReader {
124 125
 		if (file == null) { throw new IOException("File has been closed."); }
125 126
 		// Used to store result to output.
126 127
 //		StringBuilder line = new StringBuilder();
127
-		ArrayList<Byte> line = new ArrayList<Byte>(seekLength);
128
+		final List<Byte> line = new ArrayList<Byte>(seekLength);
128 129
 		// Used to store position in file pre-read
129 130
 		long fp = 0;
130 131
 		// Used to store position in file when this is called
@@ -170,12 +171,12 @@ public class ReverseFileReader {
170 171
 			// This uses seekDistance so that only wanted data is checked.
171 172
 			for (int i = seekDistance-1; i >= 0; --i) {
172 173
 				// Check for New line Character, or a non carraige-return char
173
-				if (bytes[i] == n) {
174
+				if (bytes[i] == N) {
174 175
 					// Seek to the location of this character and exit this loop.
175 176
 					file.seek(fp+i);
176 177
 					gotNewLine = true;
177 178
 					break;
178
-				} else if (bytes[i] != r) {
179
+				} else if (bytes[i] != R) {
179 180
 					// Add to the result, the loop will continue going.
180 181
 					line.add(0, bytes[i]);
181 182
 				}
@@ -217,9 +218,10 @@ public class ReverseFileReader {
217 218
 	 * If the file is closed, an empty stack will be returned.
218 219
 	 *
219 220
 	 * @param numLines Number of lines to try and get.
221
+     * @return The requested lines
220 222
 	 */
221
-	public Stack<String> getLines(int numLines) {
222
-		Stack<String> result = new Stack<String>();
223
+	public Stack<String> getLines(final int numLines) {
224
+		final Stack<String> result = new Stack<String>();
223 225
 		for (int i = 0; i < numLines; ++i) {
224 226
 			try {
225 227
 				result.push(getNextLine());

+ 2
- 2
src/com/dmdirc/addons/mediasource_vlc/VlcMediaSourcePlugin.java Näytä tiedosto

@@ -117,7 +117,7 @@ public class VlcMediaSourcePlugin extends Plugin implements MediaSource {
117 117
                 result = result.substring(sepIndex,
118 118
                         extIndex > sepIndex ? extIndex : result.length());
119 119
                 
120
-                int offset = result.indexOf('-');
120
+                final int offset = result.indexOf('-');
121 121
                 if (offset > -1) {
122 122
                     result = result.substring(offset + 1).trim();
123 123
                 }
@@ -245,7 +245,7 @@ public class VlcMediaSourcePlugin extends Plugin implements MediaSource {
245 245
                     if (itemname.endsWith("</a>")) {
246 246
                         itemname = itemname.substring(0, itemname.length()-4);
247 247
                     }
248
-                    if (!itemname.equals("")) {
248
+                    if (!itemname.isEmpty()) {
249 249
                         if (isCurrent) {
250 250
                             information.put("playlist_current", Integer.toString(playlistItem));
251 251
                         }

+ 1
- 1
src/com/dmdirc/commandparser/commands/ExternalCommand.java Näytä tiedosto

@@ -41,7 +41,7 @@ public interface ExternalCommand {
41 41
      * @param isSilent Whether this command is silenced or not
42 42
      * @param args Arguments passed to this command
43 43
      */
44
-    public abstract void execute(InputWindow origin, Server server, String channel,
44
+    void execute(InputWindow origin, Server server, String channel,
45 45
             boolean isSilent, String... args);    
46 46
 
47 47
 }

+ 1
- 1
src/com/dmdirc/commandparser/commands/PreviousCommand.java Näytä tiedosto

@@ -67,7 +67,7 @@ public final class PreviousCommand {
67 67
 
68 68
     /** {@inheritDoc} */
69 69
     @Override
70
-    public boolean equals(Object obj) {
70
+    public boolean equals(final Object obj) {
71 71
         if (obj == null) {
72 72
             return false;
73 73
         }

+ 2
- 1
src/com/dmdirc/config/Identity.java Näytä tiedosto

@@ -43,6 +43,7 @@ import java.util.ArrayList;
43 43
 import java.util.HashSet;
44 44
 import java.util.Hashtable;
45 45
 import java.util.List;
46
+import java.util.Map;
46 47
 import java.util.Map.Entry;
47 48
 import java.util.Properties;
48 49
 
@@ -198,7 +199,7 @@ public class Identity extends ConfigSource implements Serializable,
198 199
         assert(file != null);
199 200
                
200 201
         final InputStream input = new FileInputStream(file);
201
-        final Hashtable<Object,Object> oldProps = new Hashtable<Object, Object>(properties);
202
+        final Map<Object,Object> oldProps = new Hashtable<Object, Object>(properties);
202 203
         
203 204
         properties.clear();
204 205
         properties.load(input);

+ 2
- 0
src/com/dmdirc/installer/Main.java Näytä tiedosto

@@ -109,6 +109,8 @@ public final class Main implements WizardListener {
109 109
 	
110 110
 	/**
111 111
 	 * Get the Installer object for this OS.
112
+     * 
113
+     * @return The installer for this OS
112 114
 	 */
113 115
 	public static synchronized Installer getInstaller() {
114 116
 		if (myInstaller == null) {

+ 1
- 1
src/com/dmdirc/installer/StepInstall.java Näytä tiedosto

@@ -48,7 +48,7 @@ public final class StepInstall extends Step implements StepListener {
48 48
 	private static final long serialVersionUID = 2;
49 49
 
50 50
 	/** Text area showing the install information */
51
-	private JTextArea infoLabel = new JTextArea("Beginning Install");
51
+	private final JTextArea infoLabel = new JTextArea("Beginning Install");
52 52
 
53 53
 	/** Scroll pane holding text area */
54 54
 	final JScrollPane scrollPane;

+ 1
- 1
src/com/dmdirc/installer/cliparser/BooleanParam.java Näytä tiedosto

@@ -82,6 +82,6 @@ public class BooleanParam extends CLIParam {
82 82
 	 * @return The value of this param as a string.
83 83
 	 */
84 84
 	public String getStringValue() {
85
-		return ""+getValue();
85
+		return String.valueOf(getValue());
86 86
 	}
87 87
 }

+ 12
- 12
src/com/dmdirc/installer/cliparser/CLIParser.java Näytä tiedosto

@@ -82,11 +82,11 @@ public class CLIParser {
82 82
 	 * @return true if added, false if already exists.
83 83
 	 */
84 84
 	public boolean add(final CLIParam param) {
85
-		boolean validChar = (param.getChr() == 0 || !params.containsKey(""+param.getChr()));
86
-		boolean validString = (param.getString().isEmpty() || !params.containsKey("-"+param.getString()));
85
+		final boolean validChar = param.getChr() == 0 || !params.containsKey(param.getChr());
86
+		final boolean validString = param.getString().isEmpty() || !params.containsKey("-"+param.getString());
87 87
 		if (validChar && validString) {
88 88
 			if (param.getChr() != 0) {
89
-				params.put(""+param.getChr(), param);
89
+				params.put(String.valueOf(param.getChr()), param);
90 90
 			}
91 91
 			if (!param.getString().isEmpty()) {
92 92
 				params.put("-"+param.getString(), param);
@@ -189,15 +189,15 @@ public class CLIParser {
189 189
 		System.out.println(usage);
190 190
 		System.out.println(" ");
191 191
 		for (CLIParam param : this.getParamList()) {
192
-			if (param.getChr() != 0) {
193
-				System.out.print("-"+param.getChr()+" ");
194
-			} else {
192
+			if (param.getChr() == 0) {
195 193
 				System.out.print("   ");
196
-			}
197
-			if (!param.getString().isEmpty()) {
198
-				System.out.print("--"+param.getString()+" ");
199 194
 			} else {
195
+				System.out.print("-"+param.getChr()+" ");
196
+			}
197
+			if (param.getString().isEmpty()) {
200 198
 				System.out.print("\t\t");
199
+			} else {
200
+				System.out.print("--"+param.getString()+" ");
201 201
 			}
202 202
 			System.out.println("\t"+param.getDescription());
203 203
 		}
@@ -224,10 +224,10 @@ public class CLIParser {
224 224
 						System.out.println("Unknown Param: -"+name);
225 225
 						if (helpParam != null) {
226 226
 							String command = "";
227
-							if (!helpParam.getString().isEmpty()) {
228
-								command = helpParam.getString();
227
+							if (helpParam.getString().isEmpty()) {
228
+								command = String.valueOf(helpParam.getChr());
229 229
 							} else if (helpParam.getChr() != 0) {
230
-								command = ""+helpParam.getChr();
230
+								command = helpParam.getString();
231 231
 							}
232 232
 							if (!command.isEmpty()) {
233 233
 								System.out.println("Use "+command+" to get help.");

+ 3
- 3
src/com/dmdirc/parser/ChannelClientInfo.java Näytä tiedosto

@@ -201,9 +201,9 @@ public final class ChannelClientInfo {
201 201
 	 *
202 202
 	 * @param sReason Why are they being kicked? "" for no reason
203 203
 	 */
204
-	public void kick(String sReason) {
205
-		if (!sReason.isEmpty()) { sReason = " :" + sReason; }
206
-		myParser.sendString("KICK " + myChannel + " " + this.getNickname() + sReason);
204
+	public void kick(final String sReason) {
205
+		myParser.sendString("KICK " + myChannel + " " + this.getNickname()
206
+                + (sReason.isEmpty() ? sReason : " :" + sReason));
207 207
 	}
208 208
 	
209 209
 	/**

+ 1
- 1
src/com/dmdirc/parser/ChannelInfo.java Näytä tiedosto

@@ -243,7 +243,7 @@ public final class ChannelInfo {
243 243
 	 *
244 244
 	 * @return if false, any new names reply will cause current known channelclients to be removed.
245 245
 	 */
246
-	public boolean getAddingNames() { return bAddingNames; }
246
+	public boolean isAddingNames() { return bAddingNames; }
247 247
 	
248 248
 	/**
249 249
 	 * Get the name of this channel object.

+ 3
- 5
src/com/dmdirc/parser/ClientInfo.java Näytä tiedosto

@@ -139,13 +139,11 @@ public final class ClientInfo {
139 139
 	public static String[] parseHostFull(String sWho) {
140 140
 		String[] sTemp = null;
141 141
 		final String[] result = new String[3];
142
-		if (!sWho.isEmpty()) {
143
-			if (sWho.charAt(0) == ':') { sWho = sWho.substring(1); }
144
-		}
142
+		if (!sWho.isEmpty() && sWho.charAt(0) == ':') { sWho = sWho.substring(1); }
145 143
 		sTemp = sWho.split("@", 2);
146
-		if (sTemp.length != 1) { result[2] = sTemp[1]; } else { result[2] = ""; }
144
+		if (sTemp.length == 1) { result[2] = ""; } else { result[2] = sTemp[1]; }
147 145
 		sTemp = sTemp[0].split("!", 2);
148
-		if (sTemp.length != 1) { result[1] = sTemp[1]; } else { result[1] = ""; }
146
+		if (sTemp.length == 1) { result[1] = ""; } else { result[1] = sTemp[1]; }
149 147
 		result[0] = sTemp[0];
150 148
 		
151 149
 		return result;

+ 16
- 16
src/com/dmdirc/parser/IRCParser.java Näytä tiedosto

@@ -904,13 +904,13 @@ public class IRCParser implements Runnable {
904 904
 		} else if (newLine[0].equalsIgnoreCase("mode") && newLine.length == 3) {
905 905
 			// This makes sure we don't add the same item to the LMQ twice, even if its requested twice,
906 906
 			// as the ircd will only reply once.
907
-			LinkedList<Character> foundModes = new LinkedList<Character>();
907
+			final LinkedList<Character> foundModes = new LinkedList<Character>();
908 908
 
909
-			ChannelInfo channel = getChannelInfo(newLine[1]);
909
+			final ChannelInfo channel = getChannelInfo(newLine[1]);
910 910
 			if (channel != null) {
911
-				Queue<Character> listModeQueue = channel.getListModeQueue();
911
+				final Queue<Character> listModeQueue = channel.getListModeQueue();
912 912
 				for (int i = 0; i < newLine[2].length() ; ++i) {
913
-					Character mode = newLine[2].charAt(i);
913
+					final Character mode = newLine[2].charAt(i);
914 914
 					callDebugInfo(DEBUG_LMQ, "Intercepted mode request for "+channel+" for mode "+mode);
915 915
 					if (hChanModesOther.containsKey(mode) && hChanModesOther.get(mode) == MODE_LIST) {
916 916
 						if (foundModes.contains(mode)) {
@@ -974,13 +974,13 @@ public class IRCParser implements Runnable {
974 974
 			if (token[0].equalsIgnoreCase("PING") || token[1].equalsIgnoreCase("PING")) {
975 975
 				sendString("PONG :" + sParam);
976 976
 			} else if (token[0].equalsIgnoreCase("PONG") || token[1].equalsIgnoreCase("PONG")) {
977
-				if (!lastPingValue.equals("") && lastPingValue.equals(token[token.length-1])) {
977
+				if (!lastPingValue.isEmpty() && lastPingValue.equals(token[token.length-1])) {
978 978
 					lastPingValue = "";
979 979
 					serverLag = System.currentTimeMillis() - pingTime;
980 980
 					callPingSuccess();
981 981
 				}
982 982
 			} else if (token[0].equalsIgnoreCase("ERROR")) {
983
-				StringBuilder errorMessage = new StringBuilder();
983
+				final StringBuilder errorMessage = new StringBuilder();
984 984
 				for (int i = 1; i < token.length; ++i) { errorMessage.append(token[i]); }
985 985
 				callServerError(errorMessage.toString());
986 986
 			} else {
@@ -1451,14 +1451,16 @@ public class IRCParser implements Runnable {
1451 1451
 	 */
1452 1452
 	public void joinChannel(final String sChannelName, final String sKey, final boolean autoPrefix) {
1453 1453
 		final String channelName;
1454
-		if (!isValidChannelName(sChannelName)) {
1454
+		if (isValidChannelName(sChannelName)) {
1455
+			channelName = sChannelName;
1456
+        } else {
1455 1457
 			if (autoPrefix) {
1456 1458
 				if (h005Info.containsKey("CHANTYPES")) {
1457 1459
 					final String chantypes = h005Info.get("CHANTYPES");
1458
-					if (!chantypes.isEmpty()) {
1459
-						channelName = chantypes.charAt(0)+sChannelName;
1460
+					if (chantypes.isEmpty()) {
1461
+						channelName = "#" + sChannelName;
1460 1462
 					} else {
1461
-						channelName = "#"+sChannelName;
1463
+						channelName = chantypes.charAt(0) + sChannelName;
1462 1464
 					}
1463 1465
 				} else {
1464 1466
 					return;
@@ -1466,8 +1468,6 @@ public class IRCParser implements Runnable {
1466 1468
 			} else {
1467 1469
 				return;
1468 1470
 			}
1469
-		} else {
1470
-			channelName = sChannelName;
1471 1471
 		}
1472 1472
 		if (sKey.isEmpty()) {
1473 1473
 			sendString("JOIN " + channelName);
@@ -1712,9 +1712,9 @@ public class IRCParser implements Runnable {
1712 1712
 		// Check if we are already on this channel
1713 1713
 		if (getChannelInfo(sChannelName) != null) { return true; }
1714 1714
 		// Check if we know of any valid chan prefixes
1715
-		if (hChanPrefix.size() == 0) {
1715
+		if (hChanPrefix.isEmpty()) {
1716 1716
 			// We don't. Lets check against RFC2811-Specified channel types
1717
-			char first = sChannelName.charAt(0);
1717
+			final char first = sChannelName.charAt(0);
1718 1718
 			return first == '#' || first == '&' || first == '!' || first == '+';
1719 1719
 		}
1720 1720
 		// Otherwise return true if:
@@ -1886,8 +1886,8 @@ public class IRCParser implements Runnable {
1886 1886
 				setPingNeeded(true);
1887 1887
 				pingCountDown = pingCountDownLength;
1888 1888
 				callPingSent();
1889
-				lastPingValue = ""+System.currentTimeMillis();
1890
-				sendLine("PING "+lastPingValue);
1889
+				lastPingValue = String.valueOf(System.currentTimeMillis());
1890
+				sendLine("PING " + lastPingValue);
1891 1891
 			}
1892 1892
 		}
1893 1893
 	}

+ 6
- 6
src/com/dmdirc/parser/MyInfo.java Näytä tiedosto

@@ -59,16 +59,16 @@ public final class MyInfo {
59 59
 		} catch (SecurityException e) {
60 60
 			result = null;
61 61
 		}
62
-		if (result != null && !result.isEmpty()) {
63
-			nickname = result;
64
-			username = nickname;
65
-			realname = nickname+" - DMDIrc";
66
-			altNickname = nickname+"-";
67
-		} else {
62
+		if (result == null || result.isEmpty()) {
68 63
 			nickname = "IRCParser";
69 64
 			username = "IRCParser";
70 65
 			realname = "DMDIrc IRCParser";
71 66
 			altNickname = "IRC-Parser";
67
+		} else {
68
+			nickname = result;
69
+			username = nickname;
70
+			realname = nickname+" - DMDIrc";
71
+			altNickname = nickname+"-";
72 72
 		}
73 73
 	}
74 74
 	

+ 2
- 2
src/com/dmdirc/parser/Process001.java Näytä tiedosto

@@ -36,7 +36,7 @@ public class Process001 extends IRCProcessor {
36 36
 	 * @param sParam Type of line to process ("001")
37 37
 	 * @param token IRCTokenised line to process
38 38
 	 */
39
-	public void process(String sParam, String[] token) {
39
+	public void process(final String sParam, final String[] token) {
40 40
 		myParser.got001 = true;
41 41
 		// << :demon1.uk.quakenet.org 001 Java-Test :Welcome to the QuakeNet IRC Network, Java-Test
42 42
 		String sNick;
@@ -67,7 +67,7 @@ public class Process001 extends IRCProcessor {
67 67
          * @return true if a method was called, false otherwise
68 68
 	 */	
69 69
 	protected boolean callServerReady() {
70
-		CallbackOnServerReady cb = (CallbackOnServerReady)getCallbackManager().getCallbackType("OnServerReady");
70
+		final CallbackOnServerReady cb = (CallbackOnServerReady)getCallbackManager().getCallbackType("OnServerReady");
71 71
 		if (cb != null) { return cb.call(); }
72 72
 		return false;
73 73
 	}

+ 10
- 21
src/com/dmdirc/parser/Process004005.java Näytä tiedosto

@@ -36,7 +36,7 @@ public class Process004005 extends IRCProcessor {
36 36
 	 * @param sParam Type of line to process ("005", "004")
37 37
 	 * @param token IRCTokenised line to process
38 38
 	 */
39
-	public void process(String sParam, String[] token) {
39
+	public void process(final String sParam, final String[] token) {
40 40
 		if (sParam.equals("003")) {
41 41
 			myParser.h005Info.put("003IRCD",token[token.length-1]);
42 42
 		} else if (sParam.equals("004")) {
@@ -67,25 +67,14 @@ public class Process004005 extends IRCProcessor {
67 67
 					} else if (!sValue.equalsIgnoreCase("rfc1459")) {
68 68
 						myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Unknown casemapping: '"+sValue+"' - assuming rfc1459", myParser.getLastLine()));
69 69
 					}
70
-					boolean limitChanged = (myParser.getLastLimit() != limit);
70
+					final boolean limitChanged = (myParser.getLastLimit() != limit);
71 71
 					myParser.updateCharArrays(limit);
72
-					if (limitChanged) {
73
-						if (myParser.knownClients() == 1) {
72
+					if (limitChanged && myParser.knownClients() == 1) {
74 73
 							// This means that the casemapping is not rfc1459
75 74
 							// We have only added ourselves so far (from 001)
76 75
 							// We can fix the hashtable easily.
77
-							myParser.removeClient(myParser.getMyself());
78
-							myParser.addClient(myParser.getMyself());
79
-						} else if (myParser.knownClients() > 1) {
80
-							// If this happens then something buggered up.
81
-							// joining channels before 005, when the encoding is not rfc1459
82
-							// myParser.callErrorInfo(new ParserError(ParserError.ERROR_ERROR, "Casemapping has changed since we have seen other users!", myParser.getLastLine()));
83
-						}
84
-						if (myParser.knownChannels() > 0) {
85
-							// If this happens then something buggered up.
86
-							// joining channels before 005, when the encoding is not rfc1459
87
-							// myParser.callErrorInfo(new ParserError(ParserError.ERROR_ERROR, "Casemapping has changed since we joined channels!", myParser.getLastLine()));
88
-						}
76
+						myParser.removeClient(myParser.getMyself());
77
+						myParser.addClient(myParser.getMyself());
89 78
 					}
90 79
 				} else if (sKey.equals("CHANTYPES")) {
91 80
 					myParser.parseChanPrefix();
@@ -129,11 +118,11 @@ public class Process004005 extends IRCProcessor {
129 118
          * @return true if a method was called, false otherwise
130 119
 	 */
131 120
 	protected boolean callGotNetwork() {
132
-		String networkName = myParser.sNetworkName;
133
-		String ircdVersion = myParser.getIRCD(false);
134
-		String ircdType = myParser.getIRCD(true);
121
+		final String networkName = myParser.sNetworkName;
122
+		final String ircdVersion = myParser.getIRCD(false);
123
+		final String ircdType = myParser.getIRCD(true);
135 124
 		
136
-		CallbackOnGotNetwork cb = (CallbackOnGotNetwork)getCallbackManager().getCallbackType("OnGotNetwork");
125
+		final CallbackOnGotNetwork cb = (CallbackOnGotNetwork)getCallbackManager().getCallbackType("OnGotNetwork");
137 126
 		if (cb != null) { return cb.call(networkName, ircdVersion, ircdType); }
138 127
 		return false;
139 128
 	}
@@ -144,6 +133,6 @@ public class Process004005 extends IRCProcessor {
144 133
 	 * @param parser IRCParser That owns this IRCProcessor
145 134
 	 * @param manager ProcessingManager that is in charge of this IRCProcessor
146 135
 	 */
147
-	protected Process004005 (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
136
+	protected Process004005 (final IRCParser parser, final ProcessingManager manager) { super(parser, manager); }
148 137
 
149 138
 }

+ 1
- 1
src/com/dmdirc/parser/ProcessNames.java Näytä tiedosto

@@ -62,7 +62,7 @@ public class ProcessNames extends IRCProcessor {
62 62
 			if (iChannel == null) { return; }
63 63
 			
64 64
 			// If we are not expecting names, clear the current known names - this is fresh stuff!
65
-			if (!iChannel.getAddingNames()) { iChannel.emptyChannel(); }
65
+			if (!iChannel.isAddingNames()) { iChannel.emptyChannel(); }
66 66
 			iChannel.setAddingNames(true);
67 67
 			
68 68
 			String[] sNames = token[token.length-1].split(" ");

Loading…
Peruuta
Tallenna