KickJava   Java API By Example, From Geeks To Geeks.

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


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: CDPStatusBlock.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 import java.io.PrintStream JavaDoc;
13
14 /**
15  * Instances of this class model the consolidation data point status from an RRD file.
16  *
17  * @author <a HREF="mailto:ciaran@codeloop.com">Ciaran Treanor</a>
18  * @version $Revision: 1.1 $
19  */

20 public class CDPStatusBlock {
21
22     long offset;
23     long size;
24     int unknownDatapoints;
25     double value;
26
27     CDPStatusBlock(RRDFile file) throws IOException JavaDoc {
28
29         offset = file.getFilePointer();
30         value = file.readDouble();
31         unknownDatapoints = file.readInt();
32
33         // Skip rest of cdp_prep_t.scratch
34
file.skipBytes(68);
35
36         size = file.getFilePointer() - offset;
37     }
38
39     /**
40      * Returns the number of unknown primary data points that were integrated.
41      *
42      * @return the number of unknown primary data points that were integrated.
43      */

44     public int getUnknownDatapoints() {
45         return unknownDatapoints;
46     }
47
48     /**
49      * Returns the value of this consolidated data point.
50      *
51      * @return the value of this consolidated data point.
52      */

53     public double getValue() {
54         return value;
55     }
56
57     void toXml(PrintStream JavaDoc s) {
58
59         s.print("\t\t\t<ds><value> ");
60         s.print(value);
61         s.print(" </value> <unknown_datapoints> ");
62         s.print(unknownDatapoints);
63         s.println(" </unknown_datapoints></ds>");
64     }
65
66     /**
67      * Returns a summary the contents of this CDP status block.
68      *
69      * @return a summary of the information contained in the CDP status block.
70      */

71     public String JavaDoc toString() {
72
73         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("[CDPStatusBlock: OFFSET=0x");
74
75         sb.append(Long.toHexString(offset));
76         sb.append(", SIZE=0x");
77         sb.append(Long.toHexString(size));
78         sb.append(", unknownDatapoints=");
79         sb.append(unknownDatapoints);
80         sb.append(", value=");
81         sb.append(value);
82         sb.append("]");
83
84         return sb.toString();
85     }
86 }
87
Popular Tags