1 /
55
56
57 package org.apache.poi.hssf.record;
58
59
60
61 import org.apache.poi.util.*;
62
63
70 public class SeriesRecord
71 extends Record
72 {
73 public final static short sid = 0x1003;
74 private short field_1_categoryDataType;
75 public final static short CATEGORY_DATA_TYPE_DATES = 0;
76 public final static short CATEGORY_DATA_TYPE_NUMERIC = 1;
77 public final static short CATEGORY_DATA_TYPE_SEQUENCE = 2;
78 public final static short CATEGORY_DATA_TYPE_TEXT = 3;
79 private short field_2_valuesDataType;
80 public final static short VALUES_DATA_TYPE_DATES = 0;
81 public final static short VALUES_DATA_TYPE_NUMERIC = 1;
82 public final static short VALUES_DATA_TYPE_SEQUENCE = 2;
83 public final static short VALUES_DATA_TYPE_TEXT = 3;
84 private short field_3_numCategories;
85 private short field_4_numValues;
86 private short field_5_bubbleSeriesType;
87 public final static short BUBBLE_SERIES_TYPE_DATES = 0;
88 public final static short BUBBLE_SERIES_TYPE_NUMERIC = 1;
89 public final static short BUBBLE_SERIES_TYPE_SEQUENCE = 2;
90 public final static short BUBBLE_SERIES_TYPE_TEXT = 3;
91 private short field_6_numBubbleValues;
92
93
94 public SeriesRecord()
95 {
96
97 }
98
99
107
108 public SeriesRecord(short id, short size, byte [] data)
109 {
110 super(id, size, data);
111
112 }
113
114
123
124 public SeriesRecord(short id, short size, byte [] data, int offset)
125 {
126 super(id, size, data, offset);
127
128 }
129
130
135 protected void validateSid(short id)
136 {
137 if (id != sid)
138 {
139 throw new RecordFormatException("Not a Series record");
140 }
141 }
142
143 protected void fillFields(byte [] data, short size, int offset)
144 {
145
146 int pos = 0;
147 field_1_categoryDataType = LittleEndian.getShort(data, pos + 0x0 + offset);
148 field_2_valuesDataType = LittleEndian.getShort(data, pos + 0x2 + offset);
149 field_3_numCategories = LittleEndian.getShort(data, pos + 0x4 + offset);
150 field_4_numValues = LittleEndian.getShort(data, pos + 0x6 + offset);
151 field_5_bubbleSeriesType = LittleEndian.getShort(data, pos + 0x8 + offset);
152 field_6_numBubbleValues = LittleEndian.getShort(data, pos + 0xa + offset);
153
154 }
155
156 public String toString()
157 {
158 StringBuffer buffer = new StringBuffer();
159
160 buffer.append("[SERIES]\n");
161 buffer.append(" .categoryDataType = ")
162 .append("0x").append(HexDump.toHex( getCategoryDataType ()))
163 .append(" (").append( getCategoryDataType() ).append(" )");
164 buffer.append(System.getProperty("line.separator"));
165 buffer.append(" .valuesDataType = ")
166 .append("0x").append(HexDump.toHex( getValuesDataType ()))
167 .append(" (").append( getValuesDataType() ).append(" )");
168 buffer.append(System.getProperty("line.separator"));
169 buffer.append(" .numCategories = ")
170 .append("0x").append(HexDump.toHex( getNumCategories ()))
171 .append(" (").append( getNumCategories() ).append(" )");
172 buffer.append(System.getProperty("line.separator"));
173 buffer.append(" .numValues = ")
174 .append("0x").append(HexDump.toHex( getNumValues ()))
175 .append(" (").append( getNumValues() ).append(" )");
176 buffer.append(System.getProperty("line.separator"));
177 buffer.append(" .bubbleSeriesType = ")
178 .append("0x").append(HexDump.toHex( getBubbleSeriesType ()))
179 .append(" (").append( getBubbleSeriesType() ).append(" )");
180 buffer.append(System.getProperty("line.separator"));
181 buffer.append(" .numBubbleValues = ")
182 .append("0x").append(HexDump.toHex( getNumBubbleValues ()))
183 .append(" (").append( getNumBubbleValues() ).append(" )");
184 buffer.append(System.getProperty("line.separator"));
185
186 buffer.append("[/SERIES]\n");
187 return buffer.toString();
188 }
189
190 public int serialize(int offset, byte[] data)
191 {
192 int pos = 0;
193
194 LittleEndian.putShort(data, 0 + offset, sid);
195 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
196
197 LittleEndian.putShort(data, 4 + offset + pos, field_1_categoryDataType);
198 LittleEndian.putShort(data, 6 + offset + pos, field_2_valuesDataType);
199 LittleEndian.putShort(data, 8 + offset + pos, field_3_numCategories);
200 LittleEndian.putShort(data, 10 + offset + pos, field_4_numValues);
201 LittleEndian.putShort(data, 12 + offset + pos, field_5_bubbleSeriesType);
202 LittleEndian.putShort(data, 14 + offset + pos, field_6_numBubbleValues);
203
204 return getRecordSize();
205 }
206
207
210 public int getRecordSize()
211 {
212 return 4 + 2 + 2 + 2 + 2 + 2 + 2;
213 }
214
215 public short getSid()
216 {
217 return this.sid;
218 }
219
220 public Object clone() {
221 SeriesRecord rec = new SeriesRecord();
222
223 rec.field_1_categoryDataType = field_1_categoryDataType;
224 rec.field_2_valuesDataType = field_2_valuesDataType;
225 rec.field_3_numCategories = field_3_numCategories;
226 rec.field_4_numValues = field_4_numValues;
227 rec.field_5_bubbleSeriesType = field_5_bubbleSeriesType;
228 rec.field_6_numBubbleValues = field_6_numBubbleValues;
229 return rec;
230 }
231
232
233
234
235
244 public short getCategoryDataType()
245 {
246 return field_1_categoryDataType;
247 }
248
249
259 public void setCategoryDataType(short field_1_categoryDataType)
260 {
261 this.field_1_categoryDataType = field_1_categoryDataType;
262 }
263
264
273 public short getValuesDataType()
274 {
275 return field_2_valuesDataType;
276 }
277
278
288 public void setValuesDataType(short field_2_valuesDataType)
289 {
290 this.field_2_valuesDataType = field_2_valuesDataType;
291 }
292
293
296 public short getNumCategories()
297 {
298 return field_3_numCategories;
299 }
300
301
304 public void setNumCategories(short field_3_numCategories)
305 {
306 this.field_3_numCategories = field_3_numCategories;
307 }
308
309
312 public short getNumValues()
313 {
314 return field_4_numValues;
315 }
316
317
320 public void setNumValues(short field_4_numValues)
321 {
322 this.field_4_numValues = field_4_numValues;
323 }
324
325
334 public short getBubbleSeriesType()
335 {
336 return field_5_bubbleSeriesType;
337 }
338
339
349 public void setBubbleSeriesType(short field_5_bubbleSeriesType)
350 {
351 this.field_5_bubbleSeriesType = field_5_bubbleSeriesType;
352 }
353
354
357 public short getNumBubbleValues()
358 {
359 return field_6_numBubbleValues;
360 }
361
362
365 public void setNumBubbleValues(short field_6_numBubbleValues)
366 {
367 this.field_6_numBubbleValues = field_6_numBubbleValues;
368 }
369
370
371 }
372
373
374
375
376