File Source: Debug.java
/*
P/P * Method: com.dmdirc.commandparser.commands.global.Debug__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 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.
21 */
22
23 package com.dmdirc.commandparser.commands.global;
24
25 import com.dmdirc.Main;
26 import com.dmdirc.Server;
27 import com.dmdirc.commandparser.CommandArguments;
28 import com.dmdirc.commandparser.CommandManager;
29 import com.dmdirc.commandparser.commands.GlobalCommand;
30 import com.dmdirc.commandparser.commands.IntelligentCommand;
31 import com.dmdirc.config.ConfigManager;
32 import com.dmdirc.config.Identity;
33 import com.dmdirc.config.IdentityManager;
34 import com.dmdirc.logger.ErrorLevel;
35 import com.dmdirc.logger.Logger;
36 import com.dmdirc.plugins.PluginManager;
37 import com.dmdirc.plugins.Service;
38 import com.dmdirc.plugins.ServiceProvider;
39 import com.dmdirc.ui.input.AdditionalTabTargets;
40 import com.dmdirc.ui.interfaces.InputWindow;
41 import com.dmdirc.ui.messages.Styliser;
42 import com.dmdirc.updater.UpdateChecker;
43
44 import java.io.Serializable;
45 import java.util.Comparator;
46 import java.util.List;
47 import java.util.Map;
48 import java.util.Map.Entry;
49 import java.util.TreeSet;
50
51 /**
52 * Provides various handy ways to test or debug the client.
53 *
54 * @author Chris
55 */
56 public class Debug extends GlobalCommand implements IntelligentCommand {
57
58 /**
59 * Creates a new instance of Debug.
60 */
/*
P/P * Method: void com.dmdirc.commandparser.commands.global.Debug()
*
* Preconditions:
* init'ed(com/dmdirc/commandparser/CommandManager.commandChar)
*/
61 public Debug() {
62 CommandManager.registerCommand(this);
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public void execute(final InputWindow origin, final boolean isSilent,
68 final CommandArguments args) {
/*
P/P * Method: void execute(InputWindow, bool, CommandArguments)
*
* Preconditions:
* args != null
* init'ed(args.words)
* (soft) args.line != null
* (soft) init'ed(com.dmdirc.config.ConfigManager$1__static_init.new int[](ConfigManager$1__static_init#1)[...])
* (soft) init'ed(com/dmdirc/commandparser/CommandManager.commandChar)
* (soft) init'ed(com/dmdirc/config/IdentityManager.globalconfig)
* (soft) origin != null
*
* Presumptions:
* com.dmdirc.Main:getUI(...)@100 != null
* com.dmdirc.Main:getUI(...)@102 != null
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@104 != null
* getArguments(...).length@101 >= 1
* getArguments(...).length@103 >= 1
* ...
*
* Postconditions:
* args.words != null
* init'ed(com/dmdirc/config/IdentityManager.globalconfig)
* init'ed(java.lang.String:split(...)._tainted)
* java.lang.String:split(...)._tainted == 0
* init'ed(java.lang.String:split(...).length)
* java.lang.StringBuilder:toString(...)._tainted == 0
* new ArrayList(getSources#1) num objects <= 1
* new ConfigManager(getGlobalConfig#1) num objects <= 1
* init'ed(new ConfigManager(getGlobalConfig#1).channel)
* init'ed(new ConfigManager(getGlobalConfig#1).ircd)
* ...
*
* Test Vectors:
* getArguments(...).length@69: {1..+Inf}, {0}
* java.lang.String:equals(...)@101: {0}, {1}
* java.lang.String:equals(...)@103: {0}, {1}
* java.lang.String:equals(...)@71: {0}, {1}
* java.lang.String:equals(...)@73: {0}, {1}
* java.lang.String:equals(...)@75: {0}, {1}
* java.lang.String:equals(...)@77: {0}, {1}
* java.lang.String:equals(...)@79: {0}, {1}
* java.lang.String:equals(...)@81: {0}, {1}
* java.lang.String:equals(...)@83: {0}, {1}
* ...
*/
69 if (args.getArguments().length == 0) {
70 showUsage(origin, isSilent, "debug", "<debug command> [options]");
71 } else if ("error".equals(args.getArguments()[0])) {
72 doError(args.getArguments());
73 } else if ("showraw".equals(args.getArguments()[0])) {
74 doShowRaw(origin, isSilent);
75 } else if ("configstats".equals(args.getArguments()[0])) {
76 doConfigStats(origin, isSilent);
77 } else if ("configinfo".equals(args.getArguments()[0])) {
78 doConfigInfo(origin, isSilent);
79 } else if ("globalconfiginfo".equals(args.getArguments()[0])) {
80 doGlobalConfigInfo(origin, isSilent);
81 } else if ("colourspam".equals(args.getArguments()[0])) {
82 doColourSpam(origin, isSilent);
83 } else if ("meminfo".equals(args.getArguments()[0])) {
84 doMemInfo(origin, isSilent);
85 } else if ("rungc".equals(args.getArguments()[0])) {
86 doGarbage(origin, isSilent);
87 } else if ("threads".equals(args.getArguments()[0])) {
88 doThreads(origin, isSilent);
89 } else if ("forceupdate".equals(args.getArguments()[0])) {
90 doForceUpdate();
91 } else if ("serverinfo".equals(args.getArguments()[0])) {
92 doServerInfo(origin, isSilent);
93 } else if ("serverstate".equals(args.getArguments()[0])) {
94 doServerState(origin, isSilent);
95 } else if ("benchmark".equals(args.getArguments()[0])) {
96 doBenchmark(origin);
97 } else if ("services".equals(args.getArguments()[0])) {
98 doServices(origin, isSilent, args.getArguments());
99 } else if ("firstrun".equals(args.getArguments()[0])) {
100 Main.getUI().showFirstRunWizard();
101 } else if ("migration".equals(args.getArguments()[0])) {
102 Main.getUI().showMigrationWizard();
103 } else if ("notify".equals(args.getArguments()[0])) {
104 sendLine(origin, isSilent, FORMAT_OUTPUT, "Current notification colour is: "
105 + origin.getContainer().getNotification());
106 } else {
107 sendLine(origin, isSilent, FORMAT_ERROR, "Unknown debug action.");
108 }
109 }
110
111 /**
112 * Generates a fake error.
113 *
114 * @param args The arguments that were passed to the command
115 */
116 private void doError(final String ... args) {
/*
P/P * Method: void doError(String[])
*
* Preconditions:
* args != null
* (soft) args[1] != null
* (soft) args[2] != null
*
* Presumptions:
* init'ed(com.dmdirc.logger.ErrorLevel.FATAL)
* init'ed(com.dmdirc.logger.ErrorLevel.HIGH)
* init'ed(com.dmdirc.logger.ErrorLevel.LOW)
* init'ed(com.dmdirc.logger.ErrorLevel.MEDIUM)
* init'ed(com.dmdirc.logger.ErrorLevel.UNKNOWN)
*
* Test Vectors:
* args.length: {0,1}, {3..+Inf}
* java.lang.String:equals(...)@121: {0}, {1}
* java.lang.String:equals(...)@123: {0}, {1}
* java.lang.String:equals(...)@125: {0}, {1}
* java.lang.String:equals(...)@127: {0}, {1}
* java.lang.String:equals(...)@132: {0}, {1}
*/
117 ErrorLevel el = ErrorLevel.HIGH;
118 if (args.length > 2) {
119 final String level = args[2];
120
121 if (level.equals("low")) {
122 el = ErrorLevel.LOW;
123 } else if (level.equals("medium")) {
124 el = ErrorLevel.MEDIUM;
125 } else if (level.equals("fatal")) {
126 el = ErrorLevel.FATAL;
127 } else if (level.equals("unknown")) {
128 el = ErrorLevel.UNKNOWN;
129 }
130 }
131
132 if (args.length > 1 && args[1].equals("user")) {
133 Logger.userError(el, "Debug error message");
134 } else {
135 Logger.appError(el, "Debug error message", new Exception());
136 }
137 }
138
139 /**
140 * Attempts to show the server's raw window.
141 *
142 * @param origin The window this command was executed in
143 * @param isSilent Whether this command has been silenced or not
144 */
145 private void doShowRaw(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doShowRaw(InputWindow, bool)
*
* Presumptions:
* com.dmdirc.WritableFrameContainer:getServer(...)@150 != null
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@146 != null
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@150 != null
*
* Test Vectors:
* origin: Addr_Set{null}, Inverse{null}
* com.dmdirc.WritableFrameContainer:getServer(...)@146: Inverse{null}, Addr_Set{null}
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@146: Addr_Set{null}, Inverse{null}
*/
146 if (origin == null || origin.getContainer() == null
147 || origin.getContainer().getServer() == null) {
148 sendLine(origin, isSilent, FORMAT_ERROR, "Cannot show raw window here.");
149 } else {
150 origin.getContainer().getServer().addRaw();
151 }
152 }
153
154 /**
155 * Shows stats related to the config system.
156 *
157 * @param origin The window this command was executed in
158 * @param isSilent Whether this command has been silenced or not
159 */
160 private void doConfigStats(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doConfigStats(InputWindow, bool)
*
* Presumptions:
* java.util.Iterator:next(...)@164 != null
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@164: {0}, {1}
*/
161 final TreeSet<Entry<String, Integer>> sortedStats =
162 new TreeSet<Entry<String, Integer>>(new ValueComparator());
163 sortedStats.addAll(ConfigManager.getStats().entrySet());
164 for (Map.Entry<String, Integer> entry : sortedStats) {
165 sendLine(origin, isSilent, FORMAT_OUTPUT,
166 entry.getKey() + " - " + entry.getValue());
167 }
168 }
169
170 /**
171 * Shows memory usage information.
172 *
173 * @param origin The window this command was executed in
174 * @param isSilent Whether this command has been silenced or not
175 */
176 private void doMemInfo(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doMemInfo(InputWindow, bool)
*
* Presumptions:
* java.lang.Runtime:freeMemory(...)@181 - java.lang.Runtime:totalMemory(...)@181 in {-264+1..263}
* java.lang.Runtime:getRuntime(...)@177 != null
* java.lang.Runtime:getRuntime(...)@179 != null
* java.lang.Runtime:getRuntime(...)@181 != null
*/
177 sendLine(origin, isSilent, FORMAT_OUTPUT, "Total Memory: "
178 + Runtime.getRuntime().totalMemory());
179 sendLine(origin, isSilent, FORMAT_OUTPUT, "Free Memory: "
180 + Runtime.getRuntime().freeMemory());
181 sendLine(origin, isSilent, FORMAT_OUTPUT, "Used Memory: "
182 + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
183 }
184
185 /**
186 * Outputs 100 lines containing various colours.
187 *
188 * @param origin The window this command was executed in
189 * @param isSilent Whether this command has been silenced or not
190 */
191 private void doColourSpam(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doColourSpam(InputWindow, bool)
*/
192 for (int i = 0; i < 100; i++) {
193 sendLine(origin, isSilent, FORMAT_OUTPUT, ((char) 3) + "5Colour! "
194 + ((char) 3) + "6Colour! " + ((char) 3) + "7Colour! "
195 + ((char) 3) + "6Colour! " + ((char) 3) + "7Colour! "
196 + ((char) 3) + "6Colour! " + ((char) 3) + "7Colour! "
197 + ((char) 3) + "6Colour! " + ((char) 3) + "7Colour! ");
198 }
199 }
200
201 /**
202 * Manually runs the garbage collector.
203 *
204 * @param origin The window this command was executed in
205 * @param isSilent Whether this command has been silenced or not
206 */
207 private void doGarbage(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doGarbage(InputWindow, bool)
*/
208 System.gc();
209 sendLine(origin, isSilent, FORMAT_OUTPUT, "Invoked garbage collector.");
210 }
211
212 /**
213 * Shows information about the config manager.
214 *
215 * @param origin The window this command was executed in
216 * @param isSilent Whether this command has been silenced or not
217 */
218 private void doConfigInfo(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doConfigInfo(InputWindow, bool)
*
* Preconditions:
* origin != null
*
* Presumptions:
* com.dmdirc.ui.interfaces.InputWindow:getConfigManager(...)@219 != null
* java.util.Iterator:next(...)@219 != null
* source.myTarget@219 != null
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@219: {0}, {1}
*/
219 for (Identity source : origin.getConfigManager().getSources()) {
220 sendLine(origin, isSilent, FORMAT_OUTPUT, source.getTarget() + " - "
221 + source + "(" + source.getTarget().getOrder() + ")");
222 }
223 }
224
225 /**
226 * Shows information about the global config manager.
227 *
228 * @param origin The window this command was executed in
229 * @param isSilent Whether this command has been silenced or not
230 */
231 private void doGlobalConfigInfo(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doGlobalConfigInfo(InputWindow, bool)
*
* Preconditions:
* init'ed(com/dmdirc/config/IdentityManager.globalconfig)
* (soft) init'ed(com.dmdirc.config.ConfigManager$1__static_init.new int[](ConfigManager$1__static_init#1)[...])
*
* Presumptions:
* java.util.Iterator:next(...)@232 != null
* source.myTarget@232 != null
*
* Postconditions:
* com/dmdirc/config/IdentityManager.globalconfig == One-of{old com/dmdirc/config/IdentityManager.globalconfig, &new ConfigManager(getGlobalConfig#1)}
* com/dmdirc/config/IdentityManager.globalconfig != null
* java.lang.StringBuilder:toString(...)._tainted == 0
* new ArrayList(getSources#1) num objects <= 1
* new ConfigManager(getGlobalConfig#1) num objects == new ArrayList(getSources#1) num objects
* new MapList(ConfigManager#1) num objects == new ArrayList(getSources#1) num objects
* new ConfigManager(getGlobalConfig#1).channel == &java.lang.StringBuilder:toString(...)
* new ConfigManager(getGlobalConfig#1).ircd == &""
* new ConfigManager(getGlobalConfig#1).network == &""
* new ConfigManager(getGlobalConfig#1).server == &""
* ...
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@232: {0}, {1}
*/
232 for (Identity source : IdentityManager.getGlobalConfig().getSources()) {
233 sendLine(origin, isSilent, FORMAT_OUTPUT, source.getTarget() + " - "
234 + source + "(" + source.getTarget().getOrder() + ")");
235 }
236 }
237
238 /**
239 * Forces the update checker to check for updates.
240 */
241 private void doForceUpdate() {
/*
P/P * Method: void doForceUpdate()
*/
242 new Thread(new UpdateChecker(), "Forced update checker").start();
243 }
244
245 /**
246 * Shows information about active threads.
247 *
248 * @param origin The window this command was executed in
249 * @param isSilent Whether this command has been silenced or not
250 */
251 private void doThreads(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doThreads(InputWindow, bool)
*
* Presumptions:
* arr$.length@256 <= 232-1
* arr$[i$]@256 != null
* java.lang.Thread:getAllStackTraces(...)@252 != null
* java.util.Iterator:next(...)@252 != null
* java.util.Map:entrySet(...)@252 != null
* ...
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@252: {0}, {1}
*/
252 for (Entry<Thread, StackTraceElement[]> thread: Thread.getAllStackTraces().entrySet()) {
253 sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_BOLD
254 + thread.getKey().getName());
255
256 for (StackTraceElement element : thread.getValue()) {
257 sendLine(origin, isSilent, FORMAT_OUTPUT, Styliser.CODE_FIXED
258 + " " + element.toString());
259 }
260 }
261 }
262
263 /**
264 * Shows information about the current server's state.
265 *
266 * @param origin The window this command was executed in
267 * @param isSilent Whether this command has been silenced or not
268 */
269 private void doServerState(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doServerState(InputWindow, bool)
*
* Preconditions:
* origin != null
*
* Presumptions:
* com.dmdirc.Server:getStatus(...)@274 != null
* com.dmdirc.WritableFrameContainer:getServer(...)@273 != null
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@270 != null
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@273 != null
*
* Test Vectors:
* com.dmdirc.WritableFrameContainer:getServer(...)@270: Inverse{null}, Addr_Set{null}
*/
270 if (origin.getContainer().getServer() == null) {
271 sendLine(origin, isSilent, FORMAT_ERROR, "This window isn't connected to a server");
272 } else {
273 final Server server = origin.getContainer().getServer();
274 sendLine(origin, isSilent, FORMAT_OUTPUT, server.getStatus().getTransitionHistory());
275 }
276 }
277
278 /**
279 * Shows information about the current server.
280 *
281 * @param origin The window this command was executed in
282 * @param isSilent Whether this command has been silenced or not
283 */
284 private void doServerInfo(final InputWindow origin, final boolean isSilent) {
/*
P/P * Method: void doServerInfo(InputWindow, bool)
*
* Preconditions:
* origin != null
*
* Presumptions:
* com.dmdirc.Server:getParser(...)@290 != null
* com.dmdirc.Server:getParser(...)@293 != null
* com.dmdirc.Server:getParser(...)@296 != null
* com.dmdirc.WritableFrameContainer:getServer(...)@288 != null
* com.dmdirc.ui.interfaces.InputWindow:getContainer(...)@285 != null
* ...
*
* Test Vectors:
* com.dmdirc.WritableFrameContainer:getServer(...)@285: Inverse{null}, Addr_Set{null}
*/
285 if (origin.getContainer().getServer() == null) {
286 sendLine(origin, isSilent, FORMAT_ERROR, "This window isn't connected to a server");
287 } else {
288 final Server server = origin.getContainer().getServer();
289 sendLine(origin, isSilent, FORMAT_OUTPUT, "Server name: " + server.getName());
290 sendLine(origin, isSilent, FORMAT_OUTPUT, "Actual name: "
291 + server.getParser().getServerName());
292 sendLine(origin, isSilent, FORMAT_OUTPUT, "Network: " + server.getNetwork());
293 sendLine(origin, isSilent, FORMAT_OUTPUT, "IRCd: "
294 + server.getParser().getIRCD(false) + " - "
295 + server.getParser().getIRCD(true));
296 sendLine(origin, isSilent, FORMAT_OUTPUT, "Modes: "
297 + server.getParser().getBoolChanModes() + " "
298 + server.getParser().getListChanModes() + " "
299 + server.getParser().getSetOnlyChanModes() + " "
300 + server.getParser().getSetUnsetChanModes());
301 }
302 }
303
304 /**
305 * Benchmarks the textpane.
306 *
307 * @param origin The window this command was executed in
308 */
309 private void doBenchmark(final InputWindow origin) {
/*
P/P * Method: void doBenchmark(InputWindow)
*
* Preconditions:
* (soft) origin != null
*
* Presumptions:
* java.lang.System:nanoTime(...)@319 - java.lang.System:nanoTime(...)@313 in {-263..264-1}
*/
310 long[] results = new long[10];
311
312 for (int i = 0; i < results.length; i++) {
313 final long start = System.nanoTime();
314
315 for (int j = 0; j < 5000; j++) {
316 origin.addLine(FORMAT_OUTPUT, "This is a benchmark. Lorem ipsum doler...");
317 }
318
319 final long end = System.nanoTime();
320
321 results[i] = end - start;
322 }
323
324 for (int i = 0; i < results.length; i++) {
325 origin.addLine(FORMAT_OUTPUT, "Iteration " + i + ": " + results[i]
326 + " nanoseconds.");
327 }
328 }
329
330 /**
331 * Shows information about all the current services available to plugins.
332 *
333 * @param origin The window this command was executed in
334 * @param isSilent Whether this command has been silenced or not
335 * @param args The arguments that were passed to the command
336 */
337 private void doServices(final InputWindow origin, final boolean isSilent,
338 final String[] args) {
/*
P/P * Method: void doServices(InputWindow, bool, String[])
*
* Preconditions:
* (soft) args != null
* (soft) args[1] != null
*
* Presumptions:
* com.dmdirc.plugins.PluginManager:getAllServices(...)@340 != null
* com.dmdirc.plugins.PluginManager:getPluginManager(...)@340 != null
* com.dmdirc.plugins.Service:getProviders(...)@343 != null
* java.util.Iterator:next(...)@340 != null
* java.util.Iterator:next(...)@343 != null
*
* Test Vectors:
* args.length: {0,1}, {2..+Inf}
* java.lang.String:equals(...)@342: {0}, {1}
* java.util.Iterator:hasNext(...)@340: {0}, {1}
* java.util.Iterator:hasNext(...)@343: {0}, {1}
*/
339 sendLine(origin, isSilent, FORMAT_OUTPUT, "Available Services:");
340 for (Service service : PluginManager.getPluginManager().getAllServices()) {
341 sendLine(origin, isSilent, FORMAT_OUTPUT, " " + service.toString());
342 if (args.length > 1 && args[1].equals("full")) {
343 for (ServiceProvider provider : service.getProviders()) {
344 sendLine(origin, isSilent, FORMAT_OUTPUT, " "
345 + provider.getProviderName() + " [Active: "
346 + provider.isActive() + "]");
347 }
348 }
349 }
350 }
351
352 /** {@inheritDoc} */
353 @Override
354 public String getName() {
/*
P/P * Method: String getName()
*
* Postconditions:
* return_value == &"debug"
*/
355 return "debug";
356 }
357
358 /** {@inheritDoc} */
359 @Override
360 public boolean showInHelp() {
/*
P/P * Method: bool showInHelp()
*
* Postconditions:
* return_value == 0
*/
361 return false;
362 }
363
364 /** {@inheritDoc} */
365 @Override
366 public String getHelp() {
/*
P/P * Method: String getHelp()
*
* Postconditions:
* return_value == null
*/
367 return null;
368 }
369
370 /** {@inheritDoc} */
371 @Override
372 public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
/*
P/P * Method: AdditionalTabTargets getSuggestions(int, List)
*
* Preconditions:
* (soft) previousArgs != null
*
* Postconditions:
* return_value == &new AdditionalTabTargets(getSuggestions#1)
* new AdditionalTabTargets(getSuggestions#1) num objects == 1
*
* Test Vectors:
* arg: {2}, {0}, {1}
* java.lang.String:equals(...)@395: {0}, {1}
* java.lang.String:equals(...)@398: {0}, {1}
* java.lang.String:equals(...)@400: {0}, {1}
*/
373 final AdditionalTabTargets res = new AdditionalTabTargets();
374
375 res.excludeAll();
376
377 if (arg == 0) {
378 res.add("error");
379 res.add("showraw");
380 res.add("colourspam");
381 res.add("configstats");
382 res.add("meminfo");
383 res.add("rungc");
384 res.add("configinfo");
385 res.add("globalconfiginfo");
386 res.add("forceupdate");
387 res.add("serverinfo");
388 res.add("serverstate");
389 res.add("threads");
390 res.add("benchmark");
391 res.add("firstrun");
392 res.add("migration");
393 res.add("notify");
394 res.add("services");
395 } else if (arg == 1 && "error".equals(previousArgs.get(0))) {
396 res.add("user");
397 res.add("app");
398 } else if (arg == 1 && "services".equals(previousArgs.get(0))) {
399 res.add("full");
400 } else if (arg == 2 && "error".equals(previousArgs.get(0))) {
401 res.add("low");
402 res.add("medium");
403 res.add("high");
404 res.add("fatal");
405 res.add("unknown");
406 }
407
408 return res;
409 }
410
411 /** Reverse value comparator for a map entry. */
/*
P/P * Method: int compare(Object, Object)
*
* Preconditions:
* x0 != null
* x1 != null
*
* Postconditions:
* init'ed(return_value)
*/
412 private static class ValueComparator implements
413 Comparator<Entry<String, Integer>>, Serializable {
414
415 /**
416 * A version number for this class. It should be changed whenever the
417 * class structure is changed (or anything else that would prevent
418 * serialized objects being unserialized with the new class).
419 */
420 private static final long serialVersionUID = 1;
421
422 /** Instantiates a new ValueComparator. */
423 public ValueComparator() {
/*
P/P * Method: void com.dmdirc.commandparser.commands.global.Debug$ValueComparator()
*/
424 super();
425 }
426
427 /** {@inheritDoc} */
428 @Override
429 public int compare(final Entry<String, Integer> o1,
430 final Entry<String, Integer> o2) {
/*
P/P * Method: int compare(Map$Entry, Map$Entry)
*
* Preconditions:
* o1 != null
* o2 != null
*
* Presumptions:
* java.lang.Integer:compareTo(...)@431 <= 231
* java.util.Map_Entry:getKey(...)@434 != null
* java.util.Map_Entry:getValue(...)@431 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* java.lang.Integer:compareTo(...)@431: {-231..-1, 1..231}, {0}
*/
431 int returnValue = o1.getValue().compareTo(o2.getValue()) * -1;
432
433 if (returnValue == 0) {
434 returnValue = o1.getKey().compareToIgnoreCase(o2.getKey());
435 }
436
437 return returnValue;
438 }
439 }
440
441 }
SofCheck Inspector Build Version : 2.17854
| Debug.java |
2009-Jun-25 01:54:24 |
| Debug.class |
2009-Sep-02 17:04:16 |
| Debug$ValueComparator.class |
2009-Sep-02 17:04:16 |