1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 32 public class SupBookRecord extends Record 33 { 34 public final static short sid = 0x1AE; 35 private short field_1_number_of_sheets; 36 private short field_2_flag; 37 38 39 public SupBookRecord() 40 { 41 setFlag((short)0x401); 42 } 43 44 51 public SupBookRecord(short id, short size, byte[] data) 52 { 53 super(id, size, data); 54 } 55 56 64 public SupBookRecord(short id, short size, byte[] data, int offset) 65 { 66 super(id, size, data, offset); 67 } 68 69 protected void validateSid(short id) 70 { 71 if (id != sid) 72 { 73 throw new RecordFormatException("NOT An Supbook RECORD"); 74 } 75 } 76 77 85 protected void fillFields(byte [] data, short size, int offset) 86 { 87 field_1_number_of_sheets = LittleEndian.getShort(data,offset+0); 91 field_2_flag = LittleEndian.getShort(data,offset+2); 92 } 93 94 95 public String toString() 96 { 97 StringBuffer buffer = new StringBuffer (); 98 buffer.append("[SUPBOOK]\n"); 99 buffer.append("numberosheets = ").append(getNumberOfSheets()).append('\n'); 100 buffer.append("flag = ").append(getFlag()).append('\n'); 101 buffer.append("[/SUPBOOK]\n"); 102 return buffer.toString(); 103 } 104 105 114 public int serialize(int offset, byte [] data) 115 { 116 LittleEndian.putShort(data, 0 + offset, sid); 117 LittleEndian.putShort(data, 2 + offset, (short) 4); 118 LittleEndian.putShort(data, 4 + offset, field_1_number_of_sheets); 119 LittleEndian.putShort(data, 6 + offset, field_2_flag); 120 121 return getRecordSize(); 122 } 123 124 public void setNumberOfSheets(short number){ 125 field_1_number_of_sheets = number; 126 } 127 128 public short getNumberOfSheets(){ 129 return field_1_number_of_sheets; 130 } 131 132 public void setFlag(short flag){ 133 field_2_flag = flag; 134 } 135 136 public short getFlag() { 137 return field_2_flag; 138 } 139 140 public int getRecordSize() 141 { 142 return 4 + 4; 143 } 144 145 public short getSid() 146 { 147 return this.sid; 148 } 149 } 150 | Popular Tags |