Ver código fonte

Fix PMD bugs in parser.

Change-Id: Ifd55c3c04740aa88f349aae5abee7fa817b82e39
Reviewed-on: http://gerrit.dmdirc.com/1692
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.5
Greg Holmes 13 anos atrás
pai
commit
83e12d6517
68 arquivos alterados com 697 adições e 542 exclusões
  1. 3
    3
      src/com/dmdirc/parser/common/AwayState.java
  2. 3
    3
      src/com/dmdirc/parser/common/CallbackManager.java
  3. 5
    5
      src/com/dmdirc/parser/common/CallbackNotFoundException.java
  4. 7
    7
      src/com/dmdirc/parser/common/CallbackObject.java
  5. 4
    4
      src/com/dmdirc/parser/common/CallbackObjectSpecific.java
  6. 9
    9
      src/com/dmdirc/parser/common/ChannelListModeItem.java
  7. 3
    3
      src/com/dmdirc/parser/common/DefaultStringConverter.java
  8. 2
    2
      src/com/dmdirc/parser/common/MyInfo.java
  9. 18
    18
      src/com/dmdirc/parser/common/ParserError.java
  10. 3
    3
      src/com/dmdirc/parser/common/QueuePriority.java
  11. 1
    1
      src/com/dmdirc/parser/interfaces/ChannelClientInfo.java
  12. 1
    1
      src/com/dmdirc/parser/interfaces/ClientInfo.java
  13. 4
    4
      src/com/dmdirc/parser/interfaces/Parser.java
  14. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelJoinListener.java
  15. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelModeChangeListener.java
  16. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelNickChangeListener.java
  17. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelNonUserModeChangeListener.java
  18. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelPartListener.java
  19. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelSelfJoinListener.java
  20. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelTopicListener.java
  21. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ChannelUserModeChangeListener.java
  22. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/ErrorInfoListener.java
  23. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/PrivateMessageListener.java
  24. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/QuitListener.java
  25. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/UserModeChangeListener.java
  26. 1
    1
      src/com/dmdirc/parser/interfaces/callbacks/UserModeDiscoveryListener.java
  27. 13
    10
      src/com/dmdirc/parser/irc/IRCAuthenticator.java
  28. 1
    1
      src/com/dmdirc/parser/irc/IRCCallbackManager.java
  29. 16
    5
      src/com/dmdirc/parser/irc/IRCCallbackObject.java
  30. 2
    2
      src/com/dmdirc/parser/irc/IRCCallbackObjectSpecific.java
  31. 1
    1
      src/com/dmdirc/parser/irc/IRCChannelClientInfo.java
  32. 29
    20
      src/com/dmdirc/parser/irc/IRCChannelInfo.java
  33. 9
    6
      src/com/dmdirc/parser/irc/IRCClientInfo.java
  34. 20
    5
      src/com/dmdirc/parser/irc/IRCParserException.java
  35. 18
    18
      src/com/dmdirc/parser/irc/IRCProcessor.java
  36. 10
    7
      src/com/dmdirc/parser/irc/IRCStringConverter.java
  37. 6
    6
      src/com/dmdirc/parser/irc/Logging.java
  38. 2
    1
      src/com/dmdirc/parser/irc/PingTimer.java
  39. 3
    1
      src/com/dmdirc/parser/irc/Process001.java
  40. 12
    12
      src/com/dmdirc/parser/irc/Process004005.java
  41. 8
    6
      src/com/dmdirc/parser/irc/Process464.java
  42. 14
    10
      src/com/dmdirc/parser/irc/ProcessAway.java
  43. 7
    5
      src/com/dmdirc/parser/irc/ProcessInvite.java
  44. 23
    20
      src/com/dmdirc/parser/irc/ProcessJoin.java
  45. 16
    12
      src/com/dmdirc/parser/irc/ProcessKick.java
  46. 47
    34
      src/com/dmdirc/parser/irc/ProcessListModes.java
  47. 16
    14
      src/com/dmdirc/parser/irc/ProcessMOTD.java
  48. 25
    23
      src/com/dmdirc/parser/irc/ProcessMessage.java
  49. 95
    56
      src/com/dmdirc/parser/irc/ProcessMode.java
  50. 21
    19
      src/com/dmdirc/parser/irc/ProcessNames.java
  51. 42
    41
      src/com/dmdirc/parser/irc/ProcessNick.java
  52. 5
    5
      src/com/dmdirc/parser/irc/ProcessNickInUse.java
  53. 5
    5
      src/com/dmdirc/parser/irc/ProcessNoticeAuth.java
  54. 12
    10
      src/com/dmdirc/parser/irc/ProcessPart.java
  55. 14
    12
      src/com/dmdirc/parser/irc/ProcessQuit.java
  56. 12
    8
      src/com/dmdirc/parser/irc/ProcessTopic.java
  57. 13
    11
      src/com/dmdirc/parser/irc/ProcessWallops.java
  58. 12
    10
      src/com/dmdirc/parser/irc/ProcessWho.java
  59. 9
    9
      src/com/dmdirc/parser/irc/ProcessingManager.java
  60. 1
    1
      src/com/dmdirc/parser/irc/ProcessorNotFoundException.java
  61. 17
    7
      src/com/dmdirc/parser/irc/ServerInfo.java
  62. 2
    2
      src/com/dmdirc/parser/irc/ServerType.java
  63. 4
    9
      src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java
  64. 6
    6
      src/com/dmdirc/parser/irc/outputqueue/PriorityQueueHandler.java
  65. 19
    2
      src/com/dmdirc/parser/irc/outputqueue/QueueFactory.java
  66. 6
    6
      src/com/dmdirc/parser/irc/outputqueue/QueueHandler.java
  67. 13
    13
      src/com/dmdirc/parser/irc/outputqueue/QueueItem.java
  68. 15
    15
      src/com/dmdirc/parser/irc/outputqueue/SimpleRateLimitedQueueHandler.java

+ 3
- 3
src/com/dmdirc/parser/common/AwayState.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

+ 3
- 3
src/com/dmdirc/parser/common/CallbackManager.java Ver arquivo

@@ -69,7 +69,7 @@ public abstract class CallbackManager<T extends Parser> {
69 69
         WallDesyncListener.class, WallopListener.class, WalluserListener.class,
70 70
         ServerNoticeListener.class, UnknownServerNoticeListener.class,
71 71
     };
72
-    
72
+
73 73
     /** Hashtable used to store the different types of callback known. */
74 74
     private final Map<Class<? extends CallbackInterface>, CallbackObject> callbackHash
75 75
             = new HashMap<Class<? extends CallbackInterface>, CallbackObject>();
@@ -88,7 +88,7 @@ public abstract class CallbackManager<T extends Parser> {
88 88
      *
89 89
      * @param parser The parser associated with this CallbackManager
90 90
      */
91
-    protected void initialise(T parser) {
91
+    protected void initialise(final T parser) {
92 92
         for (Class<?> type : CLASSES) {
93 93
             if (type.isAnnotationPresent(SpecificCallback.class)) {
94 94
                 addCallbackType(getSpecificCallbackObject(parser, type));
@@ -229,7 +229,7 @@ public abstract class CallbackManager<T extends Parser> {
229 229
         if (o == null) {
230 230
             throw new NullPointerException("CallbackInterface is null");
231 231
         }
232
-        
232
+
233 233
         ((CallbackObjectSpecific) getCallbackType(callback)).add(o, target);
234 234
     }
235 235
 

+ 5
- 5
src/com/dmdirc/parser/common/CallbackNotFoundException.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  * of this software and associated documentation files (the "Software"), to deal
6 6
  * in the Software without restriction, including without limitation the rights
7 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  * copies of the Software, and to permit persons to whom the Software is
9 9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  * The above copyright notice and this permission notice shall be included in
12 12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,7 +24,7 @@ package com.dmdirc.parser.common;
24 24
 
25 25
 /**
26 26
  * IRC Parser Callback Exception.
27
- * 
27
+ *
28 28
  * @author Shane Mc Cormack
29 29
  */
30 30
 public class CallbackNotFoundException extends RuntimeException {
@@ -37,7 +37,7 @@ public class CallbackNotFoundException extends RuntimeException {
37 37
 
38 38
     /**
39 39
      * Create a new CallbackNotFound Exception.
40
-     * 
40
+     *
41 41
      * @param message Reason for exception
42 42
      */
43 43
     public CallbackNotFoundException(final String message) {

+ 7
- 7
src/com/dmdirc/parser/common/CallbackObject.java Ver arquivo

@@ -178,7 +178,7 @@ public abstract class CallbackObject {
178 178
             }
179 179
             bResult = true;
180 180
         }
181
-        
181
+
182 182
         return bResult;
183 183
     }
184 184
 
@@ -227,7 +227,7 @@ public abstract class CallbackObject {
227 227
         for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
228 228
             for (Annotation ann : anns) {
229 229
                 if (ann.annotationType().equals(FakableSource.class)) {
230
-                    Class<?> argType = type.getMethods()[0].getParameterTypes()[i];
230
+                    final Class<?> argType = type.getMethods()[0].getParameterTypes()[i];
231 231
 
232 232
                     sources.put(argType, args[i]);
233 233
                 }
@@ -258,10 +258,10 @@ public abstract class CallbackObject {
258 258
                 if (!found) {
259 259
                     param = getFakeArg(args, needed);
260 260
 
261
-                    if (param != null) {
262
-                        params[i] = param;
263
-                    } else {
261
+                    if (param == null) {
264 262
                         failed = true;
263
+                    } else {
264
+                        params[i] = param;
265 265
                     }
266 266
                 }
267 267
 
@@ -305,6 +305,6 @@ public abstract class CallbackObject {
305 305
      * @param type The type to be instansiated
306 306
      * @return A concrete implementation of that type
307 307
      */
308
-    protected abstract Class<?> getImplementation(Class<?> type);
309
-    
308
+    protected abstract Class<?> getImplementation(final Class<?> type);
309
+
310 310
 }

+ 4
- 4
src/com/dmdirc/parser/common/CallbackObjectSpecific.java Ver arquivo

@@ -147,14 +147,14 @@ public abstract class CallbackObjectSpecific extends CallbackObject {
147 147
         createFakeArgs(newArgs);
148 148
 
149 149
         for (CallbackInterface iface : new ArrayList<CallbackInterface>(callbackInfo)) {
150
-            if (type.isAnnotationPresent(SpecificCallback.class) &&
151
-                    ((args[0] instanceof ClientInfo
150
+            if (type.isAnnotationPresent(SpecificCallback.class)
151
+                    && ((args[0] instanceof ClientInfo
152 152
                     && !isValidUser(iface, ((ClientInfo) args[0]).getHostname()))
153 153
                     || (args[0] instanceof ChannelInfo
154 154
                     && !isValidChan(iface, (ChannelInfo) args[0]))
155 155
                     || (!(args[0] instanceof ClientInfo
156
-                    || args[0] instanceof ChannelInfo) &&
157
-                    args[args.length - 1] instanceof String
156
+                    || args[0] instanceof ChannelInfo)
157
+                    && args[args.length - 1] instanceof String
158 158
                     && !isValidUser(iface, (String) args[args.length - 1])))) {
159 159
                 continue;
160 160
             }

+ 9
- 9
src/com/dmdirc/parser/common/ChannelListModeItem.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  * of this software and associated documentation files (the "Software"), to deal
6 6
  * in the Software without restriction, including without limitation the rights
7 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  * copies of the Software, and to permit persons to whom the Software is
9 9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  * The above copyright notice and this permission notice shall be included in
12 12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,7 +24,7 @@ package com.dmdirc.parser.common;
24 24
 
25 25
 /**
26 26
  * Contains Channel List Mode information.
27
- * 
27
+ *
28 28
  * @author Shane Mc Cormack
29 29
  * @author Chris Smith
30 30
  * @see IRCParser
@@ -42,7 +42,7 @@ public final class ChannelListModeItem {
42 42
 
43 43
     /**
44 44
      * Create a new Item.
45
-     * 
45
+     *
46 46
      * @param item The item (ie: test!joe@user.com)
47 47
      * @param owner The owner (ie: Dataforce)
48 48
      * @param time The Time (ie: 1173389295)
@@ -60,7 +60,7 @@ public final class ChannelListModeItem {
60 60
 
61 61
     /**
62 62
      * Get The Item itself.
63
-     * 
63
+     *
64 64
      * @return The Item itself.
65 65
      */
66 66
     public String getItem() {
@@ -69,7 +69,7 @@ public final class ChannelListModeItem {
69 69
 
70 70
     /**
71 71
      * Get The Person who created the item.
72
-     * 
72
+     *
73 73
      * @return The Person who created the item.
74 74
      */
75 75
     public String getOwner() {
@@ -78,7 +78,7 @@ public final class ChannelListModeItem {
78 78
 
79 79
     /**
80 80
      * Get The Time the item was created.
81
-     * 
81
+     *
82 82
      * @return The Time the item was created.
83 83
      */
84 84
     public long getTime() {
@@ -87,7 +87,7 @@ public final class ChannelListModeItem {
87 87
 
88 88
     /**
89 89
      * Returns a String representation of this object.
90
-     * 
90
+     *
91 91
      * @return String representation of this object
92 92
      */
93 93
     @Override

+ 3
- 3
src/com/dmdirc/parser/common/DefaultStringConverter.java Ver arquivo

@@ -34,19 +34,19 @@ public class DefaultStringConverter implements StringConverter {
34 34
 
35 35
     /** {@inheritDoc} */
36 36
     @Override
37
-    public String toLowerCase(String input) {
37
+    public String toLowerCase(final String input) {
38 38
         return input.toLowerCase();
39 39
     }
40 40
 
41 41
     /** {@inheritDoc} */
42 42
     @Override
43
-    public String toUpperCase(String input) {
43
+    public String toUpperCase(final String input) {
44 44
         return input.toUpperCase();
45 45
     }
46 46
 
47 47
     /** {@inheritDoc} */
48 48
     @Override
49
-    public boolean equalsIgnoreCase(String first, String second) {
49
+    public boolean equalsIgnoreCase(final String first, final String second) {
50 50
         return first.equalsIgnoreCase(second);
51 51
     }
52 52
 

+ 2
- 2
src/com/dmdirc/parser/common/MyInfo.java Ver arquivo

@@ -46,10 +46,10 @@ public class MyInfo {
46 46
      */
47 47
     private String altNickname;
48 48
 
49
-    /** Realname string to use */
49
+    /** Realname string to use. */
50 50
     private String realname;
51 51
 
52
-    /** Username to use, this doesn't matter when an ident server is running */
52
+    /** Username to use, this doesn't matter when an ident server is running. */
53 53
     private String username;
54 54
 
55 55
     /**

+ 18
- 18
src/com/dmdirc/parser/common/ParserError.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  * of this software and associated documentation files (the "Software"), to deal
6 6
  * in the Software without restriction, including without limitation the rights
7 7
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  * copies of the Software, and to permit persons to whom the Software is
9 9
  * furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  * The above copyright notice and this permission notice shall be included in
12 12
  * all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,7 +24,7 @@ package com.dmdirc.parser.common;
24 24
 
25 25
 /**
26 26
  * IRC Parser Error.
27
- * 
27
+ *
28 28
  * @author Shane Mc Cormack
29 29
  */
30 30
 public final class ParserError {
@@ -47,11 +47,11 @@ public final class ParserError {
47 47
     private Exception exceptionInfo;
48 48
 
49 49
     /** Last line of server input before this exception was triggered. */
50
-    private String lastLine = "";
50
+    private final String lastLine;
51 51
 
52 52
     /**
53 53
      * Create a new Error.
54
-     * 
54
+     *
55 55
      * @param level Set the error level.
56 56
      * @param data String containing information about the error.
57 57
      * @param line The last line of data recieved from the server before this
@@ -65,7 +65,7 @@ public final class ParserError {
65 65
 
66 66
     /**
67 67
      * Check if this error is considered Fatal.
68
-     * 
68
+     *
69 69
      * @return Returns true for a fatal error, false for a non-fatal error
70 70
      */
71 71
     public boolean isFatal() {
@@ -75,7 +75,7 @@ public final class ParserError {
75 75
     /**
76 76
      * Check if this error is considered an error (less severe than fatal, worse
77 77
      * than warning).
78
-     * 
78
+     *
79 79
      * @return Returns true for an "Error" level error, else false.
80 80
      */
81 81
     public boolean isError() {
@@ -84,7 +84,7 @@ public final class ParserError {
84 84
 
85 85
     /**
86 86
      * Check if this error is considered a warning.
87
-     * 
87
+     *
88 88
      * @return Returns true for a warning, else false.
89 89
      */
90 90
     public boolean isWarning() {
@@ -94,7 +94,7 @@ public final class ParserError {
94 94
     /**
95 95
      * Check if this error is considered a user-error rather than a server error.
96 96
      * For DMDirc this will cause the error not to be reported to the developers
97
-     * 
97
+     *
98 98
      * @return Returns true for a user error, else false.
99 99
      */
100 100
     public boolean isUserError() {
@@ -103,7 +103,7 @@ public final class ParserError {
103 103
 
104 104
     /**
105 105
      * Check if this error was generated from an exception.
106
-     * 
106
+     *
107 107
      * @return Returns true if getException will return an exception.
108 108
      */
109 109
     public boolean isException() {
@@ -112,7 +112,7 @@ public final class ParserError {
112 112
 
113 113
     /**
114 114
      * Check if this error has a lastLine parameter.
115
-     * 
115
+     *
116 116
      * @return Returns true if getLastLine returns anything non null, non empty.
117 117
      */
118 118
     public boolean hasLastLine() {
@@ -121,7 +121,7 @@ public final class ParserError {
121 121
 
122 122
     /**
123 123
      * Set the Exception object.
124
-     * 
124
+     *
125 125
      * @param newException The exception object to store
126 126
      */
127 127
     public void setException(final Exception newException) {
@@ -133,7 +133,7 @@ public final class ParserError {
133 133
 
134 134
     /**
135 135
      * Get the Exception object.
136
-     * 
136
+     *
137 137
      * @return Returns the exception object
138 138
      */
139 139
     public Exception getException() {
@@ -142,7 +142,7 @@ public final class ParserError {
142 142
 
143 143
     /**
144 144
      * Get the full ErrorLevel.
145
-     * 
145
+     *
146 146
      * @return Returns the error level
147 147
      */
148 148
     public int getLevel() {
@@ -151,7 +151,7 @@ public final class ParserError {
151 151
 
152 152
     /**
153 153
      * Get the Error information.
154
-     * 
154
+     *
155 155
      * @return Returns the error data
156 156
      */
157 157
     public String getData() {
@@ -160,7 +160,7 @@ public final class ParserError {
160 160
 
161 161
     /**
162 162
      * Add to the error information.
163
-     * 
163
+     *
164 164
      * @param data Information to add to the end of the existing Data
165 165
      */
166 166
     public void appendData(final String data) {
@@ -169,7 +169,7 @@ public final class ParserError {
169 169
 
170 170
     /**
171 171
      * Get the last line recieved from the server before this exception.
172
-     * 
172
+     *
173 173
      * @return Returns the error data
174 174
      */
175 175
     public String getLastLine() {

+ 3
- 3
src/com/dmdirc/parser/common/QueuePriority.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

+ 1
- 1
src/com/dmdirc/parser/interfaces/ChannelClientInfo.java Ver arquivo

@@ -36,7 +36,7 @@ public interface ChannelClientInfo extends Comparable<ChannelClientInfo> {
36 36
     /**
37 37
      * Retrieves the {@link ClientInfo} object which this object corresponds
38 38
      * to.
39
-     * 
39
+     *
40 40
      * @return The client info object which this object represents
41 41
      */
42 42
     ClientInfo getClient();

+ 1
- 1
src/com/dmdirc/parser/interfaces/ClientInfo.java Ver arquivo

@@ -82,5 +82,5 @@ public interface ClientInfo {
82 82
      * @return This ClientInfo's parser
83 83
      */
84 84
     Parser getParser();
85
-    
85
+
86 86
 }

+ 4
- 4
src/com/dmdirc/parser/interfaces/Parser.java Ver arquivo

@@ -88,14 +88,14 @@ public interface Parser extends Runnable {
88 88
     Collection<? extends ChannelInfo> getChannels();
89 89
 
90 90
     /**
91
-     * Get the IP address that this parser will bind to
91
+     * Get the IP address that this parser will bind to.
92 92
      *
93 93
      * @return IP that this parser is bound to ("" for default IP)
94 94
      */
95 95
     String getBindIP();
96 96
 
97 97
     /**
98
-     * Set the IP address that this parser will bind to
98
+     * Set the IP address that this parser will bind to.
99 99
      *
100 100
      * @param ip IP to bind to
101 101
      */
@@ -227,14 +227,14 @@ public interface Parser extends Runnable {
227 227
     String getServerSoftware();
228 228
 
229 229
     /**
230
-     * Retrieves the detected type of the software running on the server
230
+     * Retrieves the detected type of the software running on the server.
231 231
      *
232 232
      * @return This parser's server's software type
233 233
      */
234 234
     String getServerSoftwareType();
235 235
 
236 236
     /**
237
-     * Get the list of lines that lines that help describe the server
237
+     * Get the list of lines that lines that help describe the server.
238 238
      *
239 239
      * @return List of identification lines for the server.
240 240
      *

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelJoinListener.java Ver arquivo

@@ -29,7 +29,7 @@ import com.dmdirc.parser.interfaces.SpecificCallback;
29 29
 
30 30
 import java.util.Date;
31 31
 
32
-/** 
32
+/**
33 33
  * Called When we, or another client joins a channel.
34 34
  * This is called AFTER client has been added to channel as a ChannelClientInfo
35 35
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelModeChangeListener.java Ver arquivo

@@ -31,7 +31,7 @@ import com.dmdirc.parser.interfaces.SpecificCallback;
31 31
 
32 32
 import java.util.Date;
33 33
 
34
-/** 
34
+/**
35 35
  * Called when the channel modes are changed or discovered.
36 36
  * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
37 37
  * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelNickChangeListener.java Ver arquivo

@@ -29,7 +29,7 @@ import com.dmdirc.parser.interfaces.SpecificCallback;
29 29
 
30 30
 import java.util.Date;
31 31
 
32
-/** 
32
+/**
33 33
  * Called when we or another user change nickname (Called once per channel the user is on).
34 34
  * This is called after the nickname change has been done internally
35 35
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelNonUserModeChangeListener.java Ver arquivo

@@ -31,7 +31,7 @@ import com.dmdirc.parser.interfaces.SpecificCallback;
31 31
 
32 32
 import java.util.Date;
33 33
 
34
-/** 
34
+/**
35 35
  * Called when the channel modes are changed or discovered.
36 36
  * cChannelClient is null if the modes were found from raw 324 (/MODE #Chan reply) or if a server set the mode.<br>
37 37
  * If a Server set the mode, sHost is the servers name, else it is the full host of the user who set it

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelPartListener.java Ver arquivo

@@ -28,7 +28,7 @@ import com.dmdirc.parser.interfaces.Parser;
28 28
 import com.dmdirc.parser.interfaces.SpecificCallback;
29 29
 import java.util.Date;
30 30
 
31
-/** 
31
+/**
32 32
  * Called When we, or another client parts a channel.
33 33
  * This is called BEFORE client has been removed from the channel.
34 34
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelSelfJoinListener.java Ver arquivo

@@ -27,7 +27,7 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
-/** 
30
+/**
31 31
  * Called When we join a channel.
32 32
  * We are NOT added as a channelclient until after the names reply
33 33
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelTopicListener.java Ver arquivo

@@ -27,7 +27,7 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 import com.dmdirc.parser.interfaces.SpecificCallback;
28 28
 import java.util.Date;
29 29
 
30
-/** 
30
+/**
31 31
  * Called when the topic is changed or discovered for the first time.
32 32
  * bIsNewTopic is true if someone sets the topic, false if the topic is discovered on join
33 33
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ChannelUserModeChangeListener.java Ver arquivo

@@ -31,7 +31,7 @@ import com.dmdirc.parser.interfaces.SpecificCallback;
31 31
 
32 32
 import java.util.Date;
33 33
 
34
-/** 
34
+/**
35 35
  * Called when a users channel mode is changed.
36 36
  */
37 37
 @SpecificCallback

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/ErrorInfoListener.java Ver arquivo

@@ -41,5 +41,5 @@ public interface ErrorInfoListener extends CallbackInterface {
41 41
      * @see com.dmdirc.parser.irc.IRCParser#callErrorInfo
42 42
      */
43 43
     void onErrorInfo(Parser parser, Date date, ParserError errorInfo);
44
-    
44
+
45 45
 }

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/PrivateMessageListener.java Ver arquivo

@@ -28,7 +28,7 @@ import com.dmdirc.parser.interfaces.SpecificCallback;
28 28
 import java.util.Date;
29 29
 
30 30
 /**
31
- * Called when a person sends a message to you directly (PM). 
31
+ * Called when a person sends a message to you directly (PM).
32 32
  * sHost is the hostname of the person sending the message. (Can be a server or a person)<br>
33 33
  * cClient is null if user is a server, or not on any common channel.
34 34
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/QuitListener.java Ver arquivo

@@ -27,7 +27,7 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
-/** 
30
+/**
31 31
  * Called When we, or another client quits IRC (Called once in total).
32 32
  * This is called BEFORE client has been removed from the channel.
33 33
  */

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/UserModeChangeListener.java Ver arquivo

@@ -27,7 +27,7 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
-/** 
30
+/**
31 31
  * Called when user modes are changed.
32 32
  * cClient represents the user who's modes were changed (should ALWAYS be us)<br>
33 33
  * sSetby is the host of the person who set the mode (usually us, may be an oper or server in some cases)

+ 1
- 1
src/com/dmdirc/parser/interfaces/callbacks/UserModeDiscoveryListener.java Ver arquivo

@@ -27,7 +27,7 @@ import com.dmdirc.parser.interfaces.Parser;
27 27
 
28 28
 import java.util.Date;
29 29
 
30
-/** 
30
+/**
31 31
  * Called when user modes are Discovered.
32 32
  * cClient represents the user who's modes were Discovered (should ALWAYS be us)<br>
33 33
  * sSetby is the host of the person who set the mode (usually us, may be an oper or server in some cases)

+ 13
- 10
src/com/dmdirc/parser/irc/IRCAuthenticator.java Ver arquivo

@@ -32,11 +32,12 @@ import java.util.concurrent.Semaphore;
32 32
 
33 33
 /**
34 34
  * Handles proxy authentication for the parser.
35
- * 
35
+ *
36 36
  * @author Shane Mc Cormack
37 37
  * @see IRCParser
38 38
  */
39
-public class IRCAuthenticator extends Authenticator {
39
+public final class IRCAuthenticator extends Authenticator {
40
+
40 41
     /**
41 42
      * A version number for this class. It should be changed whenever the class
42 43
      * structure is changed (or anything else that would prevent serialized
@@ -46,7 +47,7 @@ public class IRCAuthenticator extends Authenticator {
46 47
 
47 48
     /** Singleton instance of IRCAuthenticator. */
48 49
     private static IRCAuthenticator me = null;
49
-    
50
+
50 51
     /** List of authentication replies. */
51 52
     private final Map<String, PasswordAuthentication> replies = new HashMap<String, PasswordAuthentication>();
52 53
 
@@ -63,9 +64,11 @@ public class IRCAuthenticator extends Authenticator {
63 64
      * Authenticator.
64 65
      */
65 66
     private IRCAuthenticator() {
67
+        super();
68
+
66 69
         Authenticator.setDefault(this);
67 70
     }
68
-    
71
+
69 72
     /**
70 73
      * Get the instance of IRCAuthenticator.
71 74
      *
@@ -93,9 +96,9 @@ public class IRCAuthenticator extends Authenticator {
93 96
         final String password = server.getProxyPass();
94 97
 
95 98
         if (username == null || password == null || username.isEmpty() || password.isEmpty()) { return; }
96
-        
99
+
97 100
         final PasswordAuthentication pass = new PasswordAuthentication(username, password.toCharArray());
98
-        final String fullhost = host.toLowerCase()+":"+port;
101
+        final String fullhost = host.toLowerCase() + ":" + port;
99 102
 
100 103
         // Delete old username/password if one exists and then add the new one
101 104
         replies.remove(fullhost);
@@ -109,7 +112,7 @@ public class IRCAuthenticator extends Authenticator {
109 112
     }
110 113
 
111 114
     /**
112
-     * Get a copy of the semaphore
115
+     * Get a copy of the semaphore.
113 116
      *
114 117
      * @return the IRCAuthenticator semaphore.
115 118
      */
@@ -126,7 +129,7 @@ public class IRCAuthenticator extends Authenticator {
126 129
         final String host = server.getProxyHost();
127 130
         final int port = server.getProxyPort();
128 131
 
129
-        final String fullhost = host.toLowerCase()+":"+port;
132
+        final String fullhost = host.toLowerCase() + ":" + port;
130 133
 
131 134
         // See if any other servers are associated with this proxy.
132 135
         final List<ServerInfo> servers = owners.containsKey(fullhost) ? owners.get(fullhost) : new ArrayList<ServerInfo>();
@@ -137,7 +140,7 @@ public class IRCAuthenticator extends Authenticator {
137 140
             replies.remove(fullhost);
138 141
         }
139 142
     }
140
-    
143
+
141 144
     /** {@inheritDoc} */
142 145
     @Override
143 146
     protected PasswordAuthentication getPasswordAuthentication() {
@@ -152,7 +155,7 @@ public class IRCAuthenticator extends Authenticator {
152 155
          * getRequestorType: SERVER
153 156
          */
154 157
 
155
-        final String fullhost = getRequestingHost().toLowerCase()+":"+getRequestingPort();
158
+        final String fullhost = getRequestingHost().toLowerCase() + ":" + getRequestingPort();
156 159
         return replies.get(fullhost);
157 160
     }
158 161
 }

+ 1
- 1
src/com/dmdirc/parser/irc/IRCCallbackManager.java Ver arquivo

@@ -29,7 +29,7 @@ import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
29 29
 
30 30
 /**
31 31
  * Handles callbacks for the IRC Parser.
32
- * 
32
+ *
33 33
  * @author chris
34 34
  */
35 35
 public class IRCCallbackManager extends CallbackManager<IRCParser> {

+ 16
- 5
src/com/dmdirc/parser/irc/IRCCallbackObject.java Ver arquivo

@@ -41,8 +41,11 @@ import java.util.Map;
41 41
  */
42 42
 public class IRCCallbackObject extends CallbackObject {
43 43
 
44
-    /** A map of interfaces to the classes which should be instansiated for them. */
45
-    protected static final Map<Class<?>, Class<?>> IMPL_MAP = new HashMap<Class<?>, Class<?>>();
44
+    /**
45
+     * A map of interfaces to the classes which should be instansiated for them.
46
+     */
47
+    protected static final Map<Class<?>, Class<?>> IMPL_MAP
48
+            = new HashMap<Class<?>, Class<?>>();
46 49
 
47 50
     static {
48 51
         IMPL_MAP.put(ChannelClientInfo.class, IRCChannelClientInfo.class);
@@ -51,14 +54,22 @@ public class IRCCallbackObject extends CallbackObject {
51 54
         IMPL_MAP.put(LocalClientInfo.class, IRCClientInfo.class);
52 55
     }
53 56
 
54
-    public IRCCallbackObject(Parser parser, CallbackManager<?> manager,
55
-            Class<? extends CallbackInterface> type) {
57
+    /**
58
+     * Creates a new IRC parser callback object.
59
+     *
60
+     * @param parser Parser this callback is owned by
61
+     * @param manager Manager callback is owned by
62
+     * @param type Callback type
63
+     */
64
+    public IRCCallbackObject(final Parser parser,
65
+            final CallbackManager<?> manager,
66
+            final Class<? extends CallbackInterface> type) {
56 67
         super(parser, manager, type);
57 68
     }
58 69
 
59 70
     /** {@inheritDoc} */
60 71
     @Override
61
-    protected Class<?> getImplementation(Class<?> type) {
72
+    protected Class<?> getImplementation(final Class<?> type) {
62 73
         return IMPL_MAP.containsKey(type) ? IMPL_MAP.get(type) : type;
63 74
     }
64 75
 

+ 2
- 2
src/com/dmdirc/parser/irc/IRCCallbackObjectSpecific.java Ver arquivo

@@ -34,7 +34,7 @@ import java.util.HashMap;
34 34
 import java.util.Map;
35 35
 
36 36
 /**
37
- * A specific callback object for use with the IRC Parser
37
+ * A specific callback object for use with the IRC Parser.
38 38
  *
39 39
  * @since 0.6.3m2
40 40
  * @author chris
@@ -64,7 +64,7 @@ public class IRCCallbackObjectSpecific extends CallbackObjectSpecific {
64 64
 
65 65
     /** {@inheritDoc} */
66 66
     @Override
67
-    protected Class<?> getImplementation(Class<?> type) {
67
+    protected Class<?> getImplementation(final Class<?> type) {
68 68
         return IMPL_MAP.containsKey(type) ? IMPL_MAP.get(type) : type;
69 69
     }
70 70
 

+ 1
- 1
src/com/dmdirc/parser/irc/IRCChannelClientInfo.java Ver arquivo

@@ -44,7 +44,7 @@ public class IRCChannelClientInfo implements ChannelClientInfo {
44 44
     private final IRCParser myParser;
45 45
     /** Reference to the channel object that owns this channelclient. */
46 46
     private final ChannelInfo myChannel;
47
-    /** A Map to allow applications to attach misc data to this object */
47
+    /** A Map to allow applications to attach misc data to this object. */
48 48
     private Map<Object, Object> myMap;
49 49
 
50 50
     /**

+ 29
- 20
src/com/dmdirc/parser/irc/IRCChannelInfo.java Ver arquivo

@@ -86,12 +86,12 @@ public class IRCChannelInfo implements ChannelInfo {
86 86
     private final List<Character> lAddingModes = new LinkedList<Character>();
87 87
     /** Modes waiting to be sent to the server. */
88 88
     private final List<String> lModeQueue = new LinkedList<String>();
89
-    /** A Map to allow applications to attach misc data to this object */
89
+    /** A Map to allow applications to attach misc data to this object. */
90 90
     private Map<Object, Object> myMap;
91 91
 
92
-    /** Queue of requested list modes */
92
+    /** Queue of requested list modes. */
93 93
     private final Queue<Character> listModeQueue = new LinkedList<Character>();
94
-    /** Listmode Queue Time */
94
+    /** Listmode Queue Time. */
95 95
     private long listModeQueueTime = System.currentTimeMillis();
96 96
     /** Have we asked the server for the list modes for this channel yet? */
97 97
     private boolean askedForListModes = false;
@@ -120,7 +120,7 @@ public class IRCChannelInfo implements ChannelInfo {
120 120
         final long now = System.currentTimeMillis();
121 121
         // Incase of breakage, if getListModeQueue() was last called greater than
122 122
         // 60 seconds ago, we reset the list.
123
-        if (now-(30*1000) > listModeQueueTime) {
123
+        if (now - (30 * 1000) > listModeQueueTime) {
124 124
             result = new LinkedList<Character>();
125 125
             myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "Resetting LMQ");
126 126
         }
@@ -153,7 +153,9 @@ public class IRCChannelInfo implements ChannelInfo {
153 153
         if (serverType != ServerType.UNREAL && serverType != ServerType.IRSEE && myParser.h005Info.containsKey("MODES")) {
154 154
             try {
155 155
                 modecount = Integer.parseInt(myParser.h005Info.get("MODES"));
156
-            } catch (NumberFormatException e) { /* use default modecount */}
156
+            } catch (NumberFormatException e) {
157
+                 modecount = 1;
158
+            }
157 159
         }
158 160
 
159 161
         // Support for potential future decent mode listing in the protocol
@@ -177,7 +179,7 @@ public class IRCChannelInfo implements ChannelInfo {
177 179
                 i++;
178 180
                 listmodes = listmodes + cTemp;
179 181
                 if (i >= modecount && !supportLISTMODE) {
180
-                    myParser.sendString("MODE "+getName()+" "+listmodes, QueuePriority.LOW);
182
+                    myParser.sendString("MODE " + getName() + " " + listmodes, QueuePriority.LOW);
181 183
                     i = 0;
182 184
                     listmodes = "";
183 185
                 }
@@ -185,9 +187,9 @@ public class IRCChannelInfo implements ChannelInfo {
185 187
         }
186 188
         if (i > 0) {
187 189
             if (supportLISTMODE) {
188
-                myParser.sendString("LISTMODE "+getName()+" "+listmodes, QueuePriority.LOW);
190
+                myParser.sendString("LISTMODE " + getName() + " " + listmodes, QueuePriority.LOW);
189 191
             } else {
190
-                myParser.sendString("MODE "+getName()+" "+listmodes, QueuePriority.LOW);
192
+                myParser.sendString("MODE " + getName() + " " + listmodes, QueuePriority.LOW);
191 193
             }
192 194
         }
193 195
     }
@@ -276,7 +278,7 @@ public class IRCChannelInfo implements ChannelInfo {
276 278
     /** {@inheritDoc} */
277 279
         @Override
278 280
     public Collection<ChannelClientInfo> getChannelClients() {
279
-        synchronized(hChannelUserList) {
281
+        synchronized (hChannelUserList) {
280 282
             return new ArrayList<ChannelClientInfo>(hChannelUserList.values());
281 283
         }
282 284
     }
@@ -312,7 +314,7 @@ public class IRCChannelInfo implements ChannelInfo {
312 314
             return hChannelUserList.get(who);
313 315
         }
314 316
         if (create) {
315
-            return new IRCChannelClientInfo(myParser, (new IRCClientInfo(myParser, client)).setFake(true), this);
317
+            return new IRCChannelClientInfo(myParser, new IRCClientInfo(myParser, client).setFake(true), this);
316 318
         } else {
317 319
             return null;
318 320
         }
@@ -352,7 +354,7 @@ public class IRCChannelInfo implements ChannelInfo {
352 354
      * @param cClient Client object to be removed from channel
353 355
      */
354 356
     protected void delClient(final IRCClientInfo cClient) {
355
-        IRCChannelClientInfo cTemp = getChannelClient(cClient);
357
+        final IRCChannelClientInfo cTemp = getChannelClient(cClient);
356 358
         if (cTemp != null) {
357 359
             final IRCClientInfo clTemp = cTemp.getClient();
358 360
             clTemp.delChannelClientInfo(cTemp);
@@ -522,8 +524,9 @@ public class IRCChannelInfo implements ChannelInfo {
522 524
         final ArrayList<ChannelListModeItem> lModes = hListModes.get(cMode);
523 525
         for (int i = 0; i < lModes.size(); i++) {
524 526
             if (myParser.getStringConverter().equalsIgnoreCase(lModes.get(i).getItem(), newItem.getItem())) {
525
-                if (bAdd) { return; }
526
-                else {
527
+                if (bAdd) {
528
+                    return;
529
+                } else {
527 530
                     lModes.remove(i);
528 531
                     break;
529 532
                 }
@@ -634,7 +637,7 @@ public class IRCChannelInfo implements ChannelInfo {
634 637
                     modestr = modestr + " " + parameter;
635 638
                 }
636 639
             } else {
637
-                myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Trying to alter unknown mode.  positive: '"+add+"' | mode: '"+mode+"' | parameter: '"+parameter+"' ", ""));
640
+                myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Trying to alter unknown mode.  positive: '" + add + "' | mode: '" + mode + "' | parameter: '" + parameter + "' ", ""));
638 641
             }
639 642
         }
640 643
         myParser.callDebugInfo(IRCParser.DEBUG_INFO, "Queueing mode: %s", modestr);
@@ -714,11 +717,14 @@ public class IRCChannelInfo implements ChannelInfo {
714 717
      * @param sType Type of CTCP
715 718
      * @param sMessage Optional Additional Parameters
716 719
      */
717
-    public void sendCTCP(final String sType, String sMessage) {
720
+    public void sendCTCP(final String sType, final String sMessage) {
718 721
         if (sType.isEmpty()) { return; }
719 722
         final char char1 = (char) 1;
720
-        if (!sMessage.isEmpty()) { sMessage = " " + sMessage; }
721
-        sendMessage(char1 + sType.toUpperCase() + sMessage + char1);
723
+        if (sMessage.isEmpty()) {
724
+            sendMessage(char1 + sType.toUpperCase() + sMessage + char1);
725
+        } else {
726
+            sendMessage(char1 + sType.toUpperCase() + " " + sMessage + char1);
727
+        }
722 728
     }
723 729
 
724 730
     /**
@@ -727,11 +733,14 @@ public class IRCChannelInfo implements ChannelInfo {
727 733
      * @param sType Type of CTCP
728 734
      * @param sMessage Optional Additional Parameters
729 735
      */
730
-    public void sendCTCPReply(final String sType, String sMessage) {
736
+    public void sendCTCPReply(final String sType, final String sMessage) {
731 737
         if (sType.isEmpty()) { return; }
732 738
         final char char1 = (char) 1;
733
-        if (!sMessage.isEmpty()) { sMessage = " " + sMessage; }
734
-        sendNotice(char1 + sType.toUpperCase() + sMessage + char1);
739
+        if (sMessage.isEmpty()) {
740
+            sendNotice(char1 + sType.toUpperCase() + sMessage + char1);
741
+        } else {
742
+            sendNotice(char1 + sType.toUpperCase() + " " + sMessage + char1);
743
+        }
735 744
     }
736 745
 
737 746
     /**

+ 9
- 6
src/com/dmdirc/parser/irc/IRCClientInfo.java Ver arquivo

@@ -58,9 +58,9 @@ public class IRCClientInfo implements LocalClientInfo {
58 58
     private boolean bIsFake;
59 59
     /** Reference to the parser object that owns this channel, Used for modes. */
60 60
     private final IRCParser myParser;
61
-    /** A Map to allow applications to attach misc data to this object */
61
+    /** A Map to allow applications to attach misc data to this object. */
62 62
     private Map<Object, Object> myMap;
63
-    /** List of ChannelClientInfos that point to this */
63
+    /** List of ChannelClientInfos that point to this. */
64 64
     private final Map<String, IRCChannelClientInfo> myChannelClientInfos = new HashMap<String, IRCChannelClientInfo>();
65 65
     /** Modes waiting to be sent to the server. */
66 66
     private final List<String> lModeQueue = new LinkedList<String>();
@@ -133,11 +133,14 @@ public class IRCClientInfo implements LocalClientInfo {
133 133
      * @param sWho Hostname to parse
134 134
      * @return Array containing details. (result[0] -> Nick | result[1] -> Ident | result[2] -> Host)
135 135
      */
136
-    public static String[] parseHostFull(String sWho) {
136
+    public static String[] parseHostFull(final String sWho) {
137 137
         String[] sTemp = null;
138 138
         final String[] result = new String[3];
139
-        if (!sWho.isEmpty() && sWho.charAt(0) == ':') { sWho = sWho.substring(1); }
140
-        sTemp = sWho.split("@", 2);
139
+        if (!sWho.isEmpty() && sWho.charAt(0) == ':') {
140
+            sTemp = sWho.substring(1).split("@", 2);
141
+        } else {
142
+            sTemp = sWho.split("@", 2);
143
+        }
141 144
         if (sTemp.length == 1) { result[2] = ""; } else { result[2] = sTemp[1]; }
142 145
         sTemp = sTemp[0].split("!", 2);
143 146
         if (sTemp.length == 1) { result[1] = ""; } else { result[1] = sTemp[1]; }
@@ -415,7 +418,7 @@ public class IRCClientInfo implements LocalClientInfo {
415 418
 
416 419
     /** {@inheritDoc} */
417 420
     @Override
418
-    public void setAway(String reason) {
421
+    public void setAway(final String reason) {
419 422
         myParser.sendRawMessage("AWAY :" + reason);
420 423
     }
421 424
 

+ 20
- 5
src/com/dmdirc/parser/irc/IRCParserException.java Ver arquivo

@@ -1,14 +1,29 @@
1 1
 /*
2
- * To change this template, choose Tools | Templates
3
- * and open the template in the editor.
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
4 21
  */
5 22
 
6 23
 package com.dmdirc.parser.irc;
7 24
 
8 25
 /**
9 26
  * IRC Parser Exception!
10
- *
11
- * @author shane
12 27
  */
13 28
 class IRCParserException extends Exception {
14 29
 
@@ -16,7 +31,7 @@ class IRCParserException extends Exception {
16 31
     private static final long serialVersionUID = 1L;
17 32
 
18 33
     /**
19
-     * Create a new IRCParserException
34
+     * Create a new IRCParserException.
20 35
      *
21 36
      * @param message Reason for exception
22 37
      */

+ 18
- 18
src/com/dmdirc/parser/irc/IRCProcessor.java Ver arquivo

@@ -32,10 +32,10 @@ import com.dmdirc.parser.common.QueuePriority;
32 32
  *
33 33
  * @author Shane Mc Cormack
34 34
  */
35
-abstract class IRCProcessor {
35
+public abstract class IRCProcessor {
36 36
     /** Reference to the IRCParser that owns this IRCProcessor. */
37 37
     protected IRCParser myParser;
38
-    
38
+
39 39
     /** Reference to the Processing in charge of this IRCProcessor. */
40 40
     protected ProcessingManager myManager;
41 41
 
@@ -62,7 +62,7 @@ abstract class IRCProcessor {
62 62
     protected final boolean callErrorInfo(final ParserError errorInfo) {
63 63
         return myParser.callErrorInfo(errorInfo);
64 64
     }
65
-    
65
+
66 66
     /**
67 67
      * Callback to all objects implementing the DebugInfo Callback.
68 68
      *
@@ -75,7 +75,7 @@ abstract class IRCProcessor {
75 75
     protected final boolean callDebugInfo(final int level, final String data, final Object... args) {
76 76
         return myParser.callDebugInfo(level, String.format(data, args));
77 77
     }
78
-    
78
+
79 79
     /**
80 80
      * Callback to all objects implementing the DebugInfo Callback.
81 81
      *
@@ -87,7 +87,7 @@ abstract class IRCProcessor {
87 87
     protected final boolean callDebugInfo(final int level, final String data) {
88 88
         return myParser.callDebugInfo(level, data);
89 89
     }
90
-    
90
+
91 91
     /**
92 92
      * Check if a channel name is valid .
93 93
      *
@@ -97,7 +97,7 @@ abstract class IRCProcessor {
97 97
     protected final boolean isValidChannelName(final String sChannelName) {
98 98
         return myParser.isValidChannelName(sChannelName);
99 99
     }
100
-    
100
+
101 101
     /**
102 102
      * Get the ClientInfo object for a person.
103 103
      *
@@ -107,7 +107,7 @@ abstract class IRCProcessor {
107 107
     protected final IRCClientInfo getClientInfo(final String sWho) {
108 108
         return myParser.isKnownClient(sWho) ? myParser.getClient(sWho) : null;
109 109
     }
110
-    
110
+
111 111
     /**
112 112
      * Get the ChannelInfo object for a channel.
113 113
      *
@@ -117,7 +117,7 @@ abstract class IRCProcessor {
117 117
     protected final IRCChannelInfo getChannel(final String name) {
118 118
         return myParser.getChannel(name);
119 119
     }
120
-    
120
+
121 121
     /**
122 122
      * Get a reference to the CallbackManager.
123 123
      *
@@ -126,7 +126,7 @@ abstract class IRCProcessor {
126 126
     protected final CallbackManager<?> getCallbackManager() {
127 127
         return myParser.getCallbackManager();
128 128
     }
129
-    
129
+
130 130
     /**
131 131
      * Send a line to the server and add proper line ending.
132 132
      *
@@ -145,7 +145,7 @@ abstract class IRCProcessor {
145 145
     protected final void sendString(final String line, final QueuePriority priority) {
146 146
         myParser.sendString(line, priority);
147 147
     }
148
-    
148
+
149 149
     /**
150 150
      * Process a Line.
151 151
      *
@@ -153,15 +153,15 @@ abstract class IRCProcessor {
153 153
      * @param token IRCTokenised line to process
154 154
      */
155 155
     public abstract void process(final String sParam, final String[] token);
156
-    
156
+
157 157
     /**
158 158
      * What does this IRCProcessor handle.
159 159
      *
160 160
      * @return String[] with the names of the tokens we handle.
161 161
      */
162 162
     public abstract String[] handles();
163
-    
164
-    /** 
163
+
164
+    /**
165 165
      * Get the name for this Processor.
166 166
      * @return the name of this processor
167 167
      */
@@ -173,20 +173,20 @@ abstract class IRCProcessor {
173 173
         }
174 174
         return this.getClass().getName().substring(packageLength);
175 175
     }
176
-    
177
-    /** 
176
+
177
+    /**
178 178
      * Get the name for this Processor in lowercase.
179 179
      * @return lower case name of this processor
180 180
      */
181 181
     public final String getLowerName() {
182 182
         return this.getName().toLowerCase();
183 183
     }
184
-    
185
-    /** 
184
+
185
+    /**
186 186
      * Get the name for this Processor.
187 187
      * @return the name of this processor
188 188
      */
189 189
         @Override
190 190
     public final String toString() { return this.getName(); }
191
-    
191
+
192 192
 }

+ 10
- 7
src/com/dmdirc/parser/irc/IRCStringConverter.java Ver arquivo

@@ -30,12 +30,12 @@ import com.dmdirc.parser.interfaces.StringConverter;
30 30
  * @author Shane Mc Cormack
31 31
  */
32 32
 public class IRCStringConverter implements StringConverter {
33
-    
33
+
34 34
     /** Characters to use when converting tolowercase. */
35 35
     private final char[] lowercase;
36 36
     /** Characters to use when converting touppercase. */
37 37
     private final char[] uppercase;
38
-    /** limit */
38
+    /** limit. */
39 39
     private final byte limit;
40 40
 
41 41
     /**
@@ -44,7 +44,7 @@ public class IRCStringConverter implements StringConverter {
44 44
     public IRCStringConverter() {
45 45
         this((byte) 4);
46 46
     }
47
-    
47
+
48 48
     /**
49 49
      * Create a new IRCStringConverter.
50 50
      * @param limit Number of post-alphabetical characters to convert
@@ -54,9 +54,12 @@ public class IRCStringConverter implements StringConverter {
54 54
      */
55 55
     public IRCStringConverter(final byte limit) {
56 56
         // If limit is out side the boundries, use rfc1459
57
-        if (limit > 4 || limit < 0) { this.limit = (byte) 4; }
58
-        else { this.limit = limit; }
59
-        
57
+        if (limit > 4 || limit < 0) {
58
+            this.limit = (byte) 4;
59
+        } else {
60
+            this.limit = limit;
61
+        }
62
+
60 63
         lowercase = new char[127];
61 64
         uppercase = new char[127];
62 65
         // Normal Chars
@@ -78,7 +81,7 @@ public class IRCStringConverter implements StringConverter {
78 81
      * @return last used chararray limit
79 82
      */
80 83
     protected int getLimit() { return limit; }
81
-    
84
+
82 85
     /** {@inheritDoc} */
83 86
         @Override
84 87
     public String toLowerCase(final String input) {

+ 6
- 6
src/com/dmdirc/parser/irc/Logging.java Ver arquivo

@@ -29,7 +29,7 @@ import java.lang.reflect.Method;
29 29
  * Logging using log4j if available.
30 30
  */
31 31
 public class Logging {
32
-    /** Available Log Levels */
32
+    /** Available Log Levels. */
33 33
     public enum LogLevel {
34 34
         TRACE("trace", "isTraceEnabled"),
35 35
         DEBUG("debug", "isDebugEnabled"),
@@ -38,14 +38,14 @@ public class Logging {
38 38
         ERROR("error", "isErrorEnabled"),
39 39
         FATAL("fatal", "isFatalEnabled");
40 40
 
41
-        /** Method name */
41
+        /** Method name. */
42 42
         private final String methodName;
43 43
 
44
-        /** Check Method name */
44
+        /** Check Method name. */
45 45
         private final String checkMethodName;
46 46
 
47 47
         /**
48
-         * Create a new LogLevel
48
+         * Create a new LogLevel.
49 49
          *
50 50
          * @param methodName Name of method in log4j to log to
51 51
          * @param checkMethodName Name of method in log4j to sue to check logging
@@ -56,14 +56,14 @@ public class Logging {
56 56
         }
57 57
 
58 58
         /**
59
-         * Get the Name of method in log4j to log to
59
+         * Get the Name of method in log4j to log to.
60 60
          *
61 61
          * @return Name of method in log4j to log to
62 62
          */
63 63
         public String getMethodName() { return methodName; }
64 64
 
65 65
         /**
66
-         * Get the Name of the check method in log4j
66
+         * Get the Name of the check method in log4j.
67 67
          *
68 68
          * @return Name of check method in log4j
69 69
          */

+ 2
- 1
src/com/dmdirc/parser/irc/PingTimer.java Ver arquivo

@@ -34,7 +34,7 @@ import java.util.TimerTask;
34 34
 public class PingTimer extends TimerTask {
35 35
     /** Owning Parser. */
36 36
     final IRCParser myOwner;
37
-    /** The Timer that owns this task */
37
+    /** The Timer that owns this task. */
38 38
     final Timer myTimer;
39 39
     
40 40
     /**
@@ -44,6 +44,7 @@ public class PingTimer extends TimerTask {
44 44
      * @param timer Timer that owns this TimerTask.
45 45
      */
46 46
     public PingTimer(final IRCParser control, final Timer timer) {
47
+        super();
47 48
         myOwner = control;
48 49
         myTimer = timer;
49 50
     }

+ 3
- 1
src/com/dmdirc/parser/irc/Process001.java Ver arquivo

@@ -101,6 +101,8 @@ public class Process001 extends IRCProcessor {
101 101
      * @param parser IRCParser That owns this IRCProcessor
102 102
      * @param manager ProcessingManager that is in charge of this IRCProcessor
103 103
      */
104
-    protected Process001(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
104
+    protected Process001(final IRCParser parser, final ProcessingManager manager) {
105
+        super(parser, manager);
106
+    }
105 107
 
106 108
 }

+ 12
- 12
src/com/dmdirc/parser/irc/Process004005.java Ver arquivo

@@ -47,13 +47,13 @@ public class Process004005 extends IRCProcessor {
47 47
                 myParser.h005Info.put("002IRCD", matcher.group(1));
48 48
             }
49 49
         } else if (sParam.equals("003")) {
50
-            myParser.h005Info.put("003IRCD", token[token.length-1]);
50
+            myParser.h005Info.put("003IRCD", token[token.length - 1]);
51 51
         } else if (sParam.equals("004")) {
52 52
             // 004
53 53
             final boolean multiParam = token.length > 4;
54 54
             int i = multiParam ? 4 : 1;
55 55
             final String[] bits = multiParam ? token : token[3].split(" ");
56
-            
56
+
57 57
             myParser.h005Info.put("004IRCD", bits[i++]);
58 58
             // some IRCDs put a timestamp where the usermodes should be
59 59
             // (issues 4140. 4181 and 4183) so check to see if this is numeric
@@ -66,7 +66,7 @@ public class Process004005 extends IRCProcessor {
66 66
         } else if (sParam.equals("005")) {
67 67
             // 005
68 68
             for (int i = 3; i < token.length; i++) {
69
-                String[] bits = token[i].split("=", 2);
69
+                final String[] bits = token[i].split("=", 2);
70 70
                 if (bits[0].isEmpty()) { continue; }
71 71
                 final boolean isNegation = (bits[0].charAt(0) == '-');
72 72
                 final String sKey = (isNegation) ? bits[0].substring(1).toUpperCase() : bits[0].toUpperCase();
@@ -87,7 +87,7 @@ public class Process004005 extends IRCProcessor {
87 87
                     } else if (sValue.equalsIgnoreCase("ascii")) {
88 88
                         limit = (byte) 0;
89 89
                     } else if (!sValue.equalsIgnoreCase("rfc1459")) {
90
-                        myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Unknown casemapping: '"+sValue+"' - assuming rfc1459", myParser.getLastLine()));
90
+                        myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Unknown casemapping: '" + sValue + "' - assuming rfc1459", myParser.getLastLine()));
91 91
                     }
92 92
                     final boolean limitChanged = (myParser.getStringConverter().getLimit() != limit);
93 93
                     myParser.updateCharArrays(limit);
@@ -105,15 +105,15 @@ public class Process004005 extends IRCProcessor {
105 105
                 } else if (sKey.equals("CHANMODES")) {
106 106
                     myParser.parseChanModes();
107 107
                 } else if (sKey.equals("NAMESX") || sKey.equals("UHNAMES")) {
108
-                    myParser.sendString("PROTOCTL "+sKey);
108
+                    myParser.sendString("PROTOCTL " + sKey);
109 109
                 } else if (sKey.equals("LISTMODE")) {
110 110
                     // Support for potential future decent mode listing in the protocol
111
-                    // 
111
+                    //
112 112
                     // See my proposal: http://shanemcc.co.uk/irc/#listmode
113 113
                     // Add listmode handler
114 114
                     String[] handles = new String[2];
115 115
                     handles[0] = sValue; // List mode item
116
-                    final String endValue = ""+(Integer.parseInt(sValue) + 1);
116
+                    final String endValue = "" + (Integer.parseInt(sValue) + 1);
117 117
                     myParser.h005Info.put("LISTMODEEND", endValue);
118 118
                     handles[1] = endValue; // List mode end
119 119
                     // Add listmode handlers
@@ -124,7 +124,7 @@ public class Process004005 extends IRCProcessor {
124 124
             }
125 125
         }
126 126
     }
127
-    
127
+
128 128
     /**
129 129
      * What does this IRCProcessor handle.
130 130
      *
@@ -133,8 +133,8 @@ public class Process004005 extends IRCProcessor {
133 133
     @Override
134 134
     public String[] handles() {
135 135
         return new String[]{"002", "003", "004", "005"};
136
-    } 
137
-    
136
+    }
137
+
138 138
     /**
139 139
      * Callback to all objects implementing the GotNetwork Callback.
140 140
      * This takes no params of its own, but works them out itself.
@@ -146,10 +146,10 @@ public class Process004005 extends IRCProcessor {
146 146
         final String networkName = myParser.networkName;
147 147
         final String ircdVersion = myParser.getServerSoftware();
148 148
         final String ircdType = myParser.getServerSoftwareType();
149
-        
149
+
150 150
         return getCallbackManager().getCallbackType(NetworkDetectedListener.class).call(networkName, ircdVersion, ircdType);
151 151
     }
152
-    
152
+
153 153
     /**
154 154
      * Create a new instance of the IRCProcessor Object.
155 155
      *

+ 8
- 6
src/com/dmdirc/parser/irc/Process464.java Ver arquivo

@@ -35,12 +35,12 @@ public class Process464 extends IRCProcessor {
35 35
      * @param token IRCTokenised line to process
36 36
      */
37 37
     @Override
38
-    public void process(String sParam, String[] token) {
38
+    public void process(final String sParam, final String[] token) {
39 39
         callPasswordRequired();
40 40
 //        ParserError ei = new ParserError(ParserError.ERROR_ERROR, "Password Required");
41 41
 //        callErrorInfo(ei);
42 42
     }
43
-    
43
+
44 44
     /**
45 45
      * What does this IRCProcessor handle.
46 46
      *
@@ -49,8 +49,8 @@ public class Process464 extends IRCProcessor {
49 49
     @Override
50 50
     public String[] handles() {
51 51
         return new String[]{"464"};
52
-    } 
53
-    
52
+    }
53
+
54 54
     /**
55 55
      * Callback to all objects implementing the PasswordRequired Callback.
56 56
      *
@@ -60,13 +60,15 @@ public class Process464 extends IRCProcessor {
60 60
     protected boolean callPasswordRequired() {
61 61
         return getCallbackManager().getCallbackType(PasswordRequiredListener.class).call();
62 62
     }
63
-    
63
+
64 64
     /**
65 65
      * Create a new instance of the IRCProcessor Object.
66 66
      *
67 67
      * @param parser IRCParser That owns this IRCProcessor
68 68
      * @param manager ProcessingManager that is in charge of this IRCProcessor
69 69
      */
70
-    protected Process464(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
70
+    protected Process464(final IRCParser parser, final ProcessingManager manager) {
71
+        super(parser, manager);
72
+    }
71 73
 
72 74
 }

+ 14
- 10
src/com/dmdirc/parser/irc/ProcessAway.java Ver arquivo

@@ -36,17 +36,19 @@ public class ProcessAway extends IRCProcessor {
36 36
      * @param token IRCTokenised line to process
37 37
      */
38 38
     @Override
39
-    public void process(String sParam, String[] token) {
40
-        if (sParam.equals("301")) {
41
-            IRCClientInfo iClient = getClientInfo(token[3]);
42
-            if (iClient != null) { iClient.setAwayReason(token[token.length-1]); }
39
+    public void process(final String sParam, final String[] token) {
40
+        if ("301".equals(sParam)) {
41
+            final IRCClientInfo iClient = getClientInfo(token[3]);
42
+            if (iClient != null) {
43
+                iClient.setAwayReason(token[token.length - 1]);
44
+            }
43 45
         } else {
44 46
             final AwayState oldState = myParser.getLocalClient().getAwayState();
45
-            myParser.getLocalClient().setAwayState(sParam.equals("306") ? AwayState.AWAY : AwayState.HERE);
47
+            myParser.getLocalClient().setAwayState("306".equals(sParam) ? AwayState.AWAY : AwayState.HERE);
46 48
             callAwayState(oldState, myParser.getLocalClient().getAwayState(), myParser.getLocalClient().getAwayReason());
47 49
         }
48 50
     }
49
-    
51
+
50 52
     /**
51 53
      * Callback to all objects implementing the onAwayState Callback.
52 54
      *
@@ -59,7 +61,7 @@ public class ProcessAway extends IRCProcessor {
59 61
     protected boolean callAwayState(final AwayState oldState, final AwayState currentState, final String reason) {
60 62
         return getCallbackManager().getCallbackType(AwayStateListener.class).call(oldState, currentState, reason);
61 63
     }
62
-    
64
+
63 65
     /**
64 66
      * What does this IRCProcessor handle.
65 67
      *
@@ -68,14 +70,16 @@ public class ProcessAway extends IRCProcessor {
68 70
     @Override
69 71
     public String[] handles() {
70 72
         return new String[]{"301", "305", "306"};
71
-    } 
72
-    
73
+    }
74
+
73 75
     /**
74 76
      * Create a new instance of the IRCProcessor Object.
75 77
      *
76 78
      * @param parser IRCParser That owns this IRCProcessor
77 79
      * @param manager ProcessingManager that is in charge of this IRCProcessor
78 80
      */
79
-    protected ProcessAway(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
81
+    protected ProcessAway(final IRCParser parser, final ProcessingManager manager) {
82
+        super(parser, manager);
83
+    }
80 84
 
81 85
 }

+ 7
- 5
src/com/dmdirc/parser/irc/ProcessInvite.java Ver arquivo

@@ -41,7 +41,7 @@ public class ProcessInvite extends IRCProcessor {
41 41
             callInvite(token[0].substring(1), token[3]);
42 42
         }
43 43
     }
44
-    
44
+
45 45
     /**
46 46
      * Callback to all objects implementing the Invite Callback.
47 47
      *
@@ -53,7 +53,7 @@ public class ProcessInvite extends IRCProcessor {
53 53
     protected boolean callInvite(final String userHost, final String channel) {
54 54
         return getCallbackManager().getCallbackType(InviteListener.class).call(userHost, channel);
55 55
     }
56
-    
56
+
57 57
     /**
58 58
      * What does this IRCProcessor handle.
59 59
      *
@@ -62,14 +62,16 @@ public class ProcessInvite extends IRCProcessor {
62 62
     @Override
63 63
     public String[] handles() {
64 64
         return new String[]{"INVITE"};
65
-    } 
66
-    
65
+    }
66
+
67 67
     /**
68 68
      * Create a new instance of the IRCProcessor Object.
69 69
      *
70 70
      * @param parser IRCParser That owns this IRCProcessor
71 71
      * @param manager ProcessingManager that is in charge of this IRCProcessor
72 72
      */
73
-    protected ProcessInvite(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
73
+    protected ProcessInvite(final IRCParser parser, final ProcessingManager manager) {
74
+        super(parser, manager);
75
+    }
74 76
 
75 77
 }

+ 23
- 20
src/com/dmdirc/parser/irc/ProcessJoin.java Ver arquivo

@@ -44,24 +44,25 @@ public class ProcessJoin extends IRCProcessor {
44 44
     public void process(final String sParam, final String[] token) {
45 45
         if (sParam.equals("329")) {
46 46
             if (token.length < 5) { return; }
47
-            IRCChannelInfo iChannel = myParser.getChannel(token[3]);
47
+            final IRCChannelInfo iChannel = myParser.getChannel(token[3]);
48 48
             if (iChannel != null) {
49 49
                 try {
50 50
                     iChannel.setCreateTime(Integer.parseInt(token[4]));
51
-                } catch (NumberFormatException nfe) { /* Oh well, not a normal ircd I guess */ }
51
+                } catch (NumberFormatException nfe) {
52
+                    /* Oh well, not a normal ircd I guess */
53
+                }
52 54
             }
53 55
         } else {
54 56
             // :nick!ident@host JOIN (:)#Channel
55
-            Byte nTemp;
56 57
             if (token.length < 3) { return; }
57 58
             IRCClientInfo iClient;
58 59
             IRCChannelInfo iChannel;
59 60
             IRCChannelClientInfo iChannelClient;
60
-            
61
+
61 62
             iClient = getClientInfo(token[0]);
62
-            iChannel = myParser.getChannel(token[token.length-1]);
63
-            
64
-            if (iClient == null) { 
63
+            iChannel = myParser.getChannel(token[token.length - 1]);
64
+
65
+            if (iClient == null) {
65 66
                 iClient = new IRCClientInfo(myParser, token[0]);
66 67
                 myParser.addClient(iClient);
67 68
             }
@@ -70,13 +71,13 @@ public class ProcessJoin extends IRCProcessor {
70 71
             if (iChannel != null) {
71 72
                 if (iClient == myParser.getLocalClient()) {
72 73
                     try {
73
-                        if (iChannel.getChannelClient(iClient) != null) {
74
+                        if (iChannel.getChannelClient(iClient) == null) {
75
+                            // Otherwise we have a channel known, that we are not in?
76
+                            myParser.callErrorInfo(new ParserError(ParserError.ERROR_FATAL, "Joined known channel that we wern't already on..", myParser.getLastLine()));
77
+                        } else {
74 78
                             // If we are joining a channel we are already on, fake a part from
75 79
                             // the channel internally, and rejoin.
76 80
                             myParser.getProcessingManager().process("PART", token);
77
-                        } else {
78
-                            // Otherwise we have a channel known, that we are not in?
79
-                            myParser.callErrorInfo(new ParserError(ParserError.ERROR_FATAL, "Joined known channel that we wern't already on..", myParser.getLastLine()));
80 81
                         }
81 82
                     } catch (ProcessorNotFoundException e) { }
82 83
                 } else if (iChannel.getChannelClient(iClient) != null) {
@@ -93,16 +94,16 @@ public class ProcessJoin extends IRCProcessor {
93 94
             //if (iClient != myParser.getMyself()) {
94 95
                 // callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got join for channel ("+token[token.length-1]+") that I am not on. [Me: "+myParser.getMyself()+"]", myParser.getLastLine()));
95 96
             //}
96
-            iChannel = new IRCChannelInfo(myParser, token[token.length-1]);
97
+            iChannel = new IRCChannelInfo(myParser, token[token.length - 1]);
97 98
             // Add ourself to the channel, this will be overridden by the NAMES reply
98 99
             iChannel.addClient(iClient);
99 100
             myParser.addChannel(iChannel);
100
-            sendString("MODE "+iChannel.getName(), QueuePriority.LOW);
101
-            
101
+            sendString("MODE " + iChannel.getName(), QueuePriority.LOW);
102
+
102 103
             callChannelSelfJoin(iChannel);
103 104
         }
104 105
     }
105
-    
106
+
106 107
 
107 108
     /**
108 109
      * Callback to all objects implementing the ChannelJoin Callback.
@@ -115,7 +116,7 @@ public class ProcessJoin extends IRCProcessor {
115 116
     protected boolean callChannelJoin(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient) {
116 117
         return getCallbackManager().getCallbackType(ChannelJoinListener.class).call(cChannel, cChannelClient);
117 118
     }
118
-    
119
+
119 120
     /**
120 121
      * Callback to all objects implementing the ChannelSelfJoin Callback.
121 122
      *
@@ -126,7 +127,7 @@ public class ProcessJoin extends IRCProcessor {
126 127
     protected boolean callChannelSelfJoin(final ChannelInfo cChannel) {
127 128
         return getCallbackManager().getCallbackType(ChannelSelfJoinListener.class).call(cChannel);
128 129
     }
129
-    
130
+
130 131
     /**
131 132
      * What does this IRCProcessor handle.
132 133
      *
@@ -135,14 +136,16 @@ public class ProcessJoin extends IRCProcessor {
135 136
     @Override
136 137
     public String[] handles() {
137 138
         return new String[]{"JOIN", "329"};
138
-    } 
139
-    
139
+    }
140
+
140 141
     /**
141 142
      * Create a new instance of the IRCProcessor Object.
142 143
      *
143 144
      * @param parser IRCParser That owns this IRCProcessor
144 145
      * @param manager ProcessingManager that is in charge of this IRCProcessor
145 146
      */
146
-    protected ProcessJoin(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
147
+    protected ProcessJoin(final IRCParser parser, final ProcessingManager manager) {
148
+        super(parser, manager);
149
+    }
147 150
 
148 151
 }

+ 16
- 12
src/com/dmdirc/parser/irc/ProcessKick.java Ver arquivo

@@ -46,26 +46,28 @@ public class ProcessKick extends IRCProcessor {
46 46
         IRCClientInfo iClient;
47 47
         IRCClientInfo iKicker;
48 48
         String sReason = "";
49
-        
49
+
50 50
         iClient = getClientInfo(token[3]);
51 51
         iKicker = getClientInfo(token[0]);
52 52
         iChannel = getChannel(token[2]);
53
-        
53
+
54 54
         if (iClient == null) { return; }
55
-        
55
+
56 56
         if ((IRCParser.ALWAYS_UPDATECLIENT && iKicker != null)
57 57
                 && iKicker.getHostname().isEmpty()) {
58 58
             // To facilitate dmdirc formatter, get user information
59 59
             iKicker.setUserBits(token[0], false);
60 60
         }
61 61
 
62
-        if (iChannel == null) { 
62
+        if (iChannel == null) {
63 63
             if (iClient != myParser.getLocalClient()) {
64
-                callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got kick for channel ("+token[2]+") that I am not on. [User: "+token[3]+"]", myParser.getLastLine()));
64
+                callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got kick for channel (" + token[2] + ") that I am not on. [User: " + token[3] + "]", myParser.getLastLine()));
65 65
             }
66 66
             return;
67 67
         } else {
68
-            if (token.length > 4) { sReason = token[token.length-1]; }
68
+            if (token.length > 4) {
69
+                sReason = token[token.length - 1];
70
+            }
69 71
             iChannelClient = iChannel.getChannelClient(iClient);
70 72
             if (iChannelClient == null) {
71 73
                 // callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got kick for channel ("+token[2]+") for a non-existant user. [User: "+token[0]+"]", myParser.getLastLine()));
@@ -81,7 +83,7 @@ public class ProcessKick extends IRCProcessor {
81 83
             }
82 84
         }
83 85
     }
84
-    
86
+
85 87
     /**
86 88
      * Callback to all objects implementing the ChannelKick Callback.
87 89
      *
@@ -93,10 +95,10 @@ public class ProcessKick extends IRCProcessor {
93 95
      * @param sKickedByHost Hostname of Kicker (or servername)
94 96
      * @return true if a method was called, false otherwise
95 97
      */
96
-    protected boolean callChannelKick(ChannelInfo cChannel, ChannelClientInfo cKickedClient, ChannelClientInfo cKickedByClient, String sReason, String sKickedByHost) {
98
+    protected boolean callChannelKick(final ChannelInfo cChannel, final ChannelClientInfo cKickedClient, final ChannelClientInfo cKickedByClient, final String sReason, final String sKickedByHost) {
97 99
         return getCallbackManager().getCallbackType(ChannelKickListener.class).call(cChannel, cKickedClient, cKickedByClient, sReason, sKickedByHost);
98 100
     }
99
-    
101
+
100 102
     /**
101 103
      * What does this IRCProcessor handle.
102 104
      *
@@ -105,14 +107,16 @@ public class ProcessKick extends IRCProcessor {
105 107
     @Override
106 108
     public String[] handles() {
107 109
         return new String[]{"KICK"};
108
-    } 
109
-    
110
+    }
111
+
110 112
     /**
111 113
      * Create a new instance of the IRCProcessor Object.
112 114
      *
113 115
      * @param parser IRCParser That owns this IRCProcessor
114 116
      * @param manager ProcessingManager that is in charge of this IRCProcessor
115 117
      */
116
-    protected ProcessKick(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
118
+    protected ProcessKick(final IRCParser parser, final ProcessingManager manager) {
119
+        super(parser, manager);
120
+    }
117 121
 
118 122
 }

+ 47
- 34
src/com/dmdirc/parser/irc/ProcessListModes.java Ver arquivo

@@ -42,8 +42,8 @@ public class ProcessListModes extends IRCProcessor {
42 42
      */
43 43
     @SuppressWarnings("unchecked")
44 44
     @Override
45
-    public void process(String sParam, String[] token) {
46
-        IRCChannelInfo channel = getChannel(token[3]);
45
+    public void process(final String sParam, final String[] token) {
46
+        final IRCChannelInfo channel = getChannel(token[3]);
47 47
         final ServerType serverType = myParser.getServerType();
48 48
         String item = "";
49 49
         String owner = "";
@@ -53,7 +53,7 @@ public class ProcessListModes extends IRCProcessor {
53 53
         char mode = 'b';
54 54
         boolean isItem = true; // true if item listing, false if "end of .." item
55 55
         if (channel == null) { return; }
56
-        
56
+
57 57
         if (sParam.equals("367") || sParam.equals("368")) {
58 58
             // Ban List/Item.
59 59
             // (Also used for +d and +q on dancer/hyperion... -_-)
@@ -99,27 +99,27 @@ public class ProcessListModes extends IRCProcessor {
99 99
             tokenStart = 5;
100 100
             isCleverMode = true;
101 101
         }
102
-        
102
+
103 103
         final Queue<Character> listModeQueue = channel.getListModeQueue();
104 104
         if (!isCleverMode && listModeQueue != null) {
105 105
             if (sParam.equals("482")) {
106
-                myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "Dropped LMQ mode "+listModeQueue.poll());
106
+                myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "Dropped LMQ mode " + listModeQueue.poll());
107 107
                 return;
108 108
             } else {
109 109
                 if (listModeQueue.peek() != null) {
110
-                    Character oldMode = mode;
110
+                    final Character oldMode = mode;
111 111
                     mode = listModeQueue.peek();
112
-                    myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ says this is "+mode);
113
-                    
112
+                    myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ says this is " + mode);
113
+
114 114
                     boolean error = true;
115
-                    
115
+
116 116
                     // b or q are given in the same list, d is separate.
117 117
                     // b and q remove each other from the LMQ.
118 118
                     //
119 119
                     // Only raise an LMQ error if the lmqmode isn't one of bdq if the
120 120
                     // guess is one of bdq
121 121
                     if (ServerTypeGroup.FREENODE.isMember(serverType) && (mode == 'b' || mode == 'q' || mode == 'd')) {
122
-                        LinkedList<Character> lmq = (LinkedList<Character>) listModeQueue;
122
+                        final LinkedList<Character> lmq = (LinkedList<Character>) listModeQueue;
123 123
                         if (mode == 'b') {
124 124
                             error = !(oldMode == 'q' || oldMode == 'd');
125 125
                             lmq.remove((Character) 'q');
@@ -142,47 +142,50 @@ public class ProcessListModes extends IRCProcessor {
142 142
                     // freenode-specific hacks above think the mode should be
143 143
                     // something else, error.
144 144
                     if (oldMode != mode && error) {
145
-                        myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ disagrees with guess. LMQ: "+mode+" Guess: "+oldMode);
145
+                        myParser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ disagrees with guess. LMQ: " + mode + " Guess: " + oldMode);
146 146
 //                        myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "LMQ disagrees with guess. LMQ: "+mode+" Guess: "+oldMode, myParser.getLastLine()));
147 147
                     }
148
-                    
148
+
149 149
                     if (!isItem) {
150 150
                         listModeQueue.poll();
151 151
                     }
152 152
                 }
153 153
             }
154 154
         }
155
-        
155
+
156 156
         if (isItem) {
157 157
             if ((!isCleverMode) && listModeQueue == null && ServerTypeGroup.FREENODE.isMember(serverType) && token.length > 4 && mode == 'b') {
158 158
                 // Assume mode is a 'd' mode
159 159
                 mode = 'd';
160 160
                 // Now work out if its not (or attempt to.)
161
-                int identstart = token[tokenStart].indexOf('!');
162
-                int hoststart = token[tokenStart].indexOf('@');
161
+                final int identstart = token[tokenStart].indexOf('!');
162
+                final int hoststart = token[tokenStart].indexOf('@');
163 163
                 // Check that ! and @ are both in the string - as required by +b and +q
164 164
                 if ((identstart >= 0) && (identstart < hoststart)) {
165
-                    if (serverType == ServerType.HYPERION && token[tokenStart].charAt(0) == '%') { mode = 'q'; }
166
-                    else { mode = 'b'; }
165
+                    if (serverType == ServerType.HYPERION && token[tokenStart].charAt(0) == '%') {
166
+                        mode = 'q';
167
+                    } else {
168
+                        mode = 'b';
169
+                    }
167 170
                 }
168 171
             } // End Hyperian stupidness of using the same numeric for 3 different things..
169
-            
172
+
170 173
             if (!channel.getAddState(mode)) {
171
-                callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch ("+mode+"): Clearing!");
174
+                callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch (" + mode + "): Clearing!");
172 175
                 final Collection<ChannelListModeItem> list = channel.getListMode(mode);
173 176
                 if (list == null) {
174
-                    myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got list mode: '"+mode+"' - but channel object doesn't agree.", myParser.getLastLine()));
177
+                    myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got list mode: '" + mode + "' - but channel object doesn't agree.", myParser.getLastLine()));
175 178
                 } else {
176 179
                     list.clear();
177 180
                     if (ServerTypeGroup.FREENODE.isMember(serverType) && (mode == 'b' || mode == 'q')) {
178 181
                         // Also clear the other list if b or q.
179 182
                         final Character otherMode = (mode == 'b') ? 'q' : 'b';
180
-                        
183
+
181 184
                         if (!channel.getAddState(otherMode)) {
182
-                            callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch ("+mode+"): Clearing!");
185
+                            callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch (" + mode + "): Clearing!");
183 186
                             final Collection<ChannelListModeItem> otherList = channel.getListMode(otherMode);
184 187
                             if (otherList == null) {
185
-                                myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got list mode: '"+otherMode+"' - but channel object doesn't agree.", myParser.getLastLine()));
188
+                                myParser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got list mode: '" + otherMode + "' - but channel object doesn't agree.", myParser.getLastLine()));
186 189
                             } else {
187 190
                                 otherList.clear();
188 191
                             }
@@ -191,14 +194,22 @@ public class ProcessListModes extends IRCProcessor {
191 194
                 }
192 195
                 channel.setAddState(mode, true);
193 196
             }
194
-            
195
-            if (token.length > (tokenStart+2)) {
196
-                try { time = Long.parseLong(token[tokenStart+2]); } catch (NumberFormatException e) { time = 0; }
197
+
198
+            if (token.length > (tokenStart + 2)) {
199
+                try {
200
+                    time = Long.parseLong(token[tokenStart + 2]);
201
+                } catch (NumberFormatException e) {
202
+                    time = 0;
203
+                }
204
+            }
205
+            if (token.length > (tokenStart + 1)) {
206
+                owner = token[tokenStart + 1];
207
+            }
208
+            if (token.length > tokenStart) {
209
+                item = token[tokenStart];
197 210
             }
198
-            if (token.length > (tokenStart+1)) { owner = token[tokenStart+1]; }
199
-            if (token.length > tokenStart) { item = token[tokenStart]; }
200 211
             if (!item.isEmpty()) {
201
-                ChannelListModeItem clmi = new ChannelListModeItem(item, owner, time);
212
+                final ChannelListModeItem clmi = new ChannelListModeItem(item, owner, time);
202 213
                 callDebugInfo(IRCParser.DEBUG_INFO, "List Mode: %c [%s/%s/%d]", mode, item, owner, time);
203 214
                 channel.setListModeParam(mode, clmi, true);
204 215
             }
@@ -221,7 +232,7 @@ public class ProcessListModes extends IRCProcessor {
221 232
             }
222 233
         }
223 234
     }
224
-    
235
+
225 236
     /**
226 237
      * What does this IRCProcessor handle.
227 238
      *
@@ -240,7 +251,7 @@ public class ProcessListModes extends IRCProcessor {
240 251
                             "__LISTMODE__" /* Sensible List Modes */
241 252
                            };
242 253
     }
243
-    
254
+
244 255
     /**
245 256
      * Callback to all objects implementing the ChannelGotListModes Callback.
246 257
      *
@@ -249,16 +260,18 @@ public class ProcessListModes extends IRCProcessor {
249 260
      * @param mode the mode that we got list modes for.
250 261
      * @return true if a method was called, false otherwise
251 262
      */
252
-    protected boolean callChannelGotListModes(ChannelInfo cChannel, final char mode) {
263
+    protected boolean callChannelGotListModes(final ChannelInfo cChannel, final char mode) {
253 264
         return getCallbackManager().getCallbackType(ChannelListModeListener.class).call(cChannel, mode);
254 265
     }
255
-    
266
+
256 267
     /**
257 268
      * Create a new instance of the IRCProcessor Object.
258 269
      *
259 270
      * @param parser IRCParser That owns this IRCProcessor
260 271
      * @param manager ProcessingManager that is in charge of this IRCProcessor
261 272
      */
262
-    protected ProcessListModes(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
273
+    protected ProcessListModes(final IRCParser parser, final ProcessingManager manager) {
274
+        super(parser, manager);
275
+    }
263 276
 
264 277
 }

+ 16
- 14
src/com/dmdirc/parser/irc/ProcessMOTD.java Ver arquivo

@@ -38,16 +38,16 @@ public class ProcessMOTD extends IRCProcessor {
38 38
      * @param token IRCTokenised line to process
39 39
      */
40 40
     @Override
41
-    public void process(String sParam, String[] token) {
42
-        if (sParam.equals("375")) {
43
-            callMOTDStart(token[token.length-1]);
44
-        } else if (sParam.equals("372")) {
45
-            callMOTDLine(token[token.length-1]);
41
+    public void process(final String sParam, final String[] token) {
42
+        if ("375".equals(sParam)) {
43
+            callMOTDStart(token[token.length - 1]);
44
+        } else if ("372".equals(sParam)) {
45
+            callMOTDLine(token[token.length - 1]);
46 46
         } else {
47
-            callMOTDEnd(sParam.equals("422"), token[token.length-1]);
47
+            callMOTDEnd("422".equals(sParam), token[token.length - 1]);
48 48
         }
49 49
     }
50
-    
50
+
51 51
     /**
52 52
      * Callback to all objects implementing the MOTDEnd Callback.
53 53
      *
@@ -59,7 +59,7 @@ public class ProcessMOTD extends IRCProcessor {
59 59
     protected boolean callMOTDEnd(final boolean noMOTD, final String data) {
60 60
         return getCallbackManager().getCallbackType(MotdEndListener.class).call(noMOTD, data);
61 61
     }
62
-    
62
+
63 63
     /**
64 64
      * Callback to all objects implementing the MOTDLine Callback.
65 65
      *
@@ -70,7 +70,7 @@ public class ProcessMOTD extends IRCProcessor {
70 70
     protected boolean callMOTDLine(final String data) {
71 71
         return getCallbackManager().getCallbackType(MotdLineListener.class).call(data);
72 72
     }
73
-    
73
+
74 74
     /**
75 75
      * Callback to all objects implementing the MOTDStart Callback.
76 76
      *
@@ -78,10 +78,10 @@ public class ProcessMOTD extends IRCProcessor {
78 78
      * @param data Incomming Line.
79 79
      * @return true if a method was called, false otherwise
80 80
      */
81
-    protected boolean callMOTDStart(String data) {
81
+    protected boolean callMOTDStart(final String data) {
82 82
         return getCallbackManager().getCallbackType(MotdStartListener.class).call(data);
83 83
     }
84
-    
84
+
85 85
     /**
86 86
      * What does this IRCProcessor handle.
87 87
      *
@@ -90,14 +90,16 @@ public class ProcessMOTD extends IRCProcessor {
90 90
     @Override
91 91
     public String[] handles() {
92 92
         return new String[]{"372", "375", "376", "422"};
93
-    } 
94
-    
93
+    }
94
+
95 95
     /**
96 96
      * Create a new instance of the IRCProcessor Object.
97 97
      *
98 98
      * @param parser IRCParser That owns this IRCProcessor
99 99
      * @param manager ProcessingManager that is in charge of this IRCProcessor
100 100
      */
101
-    protected ProcessMOTD(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
101
+    protected ProcessMOTD(final IRCParser parser, final ProcessingManager manager) {
102
+        super(parser, manager);
103
+    }
102 104
 
103 105
 }

+ 25
- 23
src/com/dmdirc/parser/irc/ProcessMessage.java Ver arquivo

@@ -68,7 +68,7 @@ public class ProcessMessage extends IRCProcessor {
68 68
      * @param token IRCTokenised line to process
69 69
      */
70 70
     @Override
71
-    public void process(final String sParam, String[] token) {
71
+    public void process(final String sParam, final String[] token) {
72 72
         // Ignore people!
73 73
         String sMessage = "";
74 74
         if (token[0].charAt(0) == ':') { sMessage = token[0].substring(1); } else { sMessage = token[0]; }
@@ -76,7 +76,7 @@ public class ProcessMessage extends IRCProcessor {
76 76
         try {
77 77
             if (myParser.getIgnoreList().matches(sMessage) > -1) { return; }
78 78
         } catch (PatternSyntaxException pse) {
79
-             final ParserError pe = new ParserError(ParserError.ERROR_WARNING + ParserError.ERROR_USER, "Error with ignore list regex: "+pse, myParser.getLastLine());
79
+             final ParserError pe = new ParserError(ParserError.ERROR_WARNING + ParserError.ERROR_USER, "Error with ignore list regex: " + pse, myParser.getLastLine());
80 80
              pe.setException(pse);
81 81
              callErrorInfo(pe);
82 82
         }
@@ -101,7 +101,7 @@ public class ProcessMessage extends IRCProcessor {
101 101
         if (token.length < 4) {
102 102
             sMessage = "";
103 103
         } else {
104
-            sMessage = token[token.length-1];
104
+            sMessage = token[token.length - 1];
105 105
         }
106 106
         String[] bits = sMessage.split(" ", 2);
107 107
         final Character char1 = Character.valueOf((char) 1);
@@ -114,18 +114,18 @@ public class ProcessMessage extends IRCProcessor {
114 114
             // Bits is the message been split into 2 parts
115 115
             //         the first word and the rest
116 116
             if (sParam.equalsIgnoreCase("PRIVMSG") && bits[0].equalsIgnoreCase(
117
-                    char1+"ACTION") && Character.valueOf(sMessage.charAt(
118
-                    sMessage.length()-1)).equals(char1)) {
117
+                    char1 + "ACTION") && Character.valueOf(sMessage.charAt(
118
+                    sMessage.length() - 1)).equals(char1)) {
119 119
                 isAction = true;
120 120
                 if (bits.length > 1) {
121 121
                     sMessage = bits[1];
122
-                    sMessage = sMessage.substring(0, sMessage.length()-1);
122
+                    sMessage = sMessage.substring(0, sMessage.length() - 1);
123 123
                 } else { sMessage = ""; }
124 124
             }
125 125
             // If the message is not an action, check if it is another type of CTCP
126 126
             // CTCPs have Character(1) at the start/end of the line
127 127
             if (!isAction && Character.valueOf(sMessage.charAt(0)).equals(char1)
128
-                    && Character.valueOf(sMessage.charAt(sMessage.length()-1))
128
+                    && Character.valueOf(sMessage.charAt(sMessage.length() - 1))
129 129
                     .equals(char1)) {
130 130
                 isCTCP = true;
131 131
                 // Bits is the message been split into 2 parts, the first word and the rest
@@ -139,10 +139,10 @@ public class ProcessMessage extends IRCProcessor {
139 139
                 bits = bits[0].split(char1.toString(), 2);
140 140
                 sCTCP = bits[1];
141 141
                 // remove the trailing char1
142
-                if (!sMessage.isEmpty()) {
143
-                    sMessage = sMessage.split(char1.toString(), 2)[0];
144
-                } else {
142
+                if (sMessage.isEmpty()) {
145 143
                     sCTCP = sCTCP.split(char1.toString(), 2)[0];
144
+                } else {
145
+                    sMessage = sMessage.split(char1.toString(), 2)[0];
146 146
                 }
147 147
                 callDebugInfo(IRCParser.DEBUG_INFO, "CTCP: \"%s\" \"%s\"",
148 148
                         sCTCP, sMessage);
@@ -184,7 +184,9 @@ public class ProcessMessage extends IRCProcessor {
184 184
             }
185 185
             if (iClient != null) { iChannelClient = iChannel.getChannelClient(iClient); }
186 186
             if (sParam.equalsIgnoreCase("PRIVMSG")) {
187
-                if (!isAction) {
187
+                if (isAction) {
188
+                    callChannelAction(iChannel, iChannelClient, sMessage, token[0]);
189
+                } else {
188 190
                     if (isCTCP) {
189 191
                         callChannelCTCP(iChannel, iChannelClient, sCTCP, sMessage, token[0]);
190 192
                     } else if (hasModePrefix) {
@@ -192,8 +194,6 @@ public class ProcessMessage extends IRCProcessor {
192 194
                     } else {
193 195
                         callChannelMessage(iChannel, iChannelClient, sMessage, token[0]);
194 196
                     }
195
-                } else {
196
-                    callChannelAction(iChannel, iChannelClient, sMessage, token[0]);
197 197
                 }
198 198
             } else if (sParam.equalsIgnoreCase("NOTICE")) {
199 199
                 if (isCTCP) {
@@ -206,20 +206,20 @@ public class ProcessMessage extends IRCProcessor {
206 206
             }
207 207
         } else if (myParser.getStringConverter().equalsIgnoreCase(token[2], myParser.getMyNickname())) {
208 208
             if (sParam.equalsIgnoreCase("PRIVMSG")) {
209
-                if (!isAction) {
209
+                if (isAction) {
210
+                    callPrivateAction(sMessage, token[0]);
211
+                } else {
210 212
                     if (isCTCP) {
211 213
                         callPrivateCTCP(sCTCP, sMessage, token[0]);
212 214
                     } else {
213 215
                         callPrivateMessage(sMessage, token[0]);
214 216
                     }
215
-                } else {
216
-                    callPrivateAction(sMessage, token[0]);
217 217
                 }
218 218
             } else if (sParam.equalsIgnoreCase("NOTICE")) {
219 219
                 if (isCTCP) {
220 220
                     callPrivateCTCPReply(sCTCP, sMessage, token[0]);
221 221
                 } else {
222
-                    if (token[0].indexOf("@") == -1) {
222
+                    if (token[0].indexOf('@') == -1) {
223 223
                         callServerNotice(sMessage, token[0]);
224 224
                     } else {
225 225
                         callPrivateNotice(sMessage, token[0]);
@@ -227,22 +227,22 @@ public class ProcessMessage extends IRCProcessor {
227 227
                 }
228 228
             }
229 229
         } else {
230
-            callDebugInfo(IRCParser.DEBUG_INFO, "Message for Other ("+token[2]+")");
230
+            callDebugInfo(IRCParser.DEBUG_INFO, "Message for Other (" + token[2] + ")");
231 231
             if (sParam.equalsIgnoreCase("PRIVMSG")) {
232
-                if (!isAction) {
232
+                if (isAction) {
233
+                    callUnknownAction(sMessage, token[2], token[0]);
234
+                } else {
233 235
                     if (isCTCP) {
234 236
                         callUnknownCTCP(sCTCP, sMessage, token[2], token[0]);
235 237
                     } else {
236 238
                         callUnknownMessage(sMessage, token[2], token[0]);
237 239
                     }
238
-                } else {
239
-                    callUnknownAction(sMessage, token[2], token[0]);
240 240
                 }
241 241
             } else if (sParam.equalsIgnoreCase("NOTICE")) {
242 242
                 if (isCTCP) {
243 243
                     callUnknownCTCPReply(sCTCP, sMessage, token[2], token[0]);
244 244
                 } else {
245
-                    if (token[0].indexOf("@") == -1) {
245
+                    if (token[0].indexOf('@') == -1) {
246 246
                         callUnknownServerNotice(sMessage, token[2], token[0]);
247 247
                     } else {
248 248
                         callUnknownNotice(sMessage, token[2], token[0]);
@@ -525,6 +525,8 @@ public class ProcessMessage extends IRCProcessor {
525 525
      * @param parser IRCParser That owns this IRCProcessor
526 526
      * @param manager ProcessingManager that is in charge of this IRCProcessor
527 527
      */
528
-    protected ProcessMessage(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
528
+    protected ProcessMessage(final IRCParser parser, final ProcessingManager manager) {
529
+        super(parser, manager);
530
+    }
529 531
 
530 532
 }

+ 95
- 56
src/com/dmdirc/parser/irc/ProcessMode.java Ver arquivo

@@ -48,33 +48,38 @@ public class ProcessMode extends IRCProcessor {
48 48
      * @param token IRCTokenised line to process
49 49
      */
50 50
     @Override
51
-    public void process(String sParam, String[] token) {
51
+    public void process(final String sParam, final String[] token) {
52 52
         String[] sModestr;
53 53
         String sChannelName;
54 54
         if (sParam.equals("324")) {
55 55
             sChannelName = token[3];
56
-            sModestr = new String[token.length-4];
57
-            System.arraycopy(token, 4, sModestr, 0, token.length-4);
56
+            sModestr = new String[token.length - 4];
57
+            System.arraycopy(token, 4, sModestr, 0, token.length - 4);
58 58
         } else if (sParam.equals("221")) {
59
-            processUserMode(sParam, token, new String[]{token[token.length-1]}, true);
59
+            processUserMode(sParam, token, new String[]{token[token.length - 1]}, true);
60 60
             return;
61 61
         } else {
62 62
             sChannelName = token[2];
63
-            sModestr = new String[token.length-3];
64
-            System.arraycopy(token, 3, sModestr, 0, token.length-3);
63
+            sModestr = new String[token.length - 3];
64
+            System.arraycopy(token, 3, sModestr, 0, token.length - 3);
65 65
         }
66 66
 
67
-        if (!isValidChannelName(sChannelName)) { processUserMode(sParam, token, sModestr, false); }
68
-        else { processChanMode(sParam, token, sModestr, sChannelName); }
67
+        if (isValidChannelName(sChannelName)) {
68
+            processChanMode(sParam, token, sModestr, sChannelName);
69
+        } else {
70
+            processUserMode(sParam, token, sModestr, false);
71
+        }
69 72
     }
70 73
 
71 74
     /**
72
-     * Method to trim spaces from strings
75
+     * Method to trim spaces from strings.
73 76
      *
74 77
      * @param str String to trim
75 78
      * @return String without spaces on the ends
76 79
      */
77
-    private String trim(String str) { return str.trim(); }
80
+    private String trim(final String str) {
81
+        return str.trim();
82
+    }
78 83
 
79 84
     /**
80 85
      * Process Chan modes.
@@ -84,8 +89,8 @@ public class ProcessMode extends IRCProcessor {
84 89
      * @param sModestr The modes and params
85 90
      * @param sChannelName Channel these modes are for
86 91
      */
87
-    public void processChanMode(String sParam, String[] token, String[] sModestr, String sChannelName) {
88
-        StringBuilder sFullModeStr = new StringBuilder();
92
+    public void processChanMode(final String sParam, final String[] token, final String[] sModestr, final String sChannelName) {
93
+        final StringBuilder sFullModeStr = new StringBuilder();
89 94
         String sNonUserModeStr = "";
90 95
         String sNonUserModeStrParams = "";
91 96
         String sModeParam;
@@ -115,7 +120,9 @@ public class ProcessMode extends IRCProcessor {
115 120
             return;
116 121
         }
117 122
         // Get the current channel modes
118
-        if (!sParam.equals("324")) { nCurrent = iChannel.getMode(); }
123
+        if (!sParam.equals("324")) {
124
+            nCurrent = iChannel.getMode();
125
+        }
119 126
 
120 127
         setterCCI = iChannel.getChannelClient(token[0]);
121 128
         // Facilitate dmdirc formatter
@@ -126,16 +133,22 @@ public class ProcessMode extends IRCProcessor {
126 133
 
127 134
         // Loop through the mode string, and add/remove modes/params where they are needed
128 135
         for (int i = 0; i < sModestr[0].length(); ++i) {
129
-            Character cMode = sModestr[0].charAt(i);
130
-            if (cMode.equals(":".charAt(0))) { continue; }
131
-
132
-            sNonUserModeStr = sNonUserModeStr+cMode;
133
-            if (cMode.equals("+".charAt(0))) { cPositive = '+'; bPositive = true; }
134
-            else if (cMode.equals("-".charAt(0))) { cPositive = '-'; bPositive = false; }
135
-            else {
136
-                if (myParser.chanModesBool.containsKey(cMode)) { nValue = myParser.chanModesBool.get(cMode); bBooleanMode = true; }
137
-                else if (myParser.chanModesOther.containsKey(cMode)) { nValue = myParser.chanModesOther.get(cMode); bBooleanMode = false; }
138
-                else if (myParser.prefixModes.containsKey(cMode)) {
136
+            final Character cMode = sModestr[0].charAt(i);
137
+            if (cMode.equals(":".charAt(0))) {
138
+                continue;
139
+            }
140
+
141
+            sNonUserModeStr = sNonUserModeStr + cMode;
142
+            if (cMode.equals("+".charAt(0))) {
143
+                cPositive = '+'; bPositive = true;
144
+            } else if (cMode.equals("-".charAt(0))) {
145
+                cPositive = '-'; bPositive = false;
146
+            } else {
147
+                if (myParser.chanModesBool.containsKey(cMode)) {
148
+                    nValue = myParser.chanModesBool.get(cMode); bBooleanMode = true;
149
+                } else if (myParser.chanModesOther.containsKey(cMode)) {
150
+                    nValue = myParser.chanModesOther.get(cMode); bBooleanMode = false;
151
+                } else if (myParser.prefixModes.containsKey(cMode)) {
139 152
                     // (de) OP/Voice someone
140 153
                     if (sModestr.length <= nParam) {
141 154
                         myParser.callErrorInfo(new ParserError(ParserError.ERROR_FATAL + ParserError.ERROR_USER, "Broken Modes. Parameter required but not given.", myParser.getLastLine()));
@@ -155,9 +168,12 @@ public class ProcessMode extends IRCProcessor {
155 168
                         iChannelClientInfo = iChannel.addClient(iClient);
156 169
                     }
157 170
                     callDebugInfo(IRCParser.DEBUG_INFO, "\tOld Mode Value: %d", iChannelClientInfo.getChanMode());
158
-                    if (bPositive) { iChannelClientInfo.setChanMode(iChannelClientInfo.getChanMode() | nValue); sTemp = "+"; }
159
-                    else { iChannelClientInfo.setChanMode(iChannelClientInfo.getChanMode() ^ (iChannelClientInfo.getChanMode() & nValue)); sTemp = "-"; }
160
-                    sTemp = sTemp+cMode;
171
+                    if (bPositive) {
172
+                        iChannelClientInfo.setChanMode(iChannelClientInfo.getChanMode() | nValue); sTemp = "+";
173
+                    } else {
174
+                        iChannelClientInfo.setChanMode(iChannelClientInfo.getChanMode() ^ (iChannelClientInfo.getChanMode() & nValue)); sTemp = "-";
175
+                    }
176
+                    sTemp = sTemp + cMode;
161 177
                     callChannelUserModeChanged(iChannel, iChannelClientInfo, setterCCI, token[0], sTemp);
162 178
                     continue;
163 179
                 } else {
@@ -165,14 +181,17 @@ public class ProcessMode extends IRCProcessor {
165 181
                     myParser.chanModesBool.put(cMode, myParser.nextKeyCMBool);
166 182
                     nValue = myParser.nextKeyCMBool;
167 183
                     bBooleanMode = true;
168
-                    myParser.nextKeyCMBool = myParser.nextKeyCMBool*2;
184
+                    myParser.nextKeyCMBool = myParser.nextKeyCMBool * 2;
169 185
                 }
170 186
 
171 187
                 if (bBooleanMode) {
172 188
                     callDebugInfo(IRCParser.DEBUG_INFO, "Boolean Mode: %c [%d] {Positive: %b}", cMode, nValue, bPositive);
173 189
 
174
-                    if (bPositive) { nCurrent = nCurrent | nValue; }
175
-                    else { nCurrent = nCurrent ^ (nCurrent & nValue); }
190
+                    if (bPositive) {
191
+                        nCurrent = nCurrent | nValue;
192
+                    } else {
193
+                        nCurrent = nCurrent ^ (nCurrent & nValue);
194
+                    }
176 195
                 } else {
177 196
 
178 197
                     if ((bPositive || nValue == IRCParser.MODE_LIST || ((nValue & IRCParser.MODE_UNSET) == IRCParser.MODE_UNSET)) && (sModestr.length <= nParam)) {
@@ -183,31 +202,37 @@ public class ProcessMode extends IRCProcessor {
183 202
                     if (nValue == IRCParser.MODE_LIST) {
184 203
                         // List Mode
185 204
                         sModeParam = sModestr[nParam++];
186
-                        sNonUserModeStrParams = sNonUserModeStrParams+" "+sModeParam;
205
+                        sNonUserModeStrParams = sNonUserModeStrParams + " " + sModeParam;
187 206
                         nTemp = (Calendar.getInstance().getTimeInMillis() / 1000);
188 207
                         iChannel.setListModeParam(cMode, new ChannelListModeItem(sModeParam, token[0], nTemp), bPositive);
189 208
                         callDebugInfo(IRCParser.DEBUG_INFO, "List Mode: %c [%s] {Positive: %b}", cMode, sModeParam, bPositive);
190
-                        if (cbSingle != null) { cbSingle.call(iChannel, setterCCI, token[0], cPositive+cMode+" "+sModeParam); }
209
+                        if (cbSingle != null) {
210
+                            cbSingle.call(iChannel, setterCCI, token[0], cPositive + cMode + " " + sModeParam);
211
+                        }
191 212
                     } else {
192 213
                         // Mode with a parameter
193 214
                         if (bPositive) {
194 215
                             // +Mode - always needs a parameter to set
195 216
                             sModeParam = sModestr[nParam++];
196
-                            sNonUserModeStrParams = sNonUserModeStrParams+" "+sModeParam;
217
+                            sNonUserModeStrParams = sNonUserModeStrParams + " " + sModeParam;
197 218
                             callDebugInfo(IRCParser.DEBUG_INFO, "Set Mode: %c [%s] {Positive: %b}", cMode, sModeParam, bPositive);
198 219
                             iChannel.setModeParam(cMode, sModeParam);
199
-                            if (cbSingle != null) { cbSingle.call(iChannel, setterCCI, token[0], cPositive+cMode+" "+sModeParam); }
220
+                            if (cbSingle != null) {
221
+                                cbSingle.call(iChannel, setterCCI, token[0], cPositive + cMode + " " + sModeParam);
222
+                            }
200 223
                         } else {
201 224
                             // -Mode - parameter isn't always needed, we need to check
202 225
                             if ((nValue & IRCParser.MODE_UNSET) == IRCParser.MODE_UNSET) {
203 226
                                 sModeParam = sModestr[nParam++];
204
-                                sNonUserModeStrParams = sNonUserModeStrParams+" "+sModeParam;
227
+                                sNonUserModeStrParams = sNonUserModeStrParams + " " + sModeParam;
205 228
                             } else {
206 229
                                 sModeParam = "";
207 230
                             }
208 231
                             callDebugInfo(IRCParser.DEBUG_INFO, "Unset Mode: %c [%s] {Positive: %b}", cMode, sModeParam, bPositive);
209 232
                             iChannel.setModeParam(cMode, "");
210
-                            if (cbSingle != null) { cbSingle.call(iChannel, setterCCI, token[0], trim(cPositive+cMode+" "+sModeParam)); }
233
+                            if (cbSingle != null) {
234
+                                cbSingle.call(iChannel, setterCCI, token[0], trim(cPositive + cMode + " " + sModeParam));
235
+                            }
211 236
                         }
212 237
                     }
213 238
                 }
@@ -218,9 +243,14 @@ public class ProcessMode extends IRCProcessor {
218 243
         for (int i = 0; i < sModestr.length; ++i) { sFullModeStr.append(sModestr[i]).append(" "); }
219 244
 
220 245
         iChannel.setMode(nCurrent);
221
-        if (sParam.equals("324")) { callChannelModeChanged(iChannel, null, "", sFullModeStr.toString().trim()); }
222
-        else { callChannelModeChanged(iChannel, setterCCI, token[0], sFullModeStr.toString().trim()); }
223
-        if (cbNonUser != null) { cbNonUser.call(iChannel, setterCCI, token[0], trim(sNonUserModeStr+sNonUserModeStrParams)); }
246
+        if (sParam.equals("324")) {
247
+            callChannelModeChanged(iChannel, null, "", sFullModeStr.toString().trim());
248
+        } else {
249
+            callChannelModeChanged(iChannel, setterCCI, token[0], sFullModeStr.toString().trim());
250
+        }
251
+        if (cbNonUser != null) {
252
+            cbNonUser.call(iChannel, setterCCI, token[0], trim(sNonUserModeStr + sNonUserModeStrParams));
253
+        }
224 254
     }
225 255
 
226 256
     /**
@@ -230,11 +260,11 @@ public class ProcessMode extends IRCProcessor {
230 260
      * @param token IRCTokenised Array of the incomming line
231 261
      * @param clearOldModes Clear old modes before applying these modes (used by 221)
232 262
      */
233
-    private void processUserMode(String sParam, String[] token, String[] sModestr, boolean clearOldModes) {
263
+    private void processUserMode(final String sParam, final String[] token, final String[] sModestr, final boolean clearOldModes) {
234 264
         long nCurrent = 0, nValue = 0;
235 265
         boolean bPositive = true;
236 266
 
237
-        IRCClientInfo iClient = getClientInfo(token[2]);
267
+        final IRCClientInfo iClient = getClientInfo(token[2]);
238 268
 
239 269
         if (iClient == null) { return; }
240 270
 
@@ -245,23 +275,30 @@ public class ProcessMode extends IRCProcessor {
245 275
         }
246 276
 
247 277
         for (int i = 0; i < sModestr[0].length(); ++i) {
248
-            Character cMode = sModestr[0].charAt(i);
249
-            if (cMode.equals("+".charAt(0))) { bPositive = true; }
250
-            else if (cMode.equals("-".charAt(0))) { bPositive = false; }
251
-            else if (cMode.equals(":".charAt(0))) { continue; }
252
-            else {
253
-                if (myParser.userModes.containsKey(cMode)) { nValue = myParser.userModes.get(cMode); }
254
-                else {
278
+            final Character cMode = sModestr[0].charAt(i);
279
+            if (cMode.equals("+".charAt(0))) {
280
+                bPositive = true;
281
+            } else if (cMode.equals("-".charAt(0))) {
282
+                bPositive = false;
283
+            } else if (cMode.equals(":".charAt(0))) {
284
+                continue;
285
+            } else {
286
+                if (myParser.userModes.containsKey(cMode)) {
287
+                    nValue = myParser.userModes.get(cMode);
288
+                } else {
255 289
                     // Unknown mode
256
-                    callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got unknown user mode "+cMode+" - Added", myParser.getLastLine()));
290
+                    callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got unknown user mode " + cMode + " - Added", myParser.getLastLine()));
257 291
                     myParser.userModes.put(cMode, myParser.nNextKeyUser);
258 292
                     nValue = myParser.nNextKeyUser;
259
-                    myParser.nNextKeyUser = myParser.nNextKeyUser*2;
293
+                    myParser.nNextKeyUser = myParser.nNextKeyUser * 2;
260 294
                 }
261 295
                 // Usermodes are always boolean
262 296
                 callDebugInfo(IRCParser.DEBUG_INFO, "User Mode: %c [%d] {Positive: %b}", cMode, nValue, bPositive);
263
-                if (bPositive) { nCurrent = nCurrent | nValue; }
264
-                else { nCurrent = nCurrent ^ (nCurrent & nValue); }
297
+                if (bPositive) {
298
+                    nCurrent = nCurrent | nValue;
299
+                } else {
300
+                    nCurrent = nCurrent ^ (nCurrent & nValue);
301
+                }
265 302
             }
266 303
         }
267 304
 
@@ -283,7 +320,7 @@ public class ProcessMode extends IRCProcessor {
283 320
      * @param sModes Exact String parsed
284 321
      * @return true if a method was called, false otherwise
285 322
      */
286
-    protected boolean callChannelModeChanged(ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sHost, String sModes) {
323
+    protected boolean callChannelModeChanged(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sHost, final String sModes) {
287 324
         return getCallbackManager().getCallbackType(ChannelModeChangeListener.class).call(cChannel, cChannelClient, sHost, sModes);
288 325
     }
289 326
 
@@ -298,7 +335,7 @@ public class ProcessMode extends IRCProcessor {
298 335
      * @param sHost Host doing the mode changing (User host or server name)
299 336
      * @return true if a method was called, false otherwise
300 337
      */
301
-    protected boolean callChannelUserModeChanged(ChannelInfo cChannel, ChannelClientInfo cChangedClient, ChannelClientInfo cSetByClient, String sHost, String sMode) {
338
+    protected boolean callChannelUserModeChanged(final ChannelInfo cChannel, final ChannelClientInfo cChangedClient, final ChannelClientInfo cSetByClient, final String sHost, final String sMode) {
302 339
         return getCallbackManager().getCallbackType(ChannelUserModeChangeListener.class).call(cChannel, cChangedClient, cSetByClient, sHost, sMode);
303 340
     }
304 341
 
@@ -311,7 +348,7 @@ public class ProcessMode extends IRCProcessor {
311 348
      * @param sModes The modes set.
312 349
      * @return true if a method was called, false otherwise
313 350
      */
314
-    protected boolean callUserModeChanged(ClientInfo cClient, String sSetby, String sModes) {
351
+    protected boolean callUserModeChanged(final ClientInfo cClient, final String sSetby, final String sModes) {
315 352
         return getCallbackManager().getCallbackType(UserModeChangeListener.class).call(cClient, sSetby, sModes);
316 353
     }
317 354
 
@@ -323,7 +360,7 @@ public class ProcessMode extends IRCProcessor {
323 360
      * @param sModes The modes set.
324 361
      * @return true if a method was called, false otherwise
325 362
      */
326
-    protected boolean callUserModeDiscovered(ClientInfo cClient, String sModes) {
363
+    protected boolean callUserModeDiscovered(final ClientInfo cClient, final String sModes) {
327 364
         return getCallbackManager().getCallbackType(UserModeDiscoveryListener.class).call(cClient, sModes);
328 365
     }
329 366
 
@@ -343,6 +380,8 @@ public class ProcessMode extends IRCProcessor {
343 380
      * @param parser IRCParser That owns this IRCProcessor
344 381
      * @param manager ProcessingManager that is in charge of this IRCProcessor
345 382
      */
346
-    protected ProcessMode(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
383
+    protected ProcessMode(final IRCParser parser, final ProcessingManager manager) {
384
+        super(parser, manager);
385
+    }
347 386
 
348 387
 }

+ 21
- 19
src/com/dmdirc/parser/irc/ProcessNames.java Ver arquivo

@@ -37,39 +37,39 @@ public class ProcessNames extends IRCProcessor {
37 37
      * @param token IRCTokenised line to process
38 38
      */
39 39
     @Override
40
-    public void process(String sParam, String[] token) {
40
+    public void process(final String sParam, final String[] token) {
41 41
         IRCChannelInfo iChannel;
42
-        if (sParam.equals("366")) {
42
+        if ("366".equals(sParam)) {
43 43
             // End of names
44 44
             iChannel = getChannel(token[3]);
45 45
             if (iChannel == null) { return; }
46
-            
46
+
47 47
             if (!iChannel.hadTopic()) {
48 48
                 callChannelTopic(iChannel, true);
49 49
             }
50 50
 
51 51
             iChannel.setAddingNames(false);
52 52
             callChannelGotNames(iChannel);
53
-            
54
-            if (!iChannel.hasAskedForListModes() 
53
+
54
+            if (!iChannel.hasAskedForListModes()
55 55
                     && myParser.getAutoListMode()) {
56 56
                 iChannel.requestListModes();
57 57
             }
58 58
         } else {
59 59
             // Names
60
-            
60
+
61 61
             IRCClientInfo iClient;
62 62
             IRCChannelClientInfo iChannelClient;
63
-            
63
+
64 64
             iChannel = getChannel(token[4]);
65
-        
65
+
66 66
             if (iChannel == null) { return; }
67
-            
67
+
68 68
             // If we are not expecting names, clear the current known names - this is fresh stuff!
69 69
             if (!iChannel.isAddingNames()) { iChannel.emptyChannel(); }
70 70
             iChannel.setAddingNames(true);
71
-            
72
-            String[] sNames = token[token.length-1].split(" ");
71
+
72
+            final String[] sNames = token[token.length - 1].split(" ");
73 73
             String sNameBit = "", sName = "";
74 74
             StringBuilder sModes = new StringBuilder();
75 75
             long nPrefix = 0;
@@ -79,7 +79,7 @@ public class ProcessNames extends IRCProcessor {
79 79
                 if (sNameBit.isEmpty()) { continue; }
80 80
                 // This next bit of code allows for any ircd which decides to use @+Foo in names
81 81
                 for (int i = 0; i < sNameBit.length(); ++i) {
82
-                    Character cMode = sNameBit.charAt(i);
82
+                    final Character cMode = sNameBit.charAt(i);
83 83
                     // hPrefixMap contains @, o, +, v this caused issue 107
84 84
                     // hPrefixModes only contains o, v so if the mode is in hPrefixMap
85 85
                     // and not in hPrefixModes, its ok to use.
@@ -92,7 +92,7 @@ public class ProcessNames extends IRCProcessor {
92 92
                     }
93 93
                 }
94 94
                 callDebugInfo(IRCParser.DEBUG_INFO, "Name: %s Modes: \"%s\" [%d]", sName, sModes.toString(), nPrefix);
95
-                
95
+
96 96
                 iClient = getClientInfo(sName);
97 97
                 if (iClient == null) { iClient = new IRCClientInfo(myParser, sName); myParser.addClient(iClient); }
98 98
                 iClient.setUserBits(sName, false); // Will do nothing if this isn't UHNAMES
@@ -105,7 +105,7 @@ public class ProcessNames extends IRCProcessor {
105 105
             }
106 106
         }
107 107
     }
108
-    
108
+
109 109
     /**
110 110
      * Callback to all objects implementing the ChannelTopic Callback.
111 111
      *
@@ -126,10 +126,10 @@ public class ProcessNames extends IRCProcessor {
126 126
      * @param cChannel Channel which the names reply is for
127 127
      * @return true if a method was called, false otherwise
128 128
      */
129
-    protected boolean callChannelGotNames(ChannelInfo cChannel) {
129
+    protected boolean callChannelGotNames(final ChannelInfo cChannel) {
130 130
         return getCallbackManager().getCallbackType(ChannelNamesListener.class).call(cChannel);
131 131
     }
132
-    
132
+
133 133
     /**
134 134
      * What does this IRCProcessor handle.
135 135
      *
@@ -138,14 +138,16 @@ public class ProcessNames extends IRCProcessor {
138 138
     @Override
139 139
     public String[] handles() {
140 140
         return new String[]{"353", "366"};
141
-    } 
142
-    
141
+    }
142
+
143 143
     /**
144 144
      * Create a new instance of the IRCProcessor Object.
145 145
      *
146 146
      * @param parser IRCParser That owns this IRCProcessor
147 147
      * @param manager ProcessingManager that is in charge of this IRCProcessor
148 148
      */
149
-    protected ProcessNames(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
149
+    protected ProcessNames(final IRCParser parser, final ProcessingManager manager) {
150
+        super(parser, manager);
151
+    }
150 152
 
151 153
 }

+ 42
- 41
src/com/dmdirc/parser/irc/ProcessNick.java Ver arquivo

@@ -40,51 +40,50 @@ public class ProcessNick extends IRCProcessor {
40 40
      * @param token IRCTokenised line to process
41 41
      */
42 42
     @Override
43
-    public void process(String sParam, String[] token) {
43
+    public void process(final String sParam, final String[] token) {
44 44
         IRCClientInfo iClient;
45 45
         IRCChannelClientInfo iChannelClient;
46 46
         String oldNickname;
47
-        
47
+
48 48
         iClient = getClientInfo(token[0]);
49
-        if (iClient != null) {
50
-            oldNickname = myParser.getStringConverter().toLowerCase(iClient.getNickname());
51
-            // Remove the client from the known clients list
52
-            final boolean isSameNick = myParser.getStringConverter().equalsIgnoreCase(oldNickname, token[token.length-1]);
53
-            
49
+        if (iClient == null) {
50
+            return;
51
+        }
52
+        oldNickname = myParser.getStringConverter().toLowerCase(iClient.getNickname());
53
+        // Remove the client from the known clients list
54
+        final boolean isSameNick = myParser.getStringConverter().equalsIgnoreCase(oldNickname, token[token.length - 1]);
55
+
56
+        if (!isSameNick) {
57
+            myParser.forceRemoveClient(getClientInfo(oldNickname));
58
+        }
59
+        // Change the nickame
60
+        iClient.setUserBits(token[token.length - 1], true);
61
+        // Readd the client
62
+        if (!isSameNick && getClientInfo(iClient.getNickname()) != null) {
63
+            myParser.callErrorInfo(new ParserError(ParserError.ERROR_FATAL + ParserError.ERROR_USER, "Nick change would overwrite existing client", myParser.getLastLine()));
64
+        } else {
54 65
             if (!isSameNick) {
55
-                myParser.forceRemoveClient(getClientInfo(oldNickname));
66
+                myParser.addClient(iClient);
56 67
             }
57
-            // Change the nickame
58
-            iClient.setUserBits(token[token.length-1], true);
59
-            // Readd the client
60
-            if (!isSameNick && getClientInfo(iClient.getNickname()) != null) {
61
-//                myParser.onPostErrorInfo(new ParserError(ParserError.ERROR_FATAL, "Nick change would overwrite existing client", myParser.getLastLine()), false);
62
-                myParser.callErrorInfo(new ParserError(ParserError.ERROR_FATAL + ParserError.ERROR_USER, "Nick change would overwrite existing client", myParser.getLastLine()));
63
-            } else {
64
-                if (!isSameNick) {
65
-                    myParser.addClient(iClient);
66
-                }
67
-                
68
-                for (IRCChannelInfo iChannel : myParser.getChannels()) {
69
-                    // Find the user (using the old nickname)
70
-                    iChannelClient = iChannel.getChannelClient(oldNickname);
71
-                    if (iChannelClient != null) {
72
-                        // Rename them. This uses the old nickname (the key in the hashtable)
73
-                        // and the channelClient object has access to the new nickname (by way
74
-                        // of the ClientInfo object we updated above)
75
-                        if (!isSameNick) {
76
-                            iChannel.renameClient(oldNickname, iChannelClient);
77
-                        }
78
-                        callChannelNickChanged(iChannel, iChannelClient, IRCClientInfo.parseHost(token[0]));
68
+
69
+            for (IRCChannelInfo iChannel : myParser.getChannels()) {
70
+                // Find the user (using the old nickname)
71
+                iChannelClient = iChannel.getChannelClient(oldNickname);
72
+                if (iChannelClient != null) {
73
+                    // Rename them. This uses the old nickname (the key in the hashtable)
74
+                    // and the channelClient object has access to the new nickname (by way
75
+                    // of the ClientInfo object we updated above)
76
+                    if (!isSameNick) {
77
+                        iChannel.renameClient(oldNickname, iChannelClient);
79 78
                     }
79
+                    callChannelNickChanged(iChannel, iChannelClient, IRCClientInfo.parseHost(token[0]));
80 80
                 }
81
-                
82
-                callNickChanged(iClient, IRCClientInfo.parseHost(token[0]));
83 81
             }
82
+
83
+            callNickChanged(iClient, IRCClientInfo.parseHost(token[0]));
84 84
         }
85
-        
86 85
     }
87
-    
86
+
88 87
     /**
89 88
      * Callback to all objects implementing the ChannelNickChanged Callback.
90 89
      *
@@ -94,10 +93,10 @@ public class ProcessNick extends IRCProcessor {
94 93
      * @param sOldNick Nickname before change
95 94
      * @return true if a method was called, false otherwise
96 95
      */
97
-    protected boolean callChannelNickChanged(ChannelInfo cChannel, ChannelClientInfo cChannelClient, String sOldNick) {
96
+    protected boolean callChannelNickChanged(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sOldNick) {
98 97
         return getCallbackManager().getCallbackType(ChannelNickChangeListener.class).call(cChannel, cChannelClient, sOldNick);
99 98
     }
100
-    
99
+
101 100
     /**
102 101
      * Callback to all objects implementing the NickChanged Callback.
103 102
      *
@@ -106,10 +105,10 @@ public class ProcessNick extends IRCProcessor {
106 105
      * @param sOldNick Nickname before change
107 106
      * @return true if a method was called, false otherwise
108 107
      */
109
-    protected boolean callNickChanged(ClientInfo cClient, String sOldNick) {
108
+    protected boolean callNickChanged(final ClientInfo cClient, final String sOldNick) {
110 109
         return getCallbackManager().getCallbackType(NickChangeListener.class).call(cClient, sOldNick);
111 110
     }
112
-    
111
+
113 112
     /**
114 113
      * What does this IRCProcessor handle.
115 114
      *
@@ -118,14 +117,16 @@ public class ProcessNick extends IRCProcessor {
118 117
     @Override
119 118
     public String[] handles() {
120 119
         return new String[]{"NICK"};
121
-    } 
122
-    
120
+    }
121
+
123 122
     /**
124 123
      * Create a new instance of the IRCProcessor Object.
125 124
      *
126 125
      * @param parser IRCParser That owns this IRCProcessor
127 126
      * @param manager ProcessingManager that is in charge of this IRCProcessor
128 127
      */
129
-    protected ProcessNick(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
128
+    protected ProcessNick(final IRCParser parser, final ProcessingManager manager) {
129
+        super(parser, manager);
130
+    }
130 131
 
131 132
 }

+ 5
- 5
src/com/dmdirc/parser/irc/ProcessNickInUse.java Ver arquivo

@@ -58,15 +58,15 @@ public class ProcessNickInUse extends IRCProcessor {
58 58
                     if (myParser.getStringConverter().equalsIgnoreCase(myParser.thinkNickname, myParser.me.getAltNickname())) {
59 59
                         myParser.thinkNickname = myParser.me.getNickname();
60 60
                     }
61
-                    myParser.getLocalClient().setNickname(myParser.me.getPrependChar()+myParser.thinkNickname);
61
+                    myParser.getLocalClient().setNickname(myParser.me.getPrependChar() + myParser.thinkNickname);
62 62
                 } else {
63 63
                     myParser.getLocalClient().setNickname(myParser.me.getAltNickname());
64
-                    myParser.triedAlt = true; 
64
+                    myParser.triedAlt = true;
65 65
                 }
66 66
             }
67 67
         }
68 68
     }
69
-    
69
+
70 70
     /**
71 71
      * Callback to all objects implementing the NickInUse Callback.
72 72
      *
@@ -77,7 +77,7 @@ public class ProcessNickInUse extends IRCProcessor {
77 77
     protected boolean callNickInUse(final String nickname) {
78 78
         return getCallbackManager().getCallbackType(NickInUseListener.class).call(nickname);
79 79
     }
80
-    
80
+
81 81
     /**
82 82
      * What does this IRCProcessor handle.
83 83
      *
@@ -87,7 +87,7 @@ public class ProcessNickInUse extends IRCProcessor {
87 87
     public String[] handles() {
88 88
         return new String[]{"433"};
89 89
     }
90
-    
90
+
91 91
     /**
92 92
      * Create a new instance of the ProcessNickInUse Object.
93 93
      *

+ 5
- 5
src/com/dmdirc/parser/irc/ProcessNoticeAuth.java Ver arquivo

@@ -36,9 +36,9 @@ public class ProcessNoticeAuth extends IRCProcessor {
36 36
      */
37 37
     @Override
38 38
     public void process(final String sParam, final String[] token) {
39
-        callNoticeAuth(token[token.length-1]);
39
+        callNoticeAuth(token[token.length - 1]);
40 40
     }
41
-    
41
+
42 42
     /**
43 43
      * Callback to all objects implementing the NoticeAuth Callback.
44 44
      *
@@ -49,7 +49,7 @@ public class ProcessNoticeAuth extends IRCProcessor {
49 49
     protected boolean callNoticeAuth(final String data) {
50 50
         return getCallbackManager().getCallbackType(AuthNoticeListener.class).call(data);
51 51
     }
52
-    
52
+
53 53
     /**
54 54
      * What does this IRCProcessor handle.
55 55
      *
@@ -58,8 +58,8 @@ public class ProcessNoticeAuth extends IRCProcessor {
58 58
     @Override
59 59
     public String[] handles() {
60 60
         return new String[]{"Notice Auth"};
61
-    } 
62
-    
61
+    }
62
+
63 63
     /**
64 64
      * Create a new instance of the ProcessNoticeAuth Object.
65 65
      *

+ 12
- 10
src/com/dmdirc/parser/irc/ProcessPart.java Ver arquivo

@@ -46,23 +46,23 @@ public class ProcessPart extends IRCProcessor {
46 46
         IRCClientInfo iClient;
47 47
         IRCChannelInfo iChannel;
48 48
         IRCChannelClientInfo iChannelClient;
49
-        
49
+
50 50
         iClient = getClientInfo(token[0]);
51 51
         iChannel = getChannel(token[2]);
52
-        
52
+
53 53
         if (iClient == null) { return; }
54 54
         if (IRCParser.ALWAYS_UPDATECLIENT && iClient.getHostname().isEmpty()) {
55 55
             // This may seem pointless - updating before they leave - but the formatter needs it!
56 56
             iClient.setUserBits(token[0], false);
57 57
         }
58
-        if (iChannel == null) { 
58
+        if (iChannel == null) {
59 59
             if (iClient != myParser.getLocalClient()) {
60
-                callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got part for channel ("+token[2]+") that I am not on. [User: "+token[0]+"]", myParser.getLastLine()));
60
+                callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got part for channel (" + token[2] + ") that I am not on. [User: " + token[0] + "]", myParser.getLastLine()));
61 61
             }
62 62
             return;
63 63
         } else {
64 64
             String sReason = "";
65
-            if (token.length > 3) { sReason = token[token.length-1]; }
65
+            if (token.length > 3) { sReason = token[token.length - 1]; }
66 66
             iChannelClient = iChannel.getChannelClient(iClient);
67 67
             if (iChannelClient == null) {
68 68
                 // callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got part for channel ("+token[2]+") for a non-existant user. [User: "+token[0]+"]", myParser.getLastLine()));
@@ -78,7 +78,7 @@ public class ProcessPart extends IRCProcessor {
78 78
             }
79 79
         }
80 80
     }
81
-    
81
+
82 82
     /**
83 83
      * Callback to all objects implementing the ChannelPart Callback.
84 84
      *
@@ -91,7 +91,7 @@ public class ProcessPart extends IRCProcessor {
91 91
     protected boolean callChannelPart(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sReason) {
92 92
         return getCallbackManager().getCallbackType(ChannelPartListener.class).call(cChannel, cChannelClient, sReason);
93 93
     }
94
-    
94
+
95 95
     /**
96 96
      * What does this IRCProcessor handle.
97 97
      *
@@ -100,14 +100,16 @@ public class ProcessPart extends IRCProcessor {
100 100
     @Override
101 101
     public String[] handles() {
102 102
         return new String[]{"PART"};
103
-    } 
104
-    
103
+    }
104
+
105 105
     /**
106 106
      * Create a new instance of the IRCProcessor Object.
107 107
      *
108 108
      * @param parser IRCParser That owns this IRCProcessor
109 109
      * @param manager ProcessingManager that is in charge of this IRCProcessor
110 110
      */
111
-    protected ProcessPart(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
111
+    protected ProcessPart(final IRCParser parser, final ProcessingManager manager) {
112
+        super(parser, manager);
113
+    }
112 114
 
113 115
 }

+ 14
- 12
src/com/dmdirc/parser/irc/ProcessQuit.java Ver arquivo

@@ -47,18 +47,18 @@ public class ProcessQuit extends IRCProcessor {
47 47
         if (token.length < 2) { return; }
48 48
         IRCClientInfo iClient;
49 49
         IRCChannelClientInfo iChannelClient;
50
-        
50
+
51 51
         iClient = getClientInfo(token[0]);
52
-        
52
+
53 53
         if (iClient == null) { return; }
54 54
         if (IRCParser.ALWAYS_UPDATECLIENT && iClient.getHostname().isEmpty()) {
55 55
             // This may seem pointless - updating before they leave - but the formatter needs it!
56 56
             iClient.setUserBits(token[0], false);
57 57
         }
58 58
         String sReason = "";
59
-        if (token.length > 2) { sReason = token[token.length-1]; }
60
-        
61
-        ArrayList<IRCChannelInfo> channelList = new ArrayList<IRCChannelInfo>(myParser.getChannels());
59
+        if (token.length > 2) { sReason = token[token.length - 1]; }
60
+
61
+        final ArrayList<IRCChannelInfo> channelList = new ArrayList<IRCChannelInfo>(myParser.getChannels());
62 62
         for (IRCChannelInfo iChannel : channelList) {
63 63
             iChannelClient = iChannel.getChannelClient(iClient);
64 64
             if (iChannelClient != null) {
@@ -80,8 +80,8 @@ public class ProcessQuit extends IRCProcessor {
80 80
             myParser.removeClient(iClient);
81 81
         }
82 82
         if (!myParser.removeAfterCallback) { callQuit(iClient, sReason); }
83
-    }    
84
-    
83
+    }
84
+
85 85
     /**
86 86
      * Callback to all objects implementing the ChannelQuit Callback.
87 87
      *
@@ -94,7 +94,7 @@ public class ProcessQuit extends IRCProcessor {
94 94
     protected boolean callChannelQuit(final ChannelInfo cChannel, final ChannelClientInfo cChannelClient, final String sReason) {
95 95
         return getCallbackManager().getCallbackType(ChannelQuitListener.class).call(cChannel, cChannelClient, sReason);
96 96
     }
97
-    
97
+
98 98
     /**
99 99
      * Callback to all objects implementing the Quit Callback.
100 100
      *
@@ -106,7 +106,7 @@ public class ProcessQuit extends IRCProcessor {
106 106
     protected boolean callQuit(final ClientInfo cClient, final String sReason) {
107 107
         return getCallbackManager().getCallbackType(QuitListener.class).call(cClient, sReason);
108 108
     }
109
-    
109
+
110 110
     /**
111 111
      * What does this IRCProcessor handle.
112 112
      *
@@ -115,14 +115,16 @@ public class ProcessQuit extends IRCProcessor {
115 115
     @Override
116 116
     public String[] handles() {
117 117
         return new String[]{"QUIT"};
118
-    } 
119
-    
118
+    }
119
+
120 120
     /**
121 121
      * Create a new instance of the IRCProcessor Object.
122 122
      *
123 123
      * @param parser IRCParser That owns this IRCProcessor
124 124
      * @param manager ProcessingManager that is in charge of this IRCProcessor
125 125
      */
126
-    protected ProcessQuit(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
126
+    protected ProcessQuit(final IRCParser parser, final ProcessingManager manager) {
127
+        super(parser, manager);
128
+    }
127 129
 
128 130
 }

+ 12
- 8
src/com/dmdirc/parser/irc/ProcessTopic.java Ver arquivo

@@ -41,7 +41,7 @@ public class ProcessTopic extends IRCProcessor {
41 41
         if (sParam.equals("332")) {
42 42
             iChannel = getChannel(token[3]);
43 43
             if (iChannel == null) { return; }
44
-            iChannel.setInternalTopic(token[token.length-1]);
44
+            iChannel.setInternalTopic(token[token.length - 1]);
45 45
         } else if (sParam.equals("333")) {
46 46
             if (token.length > 3) {
47 47
                 iChannel = getChannel(token[3]);
@@ -57,18 +57,20 @@ public class ProcessTopic extends IRCProcessor {
57 57
         } else {
58 58
             if (IRCParser.ALWAYS_UPDATECLIENT) {
59 59
                 final IRCClientInfo iClient = getClientInfo(token[0]);
60
-                if (iClient != null && iClient.getHostname().isEmpty()) {iClient.setUserBits(token[0], false); }
60
+                if (iClient != null && iClient.getHostname().isEmpty()) {
61
+                    iClient.setUserBits(token[0], false);
62
+                }
61 63
             }
62 64
             iChannel = getChannel(token[2]);
63 65
             if (iChannel == null) { return; }
64 66
             iChannel.setTopicTime(System.currentTimeMillis() / 1000);
65 67
             if (token[0].charAt(0) == ':') { token[0] = token[0].substring(1); }
66 68
             iChannel.setTopicUser(token[0]);
67
-            iChannel.setInternalTopic(token[token.length-1]);
69
+            iChannel.setInternalTopic(token[token.length - 1]);
68 70
             callChannelTopic(iChannel, false);
69 71
         }
70 72
     }
71
-    
73
+
72 74
     /**
73 75
      * Callback to all objects implementing the ChannelTopic Callback.
74 76
      *
@@ -81,7 +83,7 @@ public class ProcessTopic extends IRCProcessor {
81 83
         ((IRCChannelInfo) cChannel).setHadTopic();
82 84
         return getCallbackManager().getCallbackType(ChannelTopicListener.class).call(cChannel, bIsJoinTopic);
83 85
     }
84
-    
86
+
85 87
     /**
86 88
      * What does this IRCProcessor handle.
87 89
      *
@@ -90,14 +92,16 @@ public class ProcessTopic extends IRCProcessor {
90 92
     @Override
91 93
     public String[] handles() {
92 94
         return new String[]{"TOPIC", "332", "333"};
93
-    } 
94
-    
95
+    }
96
+
95 97
     /**
96 98
      * Create a new instance of the IRCProcessor Object.
97 99
      *
98 100
      * @param parser IRCParser That owns this IRCProcessor
99 101
      * @param manager ProcessingManager that is in charge of this IRCProcessor
100 102
      */
101
-    protected ProcessTopic(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
103
+    protected ProcessTopic(final IRCParser parser, final ProcessingManager manager) {
104
+        super(parser, manager);
105
+    }
102 106
 
103 107
 }

+ 13
- 11
src/com/dmdirc/parser/irc/ProcessWallops.java Ver arquivo

@@ -39,11 +39,11 @@ public class ProcessWallops extends IRCProcessor {
39 39
     @Override
40 40
     public void process(final String sParam, final String[] token) {
41 41
         if (token.length < 3) { return; }
42
-        
42
+
43 43
         String user = token[0];
44
-        String message = token[token.length-1];
44
+        final String message = token[token.length - 1];
45 45
         if (user.charAt(0) == ':' && user.length() > 1) { user = user.substring(1); }
46
-        String[] bits = message.split(" ", 2);
46
+        final String[] bits = message.split(" ", 2);
47 47
 
48 48
         if (bits.length > 1) {
49 49
             if (message.charAt(0) == '*') {
@@ -56,7 +56,7 @@ public class ProcessWallops extends IRCProcessor {
56 56
         }
57 57
         callWallDesync(message, user);
58 58
     }
59
-    
59
+
60 60
     /**
61 61
      * Callback to all objects implementing the Wallop Callback.
62 62
      *
@@ -68,7 +68,7 @@ public class ProcessWallops extends IRCProcessor {
68 68
     protected boolean callWallop(final String message, final String host) {
69 69
         return getCallbackManager().getCallbackType(WallopListener.class).call(message, host);
70 70
     }
71
-    
71
+
72 72
     /**
73 73
      * Callback to all objects implementing the Walluser Callback.
74 74
      *
@@ -80,7 +80,7 @@ public class ProcessWallops extends IRCProcessor {
80 80
     protected boolean callWalluser(final String message, final String host) {
81 81
         return getCallbackManager().getCallbackType(WalluserListener.class).call(message, host);
82 82
     }
83
-    
83
+
84 84
     /**
85 85
      * Callback to all objects implementing the WallDesync Callback.
86 86
      *
@@ -92,8 +92,8 @@ public class ProcessWallops extends IRCProcessor {
92 92
     protected boolean callWallDesync(final String message, final String host) {
93 93
         return getCallbackManager().getCallbackType(WallDesyncListener.class).call(message, host);
94 94
     }
95
-    
96
-    
95
+
96
+
97 97
     /**
98 98
      * What does this IRCProcessor handle.
99 99
      *
@@ -102,14 +102,16 @@ public class ProcessWallops extends IRCProcessor {
102 102
     @Override
103 103
     public String[] handles() {
104 104
         return new String[]{"WALLOPS"};
105
-    } 
106
-    
105
+    }
106
+
107 107
     /**
108 108
      * Create a new instance of the IRCProcessor Object.
109 109
      *
110 110
      * @param parser IRCParser That owns this IRCProcessor
111 111
      * @param manager ProcessingManager that is in charge of this IRCProcessor
112 112
      */
113
-    protected ProcessWallops(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
113
+    protected ProcessWallops(final IRCParser parser, final ProcessingManager manager) {
114
+        super(parser, manager);
115
+    }
114 116
 
115 117
 }

+ 12
- 10
src/com/dmdirc/parser/irc/ProcessWho.java Ver arquivo

@@ -50,11 +50,11 @@ public class ProcessWho extends IRCProcessor {
50 50
         //              0               1      2        3     4              5                      6       7     8      9
51 51
         // :server 352 mynickname channel username address server nick flags :hops info
52 52
         //     0    1      2         3     4          5      6      7    8        9
53
-        
53
+
54 54
         final IRCClientInfo client = getClientInfo(token[7]);
55 55
         if (client != null) {
56 56
             // Update ident/host
57
-            client.setUserBits(token[7]+"!"+token[4]+"@"+token[5], false);
57
+            client.setUserBits(token[7] + "!" + token[4] + "@" + token[5], false);
58 58
             // Update real name
59 59
             if (client.getRealname().isEmpty()) {
60 60
                 final String name = token[9].split(" ", 2)[1];
@@ -70,7 +70,7 @@ public class ProcessWho extends IRCProcessor {
70 70
                     callAwayState(oldState, client.getAwayState(), client.getAwayReason());
71 71
                 } else {
72 72
                     callAwayStateOther(client, oldState, isAway);
73
-                    
73
+
74 74
                     ChannelClientInfo iChannelClient;
75 75
                     for (ChannelInfo iChannel : myParser.getChannels()) {
76 76
                         iChannelClient = iChannel.getChannelClient(client);
@@ -82,7 +82,7 @@ public class ProcessWho extends IRCProcessor {
82 82
             }
83 83
         }
84 84
     }
85
-    
85
+
86 86
     /**
87 87
      * Callback to all objects implementing the onAwayState Callback.
88 88
      *
@@ -95,7 +95,7 @@ public class ProcessWho extends IRCProcessor {
95 95
     protected boolean callAwayState(final AwayState oldState, final AwayState currentState, final String reason) {
96 96
         return getCallbackManager().getCallbackType(AwayStateListener.class).call(oldState, currentState, reason);
97 97
     }
98
-    
98
+
99 99
     /**
100 100
      * Callback to all objects implementing the onAwayStateOther Callback.
101 101
      *
@@ -108,7 +108,7 @@ public class ProcessWho extends IRCProcessor {
108 108
     protected boolean callAwayStateOther(final ClientInfo client, final AwayState oldState, final AwayState state) {
109 109
         return getCallbackManager().getCallbackType(OtherAwayStateListener.class).call(client, oldState, state);
110 110
     }
111
-    
111
+
112 112
     /**
113 113
      * Callback to all objects implementing the onChannelAwayStateOther Callback.
114 114
      *
@@ -122,7 +122,7 @@ public class ProcessWho extends IRCProcessor {
122 122
     protected boolean callChannelAwayStateOther(final ChannelInfo channel, final ChannelClientInfo channelClient, final AwayState oldState, final AwayState state) {
123 123
         return getCallbackManager().getCallbackType(ChannelOtherAwayStateListener.class).call(channel, channelClient, oldState, state);
124 124
     }
125
-    
125
+
126 126
     /**
127 127
      * What does this IRCProcessor handle.
128 128
      *
@@ -131,14 +131,16 @@ public class ProcessWho extends IRCProcessor {
131 131
     @Override
132 132
     public String[] handles() {
133 133
         return new String[]{"352"};
134
-    } 
135
-    
134
+    }
135
+
136 136
     /**
137 137
      * Create a new instance of the IRCProcessor Object.
138 138
      *
139 139
      * @param parser IRCParser That owns this IRCProcessor
140 140
      * @param manager ProcessingManager that is in charge of this IRCProcessor
141 141
      */
142
-    protected ProcessWho(IRCParser parser, ProcessingManager manager) { super(parser, manager); }
142
+    protected ProcessWho(final IRCParser parser, final ProcessingManager manager) {
143
+        super(parser, manager);
144
+    }
143 145
 
144 146
 }

+ 9
- 9
src/com/dmdirc/parser/irc/ProcessingManager.java Ver arquivo

@@ -34,7 +34,7 @@ import java.util.Map;
34 34
  * @author Shane Mc Cormack
35 35
  */
36 36
 public class ProcessingManager {
37
-    /** Reference to the parser object that owns this ProcessingManager */
37
+    /** Reference to the parser object that owns this ProcessingManager. */
38 38
     IRCParser myParser;
39 39
 
40 40
     /** Hashtable used to store the different types of IRCProcessor known. */
@@ -52,7 +52,7 @@ public class ProcessingManager {
52 52
      *
53 53
      * @param parser IRCParser that owns this Processing Manager
54 54
      */
55
-    public ProcessingManager(IRCParser parser) {
55
+    public ProcessingManager(final IRCParser parser) {
56 56
         myParser = parser;
57 57
         //------------------------------------------------
58 58
         // Add processors
@@ -135,14 +135,14 @@ public class ProcessingManager {
135 135
      * @param handles String Array of tokens to add this processor as a hadler for
136 136
      */
137 137
     public void addProcessor(final String[] handles, final IRCProcessor processor) {
138
-        doDebug("Adding processor: "+processor.getName());
138
+        doDebug("Adding processor: " + processor.getName());
139 139
 
140 140
         for (int i = 0; i < handles.length; ++i) {
141 141
             if (processHash.containsKey(handles[i].toLowerCase())) {
142 142
                 // New Processors take priority over old ones
143 143
                 processHash.remove(handles[i].toLowerCase());
144 144
             }
145
-            doDebug("\t Added handler for: "+handles[i]);
145
+            doDebug("\t Added handler for: " + handles[i]);
146 146
             processHash.put(handles[i].toLowerCase(), processor);
147 147
         }
148 148
     }
@@ -154,12 +154,12 @@ public class ProcessingManager {
154 154
      */
155 155
     public void delProcessor(final IRCProcessor processor) {
156 156
         IRCProcessor testProcessor;
157
-        doDebug("Deleting processor: "+processor.getName());
157
+        doDebug("Deleting processor: " + processor.getName());
158 158
         for (String elementName : processHash.keySet()) {
159
-            doDebug("\t Checking handler for: "+elementName);
159
+            doDebug("\t Checking handler for: " + elementName);
160 160
             testProcessor = processHash.get(elementName);
161 161
             if (testProcessor.getName().equalsIgnoreCase(processor.getName())) {
162
-                doDebug("\t Removed handler for: "+elementName);
162
+                doDebug("\t Removed handler for: " + elementName);
163 163
                 processHash.remove(elementName);
164 164
             }
165 165
         }
@@ -176,7 +176,7 @@ public class ProcessingManager {
176 176
         if (processHash.containsKey(sParam.toLowerCase())) {
177 177
             return processHash.get(sParam.toLowerCase());
178 178
         } else {
179
-            throw new ProcessorNotFoundException("No processors will handle "+sParam);
179
+            throw new ProcessorNotFoundException("No processors will handle " + sParam);
180 180
         }
181 181
     }
182 182
 
@@ -195,7 +195,7 @@ public class ProcessingManager {
195 195
         } catch (ProcessorNotFoundException p) {
196 196
             throw p;
197 197
         } catch (Exception e) {
198
-            final ParserError ei = new ParserError(ParserError.ERROR_ERROR,"Exception in Processor. ["+messageProcessor+"]: "+e.getMessage(), myParser.getLastLine());
198
+            final ParserError ei = new ParserError(ParserError.ERROR_ERROR,"Exception in Processor. [" + messageProcessor + "]: " + e.getMessage(), myParser.getLastLine());
199 199
             ei.setException(e);
200 200
             myParser.callErrorInfo(ei);
201 201
         } finally {

+ 1
- 1
src/com/dmdirc/parser/irc/ProcessorNotFoundException.java Ver arquivo

@@ -34,7 +34,7 @@ public class ProcessorNotFoundException extends Exception {
34 34
      * objects being unserialized with the new class).
35 35
      */
36 36
     private static final long serialVersionUID = 1;
37
-    
37
+
38 38
     /**
39 39
      * Create a new ProcessorNotFound Exception.
40 40
      *

+ 17
- 7
src/com/dmdirc/parser/irc/ServerInfo.java Ver arquivo

@@ -58,11 +58,15 @@ public class ServerInfo {
58 58
     private String proxyUser = "";
59 59
     /** Proxy password if required. */
60 60
     private String proxyPass = "";
61
-    /** URI used to create this ServerInfo if applicable */
61
+    /** URI used to create this ServerInfo if applicable. */
62 62
     private URI uri = null;
63 63
 
64
-    /** Constructor using Default values. */
65
-    public ServerInfo() { }
64
+    /**
65
+     * Constructor using default values.
66
+     */
67
+    public ServerInfo() {
68
+        //Use default values
69
+    }
66 70
 
67 71
     /**
68 72
      * Constructor using specifed host, port and password, SSL/Proxy must be specifed separately.
@@ -127,7 +131,7 @@ public class ServerInfo {
127 131
             // stupid settings to setXXXX()
128 132
             // In this case, try to return any given URI, else a blank one.
129 133
             try {
130
-                return (uri != null) ? uri : new URI("");
134
+                return (uri == null) ? new URI("") : uri;
131 135
             } catch (URISyntaxException ex2) {
132 136
                 /* This can't ever happen. */
133 137
                 return null;
@@ -292,9 +296,15 @@ public class ServerInfo {
292 296
         }
293 297
 
294 298
         String channelString = uri.getPath();
295
-        if (uri.getRawQuery() != null && !uri.getRawQuery().isEmpty()) { channelString += "?" + uri.getRawQuery(); }
296
-        if (uri.getRawFragment() != null && !uri.getRawFragment().isEmpty()) { channelString += "#" + uri.getRawFragment(); }
297
-        if (channelString.startsWith("/")) { channelString = channelString.substring(1); }
299
+        if (uri.getRawQuery() != null && !uri.getRawQuery().isEmpty()) {
300
+            channelString += "?" + uri.getRawQuery();
301
+        }
302
+        if (uri.getRawFragment() != null && !uri.getRawFragment().isEmpty()) {
303
+            channelString += "#" + uri.getRawFragment();
304
+        }
305
+        if (channelString.startsWith("/")) {
306
+            channelString = channelString.substring(1);
307
+        }
298 308
 
299 309
         return channelString;
300 310
     }

+ 2
- 2
src/com/dmdirc/parser/irc/ServerType.java Ver arquivo

@@ -65,7 +65,7 @@ public enum ServerType {
65 65
     HYBRID7("hybrid7", ".*ircd.hybrid.*", "eI"),
66 66
     /** Older versions of Hybrid. */
67 67
     HYBRID("hybrid", ".*hybrid.*", "eI"),
68
-    /** Charybdis */
68
+    /** Charybdis. */
69 69
     CHARYBDIS("charybdis", ".*charybdis.*", "eI"),
70 70
     /** Freenodes New IRCD. */
71 71
     IRCD_SEVEN("ircd-seven", ".*ircd-seven.*", "eI"),
@@ -203,7 +203,7 @@ public enum ServerType {
203 203
     }
204 204
 
205 205
     /**
206
-     * Get the MatchType of this ServerType
206
+     * Get the MatchType of this ServerType.
207 207
      *
208 208
      * @return The MatchType of this ServerType
209 209
      */

+ 4
- 9
src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -41,7 +41,7 @@ public class OutputQueue {
41 41
     private boolean queueEnabled = true;
42 42
 
43 43
     /** The output queue! */
44
-    private BlockingQueue<QueueItem> queue = new PriorityBlockingQueue<QueueItem>();
44
+    private final BlockingQueue<QueueItem> queue = new PriorityBlockingQueue<QueueItem>();
45 45
 
46 46
     /** Thread for the sending queue. */
47 47
     private QueueHandler queueHandler;
@@ -50,11 +50,6 @@ public class OutputQueue {
50 50
     private QueueFactory queueFactory = PriorityQueueHandler.getFactory();
51 51
     // private QueueFactory queueFactory = SimpleRateLimitedQueueHandler.getFactory();
52 52
 
53
-    /**
54
-     * Create a new OutputQueue
55
-     */
56
-    public OutputQueue() { }
57
-
58 53
     /**
59 54
      * Set the output stream for this queue.
60 55
      *

+ 6
- 6
src/com/dmdirc/parser/irc/outputqueue/PriorityQueueHandler.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -32,12 +32,12 @@ import java.util.concurrent.BlockingQueue;
32 32
  */
33 33
 public class PriorityQueueHandler extends QueueHandler {
34 34
     /**
35
-     * Get a QueueFactory that produces PriorityQueueHandlers
35
+     * Get a QueueFactory that produces PriorityQueueHandlers.
36 36
      *
37 37
      * @return a QueueFactory that produces PrirortyQueueHandlers.
38 38
      */
39 39
     public static QueueFactory getFactory() {
40
-        return new QueueFactory(){
40
+        return new QueueFactory() {
41 41
             /** {@inheritDoc} */
42 42
             @Override
43 43
             public QueueHandler getQueueHandler(final OutputQueue outputQueue, final BlockingQueue<QueueItem> queue, final PrintWriter out) {
@@ -47,7 +47,7 @@ public class PriorityQueueHandler extends QueueHandler {
47 47
     }
48 48
 
49 49
     /**
50
-     * Create a new PriorityQueueHandler
50
+     * Create a new PriorityQueueHandler.
51 51
      *
52 52
      * @param outputQueue Owner of this Queue Handler
53 53
      * @param queue Queue to use

+ 19
- 2
src/com/dmdirc/parser/irc/outputqueue/QueueFactory.java Ver arquivo

@@ -1,6 +1,23 @@
1 1
 /*
2
- * To change this template, choose Tools | Templates
3
- * and open the template in the editor.
2
+ *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ *  of this software and associated documentation files (the "Software"), to deal
6
+ *  in the Software without restriction, including without limitation the rights
7
+ *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ *  copies of the Software, and to permit persons to whom the Software is
9
+ *  furnished to do so, subject to the following conditions:
10
+ *
11
+ *  The above copyright notice and this permission notice shall be included in
12
+ *  all copies or substantial portions of the Software.
13
+ *
14
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ *  SOFTWARE.
4 21
  */
5 22
 
6 23
 package com.dmdirc.parser.irc.outputqueue;

+ 6
- 6
src/com/dmdirc/parser/irc/outputqueue/QueueHandler.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -43,7 +43,7 @@ public abstract class QueueHandler extends Thread implements Comparator<QueueIte
43 43
     protected OutputQueue outputQueue;
44 44
 
45 45
     /**
46
-     * Create a new Queue Thread
46
+     * Create a new Queue Thread.
47 47
      *
48 48
      * @param outputQueue the OutputQueue that owns us.
49 49
      * @param queue Queue to handle
@@ -58,7 +58,7 @@ public abstract class QueueHandler extends Thread implements Comparator<QueueIte
58 58
     }
59 59
 
60 60
     /**
61
-     * Send the given item
61
+     * Send the given item.
62 62
      *
63 63
      * @param line Line to send.
64 64
      */
@@ -119,7 +119,7 @@ public abstract class QueueHandler extends Thread implements Comparator<QueueIte
119 119
      * This is the main even loop of the queue.
120 120
      * It needs to handle pulling items out of the queue and calling
121 121
      * sendLine.
122
-     * 
122
+     *
123 123
      * It also needs to handle any delays in sending that it deems needed.
124 124
      */
125 125
     @Override

+ 13
- 13
src/com/dmdirc/parser/irc/outputqueue/QueueItem.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -25,21 +25,21 @@ package com.dmdirc.parser.irc.outputqueue;
25 25
 import com.dmdirc.parser.common.QueuePriority;
26 26
 
27 27
 /**
28
- * Queued Item
28
+ * Queued Item.
29 29
  *
30 30
  * @author shane
31 31
  */
32 32
 public class QueueItem implements Comparable<QueueItem> {
33
-    /** Global Item Number*/
33
+    /** Global Item Number. */
34 34
     private static long number = 0L;
35 35
 
36
-    /** Line to send */
36
+    /** Line to send. */
37 37
     private final String line;
38 38
 
39 39
     /** Time this line was added. */
40 40
     private final long time;
41 41
 
42
-    /** Item Number */
42
+    /** Item Number. */
43 43
     private final long itemNumber;
44 44
 
45 45
     /** What is the priority of this line? */
@@ -49,7 +49,7 @@ public class QueueItem implements Comparable<QueueItem> {
49 49
     private final QueueHandler handler;
50 50
 
51 51
     /**
52
-     * Get the value of line
52
+     * Get the value of line.
53 53
      *
54 54
      * @return the value of line
55 55
      */
@@ -58,7 +58,7 @@ public class QueueItem implements Comparable<QueueItem> {
58 58
     }
59 59
 
60 60
     /**
61
-     * Get the value of time
61
+     * Get the value of time.
62 62
      *
63 63
      * @return the value of time
64 64
      */
@@ -67,7 +67,7 @@ public class QueueItem implements Comparable<QueueItem> {
67 67
     }
68 68
 
69 69
     /**
70
-     * Get the number of this item
70
+     * Get the number of this item.
71 71
      *
72 72
      * @return the value of itemNumber
73 73
      */
@@ -76,7 +76,7 @@ public class QueueItem implements Comparable<QueueItem> {
76 76
     }
77 77
 
78 78
     /**
79
-     * Get the value of priority
79
+     * Get the value of priority.
80 80
      *
81 81
      * @return the value of priority
82 82
      */
@@ -85,11 +85,11 @@ public class QueueItem implements Comparable<QueueItem> {
85 85
     }
86 86
 
87 87
     /**
88
-     * Create a new QueueItem
88
+     * Create a new QueueItem.
89 89
      *
90 90
      * @param handler Handler for this QueueItem
91 91
      * @param line Line to send
92
-     * @param priority
92
+     * @param priority Priority for the queue item
93 93
      */
94 94
     public QueueItem(final QueueHandler handler, final String line, final QueuePriority priority) {
95 95
         this.handler = handler;

+ 15
- 15
src/com/dmdirc/parser/irc/outputqueue/SimpleRateLimitedQueueHandler.java Ver arquivo

@@ -1,16 +1,16 @@
1 1
 /*
2 2
  *  Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- * 
3
+ *
4 4
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
5 5
  *  of this software and associated documentation files (the "Software"), to deal
6 6
  *  in the Software without restriction, including without limitation the rights
7 7
  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 8
  *  copies of the Software, and to permit persons to whom the Software is
9 9
  *  furnished to do so, subject to the following conditions:
10
- * 
10
+ *
11 11
  *  The above copyright notice and this permission notice shall be included in
12 12
  *  all copies or substantial portions of the Software.
13
- * 
13
+ *
14 14
  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 15
  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 16
  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -36,12 +36,12 @@ import java.util.concurrent.BlockingQueue;
36 36
  */
37 37
 public class SimpleRateLimitedQueueHandler extends QueueHandler {
38 38
     /**
39
-     * Get a QueueFactory that produces PriorityQueueHandlers
39
+     * Get a QueueFactory that produces PriorityQueueHandlers.
40 40
      *
41 41
      * @return a QueueFactory that produces PrirortyQueueHandlers.
42 42
      */
43 43
     public static QueueFactory getFactory() {
44
-        return new QueueFactory(){
44
+        return new QueueFactory() {
45 45
             /** {@inheritDoc} */
46 46
             @Override
47 47
             public QueueHandler getQueueHandler(final OutputQueue outputQueue, final BlockingQueue<QueueItem> queue, final PrintWriter out) {
@@ -72,7 +72,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
72 72
     private boolean alwaysUpdateTime = true;
73 73
 
74 74
     /**
75
-     * Create a new SimpleRateLimitedQueueHandler
75
+     * Create a new SimpleRateLimitedQueueHandler.
76 76
      *
77 77
      * @param outputQueue Owner of this Queue Handler
78 78
      * @param queue Queue to use
@@ -84,7 +84,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
84 84
 
85 85
     /**
86 86
      * Get the number of items needed to activate rate limiting.
87
-     * 
87
+     *
88 88
      * @return Number of items needed to activate rate limiting.
89 89
      */
90 90
     public int getItems() {
@@ -159,7 +159,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
159 159
      *
160 160
      * If true, assuming the default settings) items sent at 0, 3, 6, 9 will
161 161
      * activate rate limiting, if false it would need to be 0, 1, 2, 3.
162
-     * 
162
+     *
163 163
      * @param alwaysUpdateTime Should LastItemTime always updated?
164 164
      */
165 165
     public void setAlwaysUpdateTime(final boolean alwaysUpdateTime) {
@@ -168,7 +168,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
168 168
 
169 169
     /**
170 170
      * Are we currently limiting?
171
-     * 
171
+     *
172 172
      * @return True if limiting is active.
173 173
      */
174 174
     public boolean isLimiting() {
@@ -183,16 +183,16 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
183 183
      */
184 184
     @Override
185 185
     public int compare(final QueueItem mainObject, final QueueItem otherObject) {
186
-        if (mainObject.getPriority().compareTo(otherObject.getPriority()) != 0) {
187
-            return mainObject.getPriority().compareTo(otherObject.getPriority());
188
-        } else {
186
+        if (mainObject.getPriority().compareTo(otherObject.getPriority()) == 0) {
189 187
             return super.compare(mainObject, otherObject);
188
+        } else {
189
+            return mainObject.getPriority().compareTo(otherObject.getPriority());
190 190
         }
191 191
     }
192 192
 
193 193
     /** {@inheritDoc} */
194 194
     @Override
195
-    public QueueItem getQueueItem(String line, QueuePriority priority) {
195
+    public QueueItem getQueueItem(final String line, final QueuePriority priority) {
196 196
         // Was the last line added less than limitTime ago?
197 197
         synchronized (this) {
198 198
             final boolean overTime = (lastItemTime + limitTime > System.currentTimeMillis());
@@ -219,7 +219,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
219 219
                 lastItemTime = System.currentTimeMillis();
220 220
             }
221 221
         }
222
-        
222
+
223 223
         return super.getQueueItem(line, priority);
224 224
     }
225 225
 
@@ -229,7 +229,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
229 229
         try {
230 230
             while (outputQueue.isQueueEnabled()) {
231 231
                 final QueueItem item = queue.take();
232
-                
232
+
233 233
                 sendLine(item.getLine());
234 234
 
235 235
                 final boolean doSleep;

Carregando…
Cancelar
Salvar