KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > inspector > RrdNode


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  * (C) Copyright 2003, by Sasa Markovic.
9  *
10  * Developers: Sasa Markovic (saxon@jrobin.org)
11  * Arne Vandamme (cobralord@jrobin.org)
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
26 package org.jrobin.inspector;
27
28 import org.jrobin.core.*;
29
30 import java.io.File JavaDoc;
31 import java.io.IOException JavaDoc;
32
33 class RrdNode {
34     private int dsIndex = -1, arcIndex = -1;
35     private String JavaDoc label;
36
37     RrdNode(RrdDb rrd) {
38         // header node
39
String JavaDoc path = rrd.getRrdBackend().getPath();
40         label = new File JavaDoc(path).getName();
41     }
42
43     RrdNode(RrdDb rrd, int dsIndex) throws IOException JavaDoc, RrdException {
44         // datasource node
45
this.dsIndex = dsIndex;
46         RrdDef def = rrd.getRrdDef();
47         DsDef[] dsDefs = def.getDsDefs();
48         label = dsDefs[dsIndex].dump();
49     }
50
51     RrdNode(RrdDb rrd, int dsIndex, int arcIndex) throws IOException JavaDoc, RrdException {
52         // archive node
53
this.dsIndex = dsIndex;
54         this.arcIndex = arcIndex;
55         ArcDef[] arcDefs = rrd.getRrdDef().getArcDefs();
56         label = arcDefs[arcIndex].dump();
57     }
58
59     int getDsIndex() {
60         return dsIndex;
61     }
62
63     int getArcIndex() {
64         return arcIndex;
65     }
66
67     public String JavaDoc toString() {
68         return label;
69     }
70 }
71
Popular Tags