primary.java revision d7955ce24d294fb2014c59d11fca184471056f44
1// Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
2
3package org.xbill.DNS.tests;
4
5import java.util.*;
6import org.xbill.DNS.*;
7
8public class primary {
9
10private static void
11usage() {
12	System.out.println("usage: primary [-t] [-a | -i] origin file");
13	System.exit(1);
14}
15
16public static void
17main(String [] args) throws Exception {
18	boolean time = false;
19	boolean axfr = false;
20	boolean iterator = false;
21	int arg = 0;
22
23	if (args.length < 2)
24		usage();
25
26	while (args.length - arg > 2) {
27		if (args[0].equals("-t"))
28			time = true;
29		else if (args[0].equals("-a"))
30			axfr = true;
31		else if (args[0].equals("-i"))
32			iterator = true;
33		arg++;
34	}
35
36	Name origin = Name.fromString(args[arg++], Name.root);
37	String file = args[arg++];
38
39	long start = System.currentTimeMillis();
40	Zone zone = new Zone(origin, file);
41	long end = System.currentTimeMillis();
42	if (axfr) {
43		Iterator it = zone.AXFR();
44		while (it.hasNext()) {
45			System.out.println(it.next());
46		}
47	} else if (iterator) {
48		Iterator it = zone.iterator();
49		while (it.hasNext()) {
50			System.out.println(it.next());
51		}
52	} else {
53		System.out.println(zone);
54	}
55	if (time)
56		System.out.println("; Load time: " + (end - start) + " ms");
57}
58
59}
60