1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class SCLRecord 34 extends Record 35 { 36 public final static short sid = 0xa0; 37 private short field_1_numerator; 38 private short field_2_denominator; 39 40 41 public SCLRecord() 42 { 43 44 } 45 46 54 55 public SCLRecord(short id, short size, byte [] data) 56 { 57 super(id, size, data); 58 59 } 60 61 70 71 public SCLRecord(short id, short size, byte [] data, int offset) 72 { 73 super(id, size, data, offset); 74 75 } 76 77 82 protected void validateSid(short id) 83 { 84 if (id != sid) 85 { 86 throw new RecordFormatException("Not a SCL record"); 87 } 88 } 89 90 protected void fillFields(byte [] data, short size, int offset) 91 { 92 93 int pos = 0; 94 field_1_numerator = LittleEndian.getShort(data, pos + 0x0 + offset); 95 field_2_denominator = LittleEndian.getShort(data, pos + 0x2 + offset); 96 97 } 98 99 public String toString() 100 { 101 StringBuffer buffer = new StringBuffer (); 102 103 buffer.append("[SCL]\n"); 104 buffer.append(" .numerator = ") 105 .append("0x").append(HexDump.toHex( getNumerator ())) 106 .append(" (").append( getNumerator() ).append(" )"); 107 buffer.append(System.getProperty("line.separator")); 108 buffer.append(" .denominator = ") 109 .append("0x").append(HexDump.toHex( getDenominator ())) 110 .append(" (").append( getDenominator() ).append(" )"); 111 buffer.append(System.getProperty("line.separator")); 112 113 buffer.append("[/SCL]\n"); 114 return buffer.toString(); 115 } 116 117 public int serialize(int offset, byte[] data) 118 { 119 int pos = 0; 120 121 LittleEndian.putShort(data, 0 + offset, sid); 122 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 123 124 LittleEndian.putShort(data, 4 + offset + pos, field_1_numerator); 125 LittleEndian.putShort(data, 6 + offset + pos, field_2_denominator); 126 127 return getRecordSize(); 128 } 129 130 133 public int getRecordSize() 134 { 135 return 4 + 2 + 2; 136 } 137 138 public short getSid() 139 { 140 return this.sid; 141 } 142 143 public Object clone() { 144 SCLRecord rec = new SCLRecord(); 145 146 rec.field_1_numerator = field_1_numerator; 147 rec.field_2_denominator = field_2_denominator; 148 return rec; 149 } 150 151 152 153 154 157 public short getNumerator() 158 { 159 return field_1_numerator; 160 } 161 162 165 public void setNumerator(short field_1_numerator) 166 { 167 this.field_1_numerator = field_1_numerator; 168 } 169 170 173 public short getDenominator() 174 { 175 return field_2_denominator; 176 } 177 178 181 public void setDenominator(short field_2_denominator) 182 { 183 this.field_2_denominator = field_2_denominator; 184 } 185 186 187 } 189 190 191 192 | Popular Tags |