Coverage report

| %line | %branch
--- | --- | ---
examples.fwhois |
0% |
0% |

1 |  |
     /*
2 |  |
      * Copyright 2001-2005 The Apache Software Foundation
3 |  |
      *
4 |  |
      * Licensed under the Apache License, Version 2.0 (the "License");
5 |  |
      * you may not use this file except in compliance with the License.
6 |  |
      * You may obtain a copy of the License at
7 |  |
      *
8 |  |
      *     http://www.apache.org/licenses/LICENSE-2.0
9 |  |
      *
10 |  |
      * Unless required by applicable law or agreed to in writing, software
11 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
12 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  |
      * See the License for the specific language governing permissions and
14 |  |
      * limitations under the License.
15 |  |
      */
16 |  |
     package examples;
17 |  |
18 |  |
     import java.io.IOException;
19 |  |
     import java.net.InetAddress;
20 |  |
     import java.net.UnknownHostException;
21 |  |
     import org.apache.commons.net.WhoisClient;
22 |  |
23 |  |
     /***
24 |  |
      * This is an example of how you would implement the Linux fwhois command
25 |  |
      * in Java using NetComponents.  The Java version is much shorter.
26 |  |
      * <p>
27 |  |
      ***/
28 | 0 |
     public final class fwhois
29 |  |
     {
30 |  |
31 |  |
         public static final void main(String[] args)
32 |  |
         {
33 |  |
             int index;
34 |  |
             String handle, host;
35 | 0 |
             InetAddress address = null;
36 |  |
             WhoisClient whois;
37 |  |
38 | 0 |
             if (args.length != 1)
39 |  |
             {
40 | 0 |
                 System.err.println("usage: fwhois handle[@<server>]");
41 | 0 |
                 System.exit(1);
42 |  |
             }
43 |  |
44 | 0 |
             index = args[0].lastIndexOf("@");
45 |  |
46 | 0 |
             whois = new WhoisClient();
47 |  |
             // We want to timeout if a response takes longer than 60 seconds
48 | 0 |
             whois.setDefaultTimeout(60000);
49 |  |
50 | 0 |
             if (index == -1)
51 |  |
             {
52 | 0 |
                 handle = args[0];
53 | 0 |
                 host = WhoisClient.DEFAULT_HOST;
54 |  |
             }
55 |  |
             else
56 |  |
             {
57 | 0 |
                 handle = args[0].substring(0, index);
58 | 0 |
                 host = args[0].substring(index + 1);
59 |  |
             }
60 |  |
61 |  |
             try
62 |  |
             {
63 | 0 |
                 address = InetAddress.getByName(host);
64 |  |
             }
65 | 0 |
             catch (UnknownHostException e)
66 |  |
             {
67 | 0 |
                 System.err.println("Error unknown host: " + e.getMessage());
68 | 0 |
                 System.exit(1);
69 | 0 |
             }
70 |  |
71 | 0 |
             System.out.println("[" + address.getHostName() + "]");
72 |  |
73 |  |
             try
74 |  |
             {
75 | 0 |
                 whois.connect(address);
76 | 0 |
                 System.out.print(whois.query(handle));
77 | 0 |
                 whois.disconnect();
78 |  |
             }
79 | 0 |
             catch (IOException e)
80 |  |
             {
81 | 0 |
                 System.err.println("Error I/O exception: " + e.getMessage());
82 | 0 |
                 System.exit(1);
83 | 0 |
             }
84 | 0 |
         }
85 |  |
86 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.