~ubuntu-branches/ubuntu/wily/dnsjava/wily-proposed

« back to all changes in this revision

Viewing changes to lookup.java

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2009-07-21 15:17:03 UTC
  • Revision ID: james.westby@ubuntu.com-20090721151703-6v0107p1s3h7gv1c
Tags: upstream-2.0.6
ImportĀ upstreamĀ versionĀ 2.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
 
2
 
 
3
import org.xbill.DNS.*;
 
4
 
 
5
/** @author Brian Wellington <bwelling@xbill.org> */
 
6
 
 
7
public class lookup {
 
8
 
 
9
public static void
 
10
printAnswer(String name, Lookup lookup) {
 
11
        System.out.print(name + ":");
 
12
        int result = lookup.getResult();
 
13
        if (result != Lookup.SUCCESSFUL)
 
14
                System.out.print(" " + lookup.getErrorString());
 
15
        System.out.println();
 
16
        Name [] aliases = lookup.getAliases();
 
17
        if (aliases.length > 0) {
 
18
                System.out.print("# aliases: ");
 
19
                for (int i = 0; i < aliases.length; i++) {
 
20
                        System.out.print(aliases[i]);
 
21
                        if (i < aliases.length - 1)
 
22
                                System.out.print(" ");
 
23
                }
 
24
                System.out.println();
 
25
        }
 
26
        if (lookup.getResult() == Lookup.SUCCESSFUL) {
 
27
                Record [] answers = lookup.getAnswers();
 
28
                for (int i = 0; i < answers.length; i++)
 
29
                        System.out.println(answers[i]);
 
30
        }
 
31
}
 
32
 
 
33
public static void
 
34
main(String [] args) throws Exception {
 
35
        int type = Type.A;
 
36
        int start = 0;
 
37
        if (args.length > 2 && args[0].equals("-t")) {
 
38
                type = Type.value(args[1]);
 
39
                if (type < 0)
 
40
                        throw new IllegalArgumentException("invalid type");
 
41
                start = 2;
 
42
        }
 
43
        for (int i = start; i < args.length; i++) {
 
44
                Lookup l = new Lookup(args[i], type);
 
45
                l.run();
 
46
                printAnswer(args[i], l);
 
47
        }
 
48
}
 
49
 
 
50
}