1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 31 32 public class DeltaRecord 33 extends Record 34 { 35 public final static short sid = 0x10; 36 public final static double DEFAULT_VALUE = 0.0010; 38 private double field_1_max_change; 41 42 public DeltaRecord() 43 { 44 } 45 46 53 54 public DeltaRecord(short id, short size, byte [] data) 55 { 56 super(id, size, data); 57 } 58 59 67 68 public DeltaRecord(short id, short size, byte [] data, int offset) 69 { 70 super(id, size, data, offset); 71 } 72 73 protected void validateSid(short id) 74 { 75 if (id != sid) 76 { 77 throw new RecordFormatException("NOT A DELTA RECORD"); 78 } 79 } 80 81 protected void fillFields(byte [] data, short size, int offset) 82 { 83 field_1_max_change = LittleEndian.getDouble(data, 0 + offset); 84 } 85 86 90 91 public void setMaxChange(double maxChange) 92 { 93 field_1_max_change = maxChange; 94 } 95 96 100 101 public double getMaxChange() 102 { 103 return field_1_max_change; 104 } 105 106 public String toString() 107 { 108 StringBuffer buffer = new StringBuffer (); 109 110 buffer.append("[DELTA]\n"); 111 buffer.append(" .maxchange = ").append(getMaxChange()) 112 .append("\n"); 113 buffer.append("[/DELTA]\n"); 114 return buffer.toString(); 115 } 116 117 public int serialize(int offset, byte [] data) 118 { 119 LittleEndian.putShort(data, 0 + offset, sid); 120 LittleEndian.putShort(data, 2 + offset, ( short ) 0x8); 121 LittleEndian.putDouble(data, 4 + offset, getMaxChange()); 122 return getRecordSize(); 123 } 124 125 public int getRecordSize() 126 { 127 return 12; 128 } 129 130 public short getSid() 131 { 132 return this.sid; 133 } 134 135 public Object clone() { 136 DeltaRecord rec = new DeltaRecord(); 137 rec.field_1_max_change = field_1_max_change; 138 return rec; 139 } 140 } 141 | Popular Tags |