KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > graph > RrdExport


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org)
7  *
8  * Developers: Sasa Markovic (saxon@jrobin.org)
9  * Arne Vandamme (cobralord@jrobin.org)
10  *
11  * (C) Copyright 2003, by Sasa Markovic.
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25 package org.jrobin.graph;
26
27 import org.jrobin.core.RrdException;
28 import org.jrobin.core.RrdOpener;
29
30 import java.io.IOException JavaDoc;
31
32 /**
33  * <p>RrdExport can be used to export graph-like datasources to XML format,
34  * by means of the ExportData object. More information about Export can be
35  * found in the RRDtool XPORT man page.</p>
36  *
37  * <p>RrdExport needs a RrdExportDef that holds the configuration.</p>
38  *
39  * @author Arne Vandamme (cobralord@jrobin.org)
40  */

41 public class RrdExport extends RrdExporter
42 {
43     // ================================================================
44
// -- Members
45
// ================================================================
46
private int maxRows = 400; // Default width of a graph
47

48
49     // ================================================================
50
// -- Constructors
51
// ================================================================
52
/**
53      * Constructs a new RrdExport object based on a RrdExportDef
54      * containing the configuration.
55      *
56      * @param def Reference to a RrdExportDef object.
57      */

58     public RrdExport( RrdExportDef def )
59     {
60         super( def );
61     }
62
63     /**
64      * Constructs a new RrdExport object based on a RrdExportDef
65      * containing the configuration and a RrdOpener for opening the RRD
66      * datasources.
67      *
68      * @param def Reference to a RrdExportDef object.
69      * @param rrdOpener Reference to a RrdOpener object.
70      */

71     public RrdExport( RrdExportDef def, RrdOpener rrdOpener )
72     {
73         super( def, rrdOpener );
74     }
75
76     /**
77      * Constructs a new RrdExport object based on a RrdExportDef
78      * containing the configuration and a ballpark figure of
79      * maximum number of rows in the reduced dataset.
80      *
81      * @param def Reference to a RrdExportDef object.
82      * @param maxRows Maximum number of rows in the reduced dataset.
83      */

84     public RrdExport( RrdExportDef def, int maxRows )
85     {
86         super( def );
87         setMaxRows( maxRows );
88     }
89
90     /**
91      * Constructs a new RrdExport object based on a RrdExportDef
92      * containing the configuration, RrdOpener for opening the RRD
93      * datasources and a ballpark figure of maximum number of rows
94      * in the reduced dataset.
95      *
96      * @param def Reference to a RrdExportDef object.
97      * @param rrdOpener Reference to a RrdOpener object.
98      * @param maxRows Maximum number of rows in the reduced dataset.
99      */

100     public RrdExport( RrdExportDef def, RrdOpener rrdOpener, int maxRows )
101     {
102         super( def, rrdOpener );
103         setMaxRows( maxRows );
104     }
105
106
107     // ================================================================
108
// -- Public methods
109
// ================================================================
110
/**
111      * Sets the RrdExportDef that holds the export configuration.
112      *
113      * @param def Reference to a RrdExportDef object.
114      */

115     public void setExportDef( RrdExportDef def )
116     {
117         super.setExportDef( def );
118     }
119
120     /**
121      * Sets the rrd opener reference to use for data retrieval.
122      *
123      * @param rrdOpener Reference to a RrdOpener object.
124      */

125     public void setRrdOpener( RrdOpener rrdOpener )
126     {
127         super.setRrdOpener( rrdOpener );
128     }
129
130     /**
131      * Sets the maximum number of rows that the reduced dataset should
132      * contain. Note: this number is not absolute and can be overruled
133      * in some cases.
134      *
135      * @param maxRows Maximum number of rows in the reduced dataset.
136      */

137     public void setMaxRows( int maxRows )
138     {
139         this.maxRows = maxRows;
140     }
141
142     /**
143      * Fetches the reduced dataset based on provided RrdExportDef as
144      * a ExportData object.
145      *
146      * @param maxRows Maximum number of rows in the returned set.
147      * @return ExportData object.
148      * @throws RrdException Thrown in case of JRobin specific error.
149      * @throws IOException Thrown in case of I/O related error.
150      */

151     public ExportData fetch( int maxRows ) throws RrdException, IOException JavaDoc {
152         return super.fetch( maxRows );
153     }
154
155     /**
156      * Fetches the reduced dataset based on provided RrdExportDef as
157      * a ExportData object.
158      *
159      * @return ExportData object.
160      * @throws RrdException Thrown in case of JRobin specific error.
161      * @throws IOException Thrown in case of I/O related error.
162      */

163     public ExportData fetch() throws RrdException, IOException JavaDoc {
164         return super.fetch( maxRows );
165     }
166
167     public int getMaxRows() {
168         return maxRows;
169     }
170 }
171
Popular Tags