001 /*
002 * Copyright (C) 2001 Ciaran Treanor <ciaran@codeloop.com>
003 *
004 * Distributable under GPL license.
005 * See terms of license at gnu.org.
006 *
007 * $Id: Main.java,v 1.1 2004/07/22 09:34:10 saxon64 Exp $
008 */
009 package org.jrobin.core.jrrd;
010
011 import java.io.IOException;
012
013 /**
014 * Show some of the things jRRD can do.
015 *
016 * @author <a href="mailto:ciaran@codeloop.com">Ciaran Treanor</a>
017 * @version $Revision: 1.1 $
018 */
019 public class Main {
020
021 public Main(String rrdFile) {
022
023 RRDatabase rrd = null;
024 DataChunk chunk = null;
025
026 try {
027 rrd = new RRDatabase(rrdFile);
028 chunk = rrd.getData(ConsolidationFunctionType.AVERAGE);
029 } catch (Exception e) {
030 e.printStackTrace();
031
032 return;
033 }
034
035 rrd.toXml(System.out); // Dump the database as XML.
036 rrd.printInfo(System.out); // Dump the database header information.
037 System.out.println(rrd); // Dump a summary of the contents of the database.
038 System.out.println(chunk); // Dump the chunk.
039
040 try {
041 rrd.close();
042 } catch (IOException e) {
043 e.printStackTrace();
044 }
045 }
046
047 static void usage(int status) {
048 System.err.println("Usage: " + Main.class.getName() + " rrdfile");
049 System.exit(status);
050 }
051
052 public static void main(String[] args) {
053 if (args.length != 1) {
054 usage(1);
055 }
056 new Main(args[0]);
057 }
058 }