1 9 package org.jrobin.core.jrrd; 10 11 import java.io.*; 12 13 19 public class Header implements Constants { 20 21 static final long offset = 0; 22 long size; 23 String version; 24 int dsCount; 25 int rraCount; 26 int pdpStep; 27 28 Header(RRDFile file) throws IOException { 29 30 if (!file.readString(4).equals(COOKIE)) { 31 throw new IOException("Invalid COOKIE"); 32 } 33 34 if (!(version = file.readString(5)).equals(VERSION)) { 35 throw new IOException("Unsupported RRD version (" + version + ")"); 36 } 37 38 file.align(); 39 40 file.readDouble(); 42 43 dsCount = file.readInt(); 44 rraCount = file.readInt(); 45 pdpStep = file.readInt(); 46 47 file.align(); 49 file.skipBytes(80); 50 51 size = file.getFilePointer() - offset; 52 } 53 54 59 public String getVersion() { 60 return version; 61 } 62 63 68 public int getDSCount() { 69 return dsCount; 70 } 71 72 77 public int getRRACount() { 78 return rraCount; 79 } 80 81 86 public int getPDPStep() { 87 return pdpStep; 88 } 89 90 95 public String toString() { 96 97 StringBuffer sb = new StringBuffer ("[Header: OFFSET=0x00, SIZE=0x"); 98 99 sb.append(Long.toHexString(size)); 100 sb.append(", version="); 101 sb.append(version); 102 sb.append(", dsCount="); 103 sb.append(dsCount); 104 sb.append(", rraCount="); 105 sb.append(rraCount); 106 sb.append(", pdpStep="); 107 sb.append(pdpStep); 108 sb.append("]"); 109 110 return sb.toString(); 111 } 112 } 113 | Popular Tags |