Преглед изворни кода

Style fixes

Change-Id: Ic91544916082a64c1add84fd9e0b68dd91552c40
Reviewed-on: http://gerrit.dmdirc.com/1598
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.5
Gregory Holmes пре 13 година
родитељ
комит
6e2c46187b

+ 6
- 14
src/com/dmdirc/parser/common/CallbackObjectSpecific.java Прегледај датотеку

@@ -65,13 +65,9 @@ public abstract class CallbackObjectSpecific extends CallbackObject {
65 65
      * @return true if channel given matches the specifics for the method given
66 66
      */
67 67
     protected boolean isValidChan(final CallbackInterface eMethod, final ChannelInfo cChannel) {
68
-        if (specificData.containsKey(eMethod)) {
69
-            if (!myParser.getStringConverter().equalsIgnoreCase(cChannel.getName(),
70
-                    specificData.get(eMethod))) {
71
-                return false;
72
-            }
73
-        }
74
-        return true;
68
+        return !(specificData.containsKey(eMethod) && !myParser
69
+                .getStringConverter().equalsIgnoreCase(cChannel.getName(),
70
+                specificData.get(eMethod)));
75 71
     }
76 72
 
77 73
     /**
@@ -83,13 +79,9 @@ public abstract class CallbackObjectSpecific extends CallbackObject {
83 79
      */
84 80
     protected boolean isValidUser(final CallbackInterface eMethod, final String sHost) {
85 81
         final String nickname = translateHostname(sHost);
86
-        if (specificData.containsKey(eMethod)) {
87
-            if (!myParser.getStringConverter().equalsIgnoreCase(nickname,
88
-                    specificData.get(eMethod))) {
89
-                return false;
90
-            }
91
-        }
92
-        return true;
82
+        return !(specificData.containsKey(eMethod) && !myParser
83
+                .getStringConverter().equalsIgnoreCase(nickname,
84
+                specificData.get(eMethod)));
93 85
     }
94 86
 
95 87
     /**

+ 3
- 2
src/com/dmdirc/parser/irc/ProcessKick.java Прегледај датотеку

@@ -53,9 +53,10 @@ public class ProcessKick extends IRCProcessor {
53 53
         
54 54
         if (iClient == null) { return; }
55 55
         
56
-        if (IRCParser.ALWAYS_UPDATECLIENT && iKicker != null) {
56
+        if ((IRCParser.ALWAYS_UPDATECLIENT && iKicker != null)
57
+                && iKicker.getHostname().isEmpty()) {
57 58
             // To facilitate dmdirc formatter, get user information
58
-            if (iKicker.getHostname().isEmpty()) { iKicker.setUserBits(token[0], false); }
59
+            iKicker.setUserBits(token[0], false);
59 60
         }
60 61
 
61 62
         if (iChannel == null) { 

+ 37
- 27
src/com/dmdirc/parser/irc/ProcessMessage.java Прегледај датотеку

@@ -110,33 +110,42 @@ public class ProcessMessage extends IRCProcessor {
110 110
         boolean isCTCP = false;
111 111
 
112 112
         if (sMessage.length() > 1) {
113
-            if (sParam.equalsIgnoreCase("PRIVMSG")) {
114
-                // Actions are special CTCPs
115
-                // Bits is the message been split into 2 parts, the first word and the rest
116
-                if (bits[0].equalsIgnoreCase(char1+"ACTION") && Character.valueOf(sMessage.charAt(sMessage.length()-1)).equals(char1)) {
117
-                    isAction = true;
118
-                    if (bits.length > 1) {
119
-                        sMessage = bits[1];
120
-                        sMessage = sMessage.substring(0, sMessage.length()-1);
121
-                    } else { sMessage = ""; }
122
-                }
113
+            // Actions are special CTCPs
114
+            // Bits is the message been split into 2 parts
115
+            //         the first word and the rest
116
+            if (sParam.equalsIgnoreCase("PRIVMSG") && bits[0].equalsIgnoreCase(
117
+                    char1+"ACTION") && Character.valueOf(sMessage.charAt(
118
+                    sMessage.length()-1)).equals(char1)) {
119
+                isAction = true;
120
+                if (bits.length > 1) {
121
+                    sMessage = bits[1];
122
+                    sMessage = sMessage.substring(0, sMessage.length()-1);
123
+                } else { sMessage = ""; }
123 124
             }
124 125
             // If the message is not an action, check if it is another type of CTCP
125
-            if (!isAction) {
126
-                // CTCPs have Character(1) at the start/end of the line
127
-                if (Character.valueOf(sMessage.charAt(0)).equals(char1) && Character.valueOf(sMessage.charAt(sMessage.length()-1)).equals(char1)) {
128
-                    isCTCP = true;
129
-                    // Bits is the message been split into 2 parts, the first word and the rest
130
-                    // Some CTCPs have messages and some do not
131
-                    if (bits.length > 1) { sMessage = bits[1]; } else { sMessage = ""; }
132
-                    // Remove the leading char1
133
-                    bits = bits[0].split(char1.toString(), 2);
134
-                    sCTCP = bits[1];
135
-                    // remove the trailing char1
136
-                    if (!sMessage.isEmpty()) { sMessage = sMessage.split(char1.toString(), 2)[0]; }
137
-                    else { sCTCP = sCTCP.split(char1.toString(), 2)[0]; }
138
-                    callDebugInfo(IRCParser.DEBUG_INFO, "CTCP: \"%s\" \"%s\"", sCTCP, sMessage);
126
+            // CTCPs have Character(1) at the start/end of the line
127
+            if (!isAction && Character.valueOf(sMessage.charAt(0)).equals(char1)
128
+                    && Character.valueOf(sMessage.charAt(sMessage.length()-1))
129
+                    .equals(char1)) {
130
+                isCTCP = true;
131
+                // Bits is the message been split into 2 parts, the first word and the rest
132
+                // Some CTCPs have messages and some do not
133
+                if (bits.length > 1) {
134
+                    sMessage = bits[1];
135
+                } else {
136
+                    sMessage = "";
137
+                }
138
+                // Remove the leading char1
139
+                bits = bits[0].split(char1.toString(), 2);
140
+                sCTCP = bits[1];
141
+                // remove the trailing char1
142
+                if (!sMessage.isEmpty()) {
143
+                    sMessage = sMessage.split(char1.toString(), 2)[0];
144
+                } else {
145
+                    sCTCP = sCTCP.split(char1.toString(), 2)[0];
139 146
                 }
147
+                callDebugInfo(IRCParser.DEBUG_INFO, "CTCP: \"%s\" \"%s\"",
148
+                        sCTCP, sMessage);
140 149
             }
141 150
         }
142 151
 
@@ -144,9 +153,10 @@ public class ProcessMessage extends IRCProcessor {
144 153
         if (token[0].charAt(0) == ':' && token[0].length() > 1) { token[0] = token[0].substring(1); }
145 154
 
146 155
         iClient = getClientInfo(token[0]);
147
-        if (IRCParser.ALWAYS_UPDATECLIENT && iClient != null) {
148
-            // Facilitate DMDIRC Formatter
149
-            if (iClient.getHostname().isEmpty()) {iClient.setUserBits(token[0], false); }
156
+        // Facilitate DMDIRC Formatter
157
+        if ((IRCParser.ALWAYS_UPDATECLIENT && iClient != null) && iClient
158
+                .getHostname().isEmpty()) {
159
+            iClient.setUserBits(token[0], false);
150 160
         }
151 161
 
152 162
         // Fire the appropriate callbacks.

+ 4
- 3
src/com/dmdirc/parser/irc/ProcessMode.java Прегледај датотеку

@@ -118,9 +118,10 @@ public class ProcessMode extends IRCProcessor {
118 118
         if (!sParam.equals("324")) { nCurrent = iChannel.getMode(); }
119 119
 
120 120
         setterCCI = iChannel.getChannelClient(token[0]);
121
-        if (IRCParser.ALWAYS_UPDATECLIENT && setterCCI != null) {
122
-            // Facilitate dmdirc formatter
123
-            if (setterCCI.getClient().getHostname().isEmpty()) {setterCCI.getClient().setUserBits(token[0], false); }
121
+        // Facilitate dmdirc formatter
122
+        if ((IRCParser.ALWAYS_UPDATECLIENT && setterCCI != null) && setterCCI
123
+                .getClient().getHostname().isEmpty()) {
124
+            setterCCI.getClient().setUserBits(token[0], false);
124 125
         }
125 126
 
126 127
         // Loop through the mode string, and add/remove modes/params where they are needed

+ 3
- 4
src/com/dmdirc/parser/irc/ProcessNames.java Прегледај датотеку

@@ -51,10 +51,9 @@ public class ProcessNames extends IRCProcessor {
51 51
             iChannel.setAddingNames(false);
52 52
             callChannelGotNames(iChannel);
53 53
             
54
-            if (!iChannel.hasAskedForListModes()) {
55
-                if (myParser.getAutoListMode()) {
56
-                    iChannel.requestListModes();
57
-                }
54
+            if (!iChannel.hasAskedForListModes() 
55
+                    && myParser.getAutoListMode()) {
56
+                iChannel.requestListModes();
58 57
             }
59 58
         } else {
60 59
             // Names

+ 5
- 10
src/com/dmdirc/parser/irc/outputqueue/SimpleRateLimitedQueueHandler.java Прегледај датотеку

@@ -199,12 +199,9 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
199 199
             if (overTime) {
200 200
                 // If we are not currently limiting, and this is the items-th item
201 201
                 // added in the last limitTime, start limiting.
202
-                if (!isLimiting) {
203
-                    if (++count > (items - 1)) {
204
-                        System.out.println("++ Begin Limiting");
205
-                        isLimiting = true;
206
-                        count = 0;
207
-                    }
202
+                if (!isLimiting && ++count > (items - 1)) {
203
+                    isLimiting = true;
204
+                    count = 0;
208 205
                 }
209 206
             } else if (!isLimiting) {
210 207
                 // If it has been more than limitTime seconds since the last line
@@ -238,10 +235,8 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
238 235
                 final boolean doSleep;
239 236
                 synchronized (this) {
240 237
                     doSleep = isLimiting;
241
-                    if (isLimiting) {
242
-                        if (queue.size() == 0) {
243
-                            isLimiting = false;
244
-                        }
238
+                    if (isLimiting && queue.size() == 0) {
239
+                        isLimiting = false;
245 240
                     }
246 241
                 }
247 242
 

Loading…
Откажи
Сачувај