File Source: DNSCommand.java
/*
P/P * Method: com.dmdirc.addons.dns.DNSCommand__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.dns;
24
25 import com.dmdirc.commandparser.CommandArguments;
26 import com.dmdirc.commandparser.CommandManager;
27 import com.dmdirc.commandparser.commands.GlobalCommand;
28 import com.dmdirc.ui.interfaces.InputWindow;
29
30 import java.util.Timer;
31 import java.util.TimerTask;
32
33 /**
34 * Performs DNS lookups for nicknames, hostnames or IPs.
35 */
/*
P/P * Method: void access$100(DNSCommand, InputWindow, bool, String, Object[])
*
* Preconditions:
* x0 != null
*/
36 public final class DNSCommand extends GlobalCommand {
37
38 /** Creates a new instance of DNSCommand. */
39 public DNSCommand() {
/*
P/P * Method: void com.dmdirc.addons.dns.DNSCommand()
*/
40 super();
41
42 CommandManager.registerCommand(this);
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:
* args != null
*
* Presumptions:
* com.dmdirc.commandparser.CommandArguments:getArguments(...).length@54 >= 1
* com.dmdirc.commandparser.CommandArguments:getArguments(...)@49 != null
* com.dmdirc.commandparser.CommandArguments:getArguments(...)@54 != null
*
* Test Vectors:
* com.dmdirc.commandparser.CommandArguments:getArguments(...).length@49: {1..+Inf}, {0}
*/
49 if (args.getArguments().length == 0) {
50 showUsage(origin, isSilent, "dns", "<IP|hostname>");
51 return;
52 }
53
54 sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolving: " + args.getArguments()[0]);
/*
P/P * Method: void com.dmdirc.addons.dns.DNSCommand$1(DNSCommand, CommandArguments, InputWindow, bool)
*
* Postconditions:
* this.val$args == Param_2
* init'ed(this.val$args)
* this.val$isSilent == Param_4
* init'ed(this.val$isSilent)
* this.val$origin == Param_3
* init'ed(this.val$origin)
*/
55 new Timer("DNS Command Timer").schedule(new TimerTask() {
56 /** {@inheritDoc} */
57 @Override
58 public void run() {
/*
P/P * Method: void run()
*
* Preconditions:
* this.val$args != null
*
* Presumptions:
* com.dmdirc.commandparser.CommandArguments:getArguments(...).length@59 >= 1
* com.dmdirc.commandparser.CommandArguments:getArguments(...).length@60 >= 1
* com.dmdirc.commandparser.CommandArguments:getArguments(...).length@64 >= 1
* com.dmdirc.commandparser.CommandArguments:getArguments(...)@59 != null
* com.dmdirc.commandparser.CommandArguments:getArguments(...)@60 != null
* ...
*
* Test Vectors:
* java.lang.String:matches(...)@59: {0}, {1}
*/
59 if (args.getArguments()[0].matches("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b")) {
60 sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: "
61 + args.getArguments()[0] + ": "
62 + DNSPlugin.getHostname(args.getArguments()[0]));
63 } else {
64 sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: "
65 + args.getArguments()[0] + ": "
66 + DNSPlugin.getIPs(args.getArguments()[0]));
67 }
68 }
69 }, 0);
70 }
71
72 /** {@inheritDoc} */
73 @Override
74 public String getName() {
/*
P/P * Method: String getName()
*
* Postconditions:
* return_value == &"dns"
*/
75 return "dns";
76 }
77
78 /** {@inheritDoc} */
79 @Override
80 public boolean showInHelp() {
/*
P/P * Method: bool showInHelp()
*
* Postconditions:
* return_value == 1
*/
81 return true;
82 }
83
84 /** {@inheritDoc} */
85 @Override
86 public String getHelp() {
/*
P/P * Method: String getHelp()
*
* Postconditions:
* return_value == &"dns <IP|hostname> - Performs DNS lookup of the specified ip.hostname.nickname"
*/
87 return "dns <IP|hostname> - Performs DNS lookup of the specified ip/hostname/nickname";
88 }
89
90 }
SofCheck Inspector Build Version : 2.17854
| DNSCommand.java |
2009-Jun-25 01:54:24 |
| DNSCommand.class |
2009-Sep-02 17:04:15 |
| DNSCommand$1.class |
2009-Sep-02 17:04:15 |