KickJava   Java API By Example, From Geeks To Geeks.

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


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: PDPStatusBlock.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  * Instances of this class model the primary data point status from an RRD file.
15  *
16  * @author <a HREF="mailto:ciaran@codeloop.com">Ciaran Treanor</a>
17  * @version $Revision: 1.1 $
18  */

19 public class PDPStatusBlock {
20
21     long offset;
22     long size;
23     String JavaDoc lastReading;
24     int unknownSeconds;
25     double value;
26
27     PDPStatusBlock(RRDFile file) throws IOException JavaDoc {
28
29         offset = file.getFilePointer();
30         lastReading = file.readString(Constants.LAST_DS_LEN);
31
32         file.align(4);
33
34         unknownSeconds = file.readInt();
35
36         file.skipBytes(4);
37
38         value = file.readDouble();
39
40         // Skip rest of pdp_prep_t.par[]
41
file.skipBytes(64);
42
43         size = file.getFilePointer() - offset;
44     }
45
46     /**
47      * Returns the last reading from the data source.
48      *
49      * @return the last reading from the data source.
50      */

51     public String JavaDoc getLastReading() {
52         return lastReading;
53     }
54
55     /**
56      * Returns the current value of the primary data point.
57      *
58      * @return the current value of the primary data point.
59      */

60     public double getValue() {
61         return value;
62     }
63
64     /**
65      * Returns the number of seconds of the current primary data point is
66      * unknown data.
67      *
68      * @return the number of seconds of the current primary data point is unknown data.
69      */

70     public int getUnknownSeconds() {
71         return unknownSeconds;
72     }
73
74     /**
75      * Returns a summary the contents of this PDP status block.
76      *
77      * @return a summary of the information contained in this PDP status block.
78      */

79     public String JavaDoc toString() {
80
81         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("[PDPStatus: OFFSET=0x");
82
83         sb.append(Long.toHexString(offset));
84         sb.append(", SIZE=0x");
85         sb.append(Long.toHexString(size));
86         sb.append(", lastReading=");
87         sb.append(lastReading);
88         sb.append(", unknownSeconds=");
89         sb.append(unknownSeconds);
90         sb.append(", value=");
91         sb.append(value);
92         sb.append("]");
93
94         return sb.toString();
95     }
96 }
97
Popular Tags