File Source: UrlListCommand.java
/*
P/P * Method: com.dmdirc.addons.urlcatcher.UrlListCommand__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.addons.urlcatcher;
24
25 import com.dmdirc.commandparser.CommandArguments;
26 import com.dmdirc.commandparser.commands.GlobalCommand;
27 import com.dmdirc.commandparser.commands.IntelligentCommand;
28 import com.dmdirc.ui.input.AdditionalTabTargets;
29 import com.dmdirc.ui.interfaces.InputWindow;
30 import java.util.List;
31 import java.util.Map;
32
33 /**
34 *
35 * @author chris
36 */
37 public class UrlListCommand extends GlobalCommand implements IntelligentCommand {
38
39 private final UrlCatcherPlugin plugin;
40
/*
P/P * Method: void com.dmdirc.addons.urlcatcher.UrlListCommand(UrlCatcherPlugin)
*
* Postconditions:
* this.plugin == plugin
* init'ed(this.plugin)
*/
41 public UrlListCommand(final UrlCatcherPlugin plugin) {
42 this.plugin = plugin;
43 }
44
45 /** {@inheritDoc} */
46 @Override
47 public void execute(final InputWindow origin, final boolean isSilent,
48 final CommandArguments args) {
/*
P/P * Method: void execute(InputWindow, bool, CommandArguments)
*
* Preconditions:
* this.plugin != null
* this.plugin.urls != null
*
* Presumptions:
* java.util.Iterator:next(...)@54 != null
* java.util.Map:entrySet(...)@54 != null
* java.util.Map:size(...)@51 >= 1
* java.util.Map_Entry:getValue(...)@55 != null
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@54: {0}, {1}
*/
49 final String[] headers = {"URL", "Count"};
50 final Map<String, Integer> map = plugin.getURLS();
51 final String[][] data = new String[map.size()][];
52
53 int i = 0;
54 for (Map.Entry<String, Integer> entry : map.entrySet()) {
55 data[i++] = new String[]{entry.getKey(), entry.getValue().toString()};
56 }
57
58 sendLine(origin, isSilent, FORMAT_OUTPUT, doTable(headers, data));
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public String getName() {
/*
P/P * Method: String getName()
*
* Postconditions:
* return_value == &"urllist"
*/
64 return "urllist";
65 }
66
67 /** {@inheritDoc} */
68 @Override
69 public boolean showInHelp() {
/*
P/P * Method: bool showInHelp()
*
* Postconditions:
* return_value == 1
*/
70 return true;
71 }
72
73 /** {@inheritDoc} */
74 @Override
75 public String getHelp() {
/*
P/P * Method: String getHelp()
*
* Postconditions:
* return_value == &"urllist - shows a list of URLs that have been seen"
*/
76 return "urllist - shows a list of URLs that have been seen";
77 }
78
79 /** {@inheritDoc} */
80 @Override
81 public AdditionalTabTargets getSuggestions(final int arg, final List<String> previousArgs) {
/*
P/P * Method: AdditionalTabTargets getSuggestions(int, List)
*
* Postconditions:
* init'ed(return_value)
*/
82 return new AdditionalTabTargets().excludeAll();
83 }
84
85 }
SofCheck Inspector Build Version : 2.17854
| UrlListCommand.java |
2009-Jun-25 01:54:24 |
| UrlListCommand.class |
2009-Sep-02 17:04:16 |