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 TabIdRecord 33 extends Record 34 { 35 public final static short sid = 0x13d; 36 public short[] field_1_tabids; 37 38 public TabIdRecord() 39 { 40 } 41 42 49 50 public TabIdRecord(short id, short size, byte [] data) 51 { 52 super(id, size, data); 53 } 54 55 63 64 public TabIdRecord(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 A TABID RECORD"); 74 } 75 } 76 77 protected void fillFields(byte [] data, short size, int offset) 78 { 79 field_1_tabids = new short[ size / 2 ]; 80 for (int k = 0; k < field_1_tabids.length; k++) 81 { 82 field_1_tabids[ k ] = LittleEndian.getShort(data, 83 (k * 2) + offset); 84 } 85 } 86 87 91 92 public void setTabIdArray(short [] array) 93 { 94 field_1_tabids = array; 95 } 96 97 101 102 public short [] getTabIdArray() 103 { 104 return field_1_tabids; 105 } 106 107 public String toString() 108 { 109 StringBuffer buffer = new StringBuffer (); 110 111 buffer.append("[TABID]\n"); 112 buffer.append(" .elements = ").append(field_1_tabids.length) 113 .append("\n"); 114 for (int k = 0; k < field_1_tabids.length; k++) 115 { 116 buffer.append(" .element_" + k + " = ") 117 .append(field_1_tabids[ k ]).append("\n"); 118 } 119 buffer.append("[/TABID]\n"); 120 return buffer.toString(); 121 } 122 123 public int serialize(int offset, byte [] data) 124 { 125 short[] tabids = getTabIdArray(); 126 short length = ( short ) (tabids.length * 2); 127 int byteoffset = 4; 128 129 LittleEndian.putShort(data, 0 + offset, sid); 130 LittleEndian.putShort(data, 2 + offset, 131 (( short ) length)); 133 for (int k = 0; k < (length / 2); k++) 135 { 136 LittleEndian.putShort(data, byteoffset + offset, tabids[ k ]); 137 byteoffset += 2; 138 } 139 return getRecordSize(); 140 } 141 142 public int getRecordSize() 143 { 144 return 4 + (getTabIdArray().length * 2); 145 } 146 147 public short getSid() 148 { 149 return this.sid; 150 } 151 } 152 | Popular Tags |