KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > core > RrdDataSet


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.core;
26
27 import java.io.IOException JavaDoc;
28 import java.io.OutputStream JavaDoc;
29
30 /**
31  * <p>Interface to represent a JRobin dataset. A dataset is nothing but a table of datasources, indexed
32  * by equidistant timestamps. A dataset allows access to the internal datasources with aggregatoin methods.</p>
33  *
34  * @author Arne Vandamme (cobralord@jrobin.org)
35  */

36 public interface RrdDataSet
37 {
38     /**
39      * Returns the number of rows in this dataset.
40      *
41      * @return Number of rows (data samples).
42      */

43     public int getRowCount();
44
45     /**
46      * Returns the number of columns in this dataset.
47      *
48      * @return Number of columns (datasources).
49      */

50     public int getColumnCount();
51
52     /**
53      * Returns an array of timestamps covering the whole range specified in the
54      * dataset object.
55      *
56      * @return Array of equidistant timestamps.
57      */

58     public long[] getTimestamps();
59
60     /**
61      * Returns all values for a single datasource, the returned values
62      * correspond to the timestamps returned with the {@link #getTimestamps() getTimestamps()} method.
63      *
64      * @param dsIndex Datasource index.
65      * @return Array of single datasource values.
66      */

67     public double[] getValues( int dsIndex );
68
69     /**
70      * Returns all values for all datasources, the returned values
71      * correspond to the timestamps returned with the {@link #getTimestamps() getTimestamps()} method.
72      *
73      * @return Two-dimensional aray of all datasource values.
74      */

75     public double[][] getValues();
76
77     /**
78      * Returns all values for a single datasource, the returned values
79      * correspond to the timestamps returned with the {@link #getTimestamps() getTimestamps()} method.
80      *
81      * @param dsName Datasource name.
82      * @return Array of single datasource values.
83      * @throws RrdException Thrown if no matching datasource name is found.
84      */

85     public double[] getValues( String JavaDoc dsName ) throws RrdException;
86
87     /**
88      * Returns the first timestamp in the dataset.
89      *
90      * @return The smallest timestamp.
91      */

92     public long getFirstTimestamp();
93
94     /**
95      * Returns the last timestamp in the dataset.
96      *
97      * @return The biggest timestamp.
98      */

99     public long getLastTimestamp();
100
101     /**
102      * Returns array of the names of all datasources in the set.
103      *
104      * @return Array of datasource names.
105      */

106     public String JavaDoc[] getDsNames();
107
108     /**
109      * Retrieve the table index number of a datasource by name.
110      * Names are case sensitive.
111      *
112      * @param dsName Name of the datasource for which to find the index.
113      * @return Index number of the datasource in the value table.
114      * @throws RrdException Thrown if the given datasource name cannot be found in the dataset.
115      */

116     public int getDsIndex( String JavaDoc dsName ) throws RrdException;
117
118     /**
119      * Returns the step of these datasources.
120      *
121      * @return Step as long.
122      */

123     public long getStep();
124
125     /**
126      * Returns aggregated value from the dataset for a single datasource.
127      *
128      * @param dsName Datasource name
129      * @param consolFun Consolidation function to be applied to set datasource values datasource.
130      * Valid consolidation functions are MIN, MAX, LAST and AVERAGE
131      * @return MIN, MAX, LAST or AVERAGE value calculated from the dataset for the given datasource name
132      * @throws RrdException Thrown if the given datasource name cannot be found in the dataset.
133      */

134     public double getAggregate( String JavaDoc dsName, String JavaDoc consolFun ) throws RrdException;
135
136     /**
137      * Dumps fetch data to output stream in XML format.
138      *
139      * @param outputStream Output stream to dump dataset to
140      * @throws RrdException Thrown in case of JRobin specific error.
141      * @throws IOException Thrown in case of I/O error
142      */

143     public void exportXml( OutputStream JavaDoc outputStream ) throws RrdException, IOException JavaDoc;
144
145     /**
146      * Dumps dataset to file in XML format.
147      *
148      * @param filepath Path to destination file
149      * @throws RrdException Thrown in case of JRobin specific error.
150      * @throws IOException Thrown in case of I/O error
151      */

152     public void exportXml( String JavaDoc filepath ) throws RrdException, IOException JavaDoc;
153
154     /**
155      * Dumps the dataset to XML.
156      *
157      * @return XML string format of the dataset.
158      * @throws RrdException Thrown in case of JRobin specific error.
159      * @throws IOException Thrown in case of an I/O related error.
160      */

161     public String JavaDoc exportXml() throws RrdException, IOException JavaDoc;
162 }
163
Popular Tags