KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > core > jrrd > Main


1 /*
2  * Copyright (C) 2001 Ciaran Treanor <ciaran@codeloop.com>
3  *
4  * Distributable under GPL license.
5  * See terms of license at gnu.org.
6  *
7  * $Id: Main.java,v 1.1 2004/07/22 09:34:10 saxon64 Exp $
8  */

9 package org.jrobin.core.jrrd;
10
11 import java.io.IOException JavaDoc;
12
13 /**
14  * Show some of the things jRRD can do.
15  *
16  * @author <a HREF="mailto:ciaran@codeloop.com">Ciaran Treanor</a>
17  * @version $Revision: 1.1 $
18  */

19 public class Main {
20
21     public Main(String JavaDoc rrdFile) {
22
23         RRDatabase rrd = null;
24         DataChunk chunk = null;
25
26         try {
27             rrd = new RRDatabase(rrdFile);
28             chunk = rrd.getData(ConsolidationFunctionType.AVERAGE);
29         } catch (Exception JavaDoc e) {
30             e.printStackTrace();
31
32             return;
33         }
34
35         rrd.toXml(System.out); // Dump the database as XML.
36
rrd.printInfo(System.out); // Dump the database header information.
37
System.out.println(rrd); // Dump a summary of the contents of the database.
38
System.out.println(chunk); // Dump the chunk.
39

40         try {
41             rrd.close();
42         } catch (IOException JavaDoc e) {
43             e.printStackTrace();
44         }
45     }
46
47     static void usage(int status) {
48         System.err.println("Usage: " + Main.class.getName() + " rrdfile");
49         System.exit(status);
50     }
51
52     public static void main(String JavaDoc[] args) {
53         if (args.length != 1) {
54             usage(1);
55         }
56         new Main(args[0]);
57     }
58 }
59
Popular Tags