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 SeriesTextRecord 34 extends Record 35 { 36 public final static short sid = 0x100d; 37 private short field_1_id; 38 private byte field_2_textLength; 39 private byte field_3_undocumented; 40 private String field_4_text; 41 42 43 public SeriesTextRecord() 44 { 45 46 } 47 48 56 57 public SeriesTextRecord(short id, short size, byte [] data) 58 { 59 super(id, size, data); 60 61 } 62 63 72 73 public SeriesTextRecord(short id, short size, byte [] data, int offset) 74 { 75 super(id, size, data, offset); 76 77 } 78 79 84 protected void validateSid(short id) 85 { 86 if (id != sid) 87 { 88 throw new RecordFormatException("Not a SeriesText record"); 89 } 90 } 91 92 protected void fillFields(byte [] data, short size, int offset) 93 { 94 95 int pos = 0; 96 field_1_id = LittleEndian.getShort(data, pos + 0x0 + offset); 97 field_2_textLength = data[ pos + 0x2 + offset ]; 98 field_3_undocumented = data[ pos + 0x3 + offset ]; 99 field_4_text = StringUtil.getFromUnicodeLE(data, pos + 0x4 + offset, ((field_2_textLength *2)/2)); 100 101 } 102 103 public String toString() 104 { 105 StringBuffer buffer = new StringBuffer (); 106 107 buffer.append("[SERIESTEXT]\n"); 108 buffer.append(" .id = ") 109 .append("0x").append(HexDump.toHex( getId ())) 110 .append(" (").append( getId() ).append(" )"); 111 buffer.append(System.getProperty("line.separator")); 112 buffer.append(" .textLength = ") 113 .append("0x").append(HexDump.toHex( getTextLength ())) 114 .append(" (").append( getTextLength() ).append(" )"); 115 buffer.append(System.getProperty("line.separator")); 116 buffer.append(" .undocumented = ") 117 .append("0x").append(HexDump.toHex( getUndocumented ())) 118 .append(" (").append( getUndocumented() ).append(" )"); 119 buffer.append(System.getProperty("line.separator")); 120 buffer.append(" .text = ") 121 .append(" (").append( getText() ).append(" )"); 122 buffer.append(System.getProperty("line.separator")); 123 124 buffer.append("[/SERIESTEXT]\n"); 125 return buffer.toString(); 126 } 127 128 public int serialize(int offset, byte[] data) 129 { 130 int pos = 0; 131 132 LittleEndian.putShort(data, 0 + offset, sid); 133 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 134 135 LittleEndian.putShort(data, 4 + offset + pos, field_1_id); 136 data[ 6 + offset + pos ] = field_2_textLength; 137 data[ 7 + offset + pos ] = field_3_undocumented; 138 StringUtil.putUnicodeLE(field_4_text, data, 8 + offset + pos); 139 140 return getRecordSize(); 141 } 142 143 146 public int getRecordSize() 147 { 148 return 4 + 2 + 1 + 1 + (field_2_textLength *2); 149 } 150 151 public short getSid() 152 { 153 return this.sid; 154 } 155 156 public Object clone() { 157 SeriesTextRecord rec = new SeriesTextRecord(); 158 159 rec.field_1_id = field_1_id; 160 rec.field_2_textLength = field_2_textLength; 161 rec.field_3_undocumented = field_3_undocumented; 162 rec.field_4_text = field_4_text; 163 return rec; 164 } 165 166 167 168 169 172 public short getId() 173 { 174 return field_1_id; 175 } 176 177 180 public void setId(short field_1_id) 181 { 182 this.field_1_id = field_1_id; 183 } 184 185 188 public byte getTextLength() 189 { 190 return field_2_textLength; 191 } 192 193 196 public void setTextLength(byte field_2_textLength) 197 { 198 this.field_2_textLength = field_2_textLength; 199 } 200 201 204 public byte getUndocumented() 205 { 206 return field_3_undocumented; 207 } 208 209 212 public void setUndocumented(byte field_3_undocumented) 213 { 214 this.field_3_undocumented = field_3_undocumented; 215 } 216 217 220 public String getText() 221 { 222 return field_4_text; 223 } 224 225 228 public void setText(String field_4_text) 229 { 230 this.field_4_text = field_4_text; 231 } 232 233 234 } 236 237 238 239 | Popular Tags |