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 SeriesRecord 34 extends Record 35 { 36 public final static short sid = 0x1003; 37 private short field_1_categoryDataType; 38 public final static short CATEGORY_DATA_TYPE_DATES = 0; 39 public final static short CATEGORY_DATA_TYPE_NUMERIC = 1; 40 public final static short CATEGORY_DATA_TYPE_SEQUENCE = 2; 41 public final static short CATEGORY_DATA_TYPE_TEXT = 3; 42 private short field_2_valuesDataType; 43 public final static short VALUES_DATA_TYPE_DATES = 0; 44 public final static short VALUES_DATA_TYPE_NUMERIC = 1; 45 public final static short VALUES_DATA_TYPE_SEQUENCE = 2; 46 public final static short VALUES_DATA_TYPE_TEXT = 3; 47 private short field_3_numCategories; 48 private short field_4_numValues; 49 private short field_5_bubbleSeriesType; 50 public final static short BUBBLE_SERIES_TYPE_DATES = 0; 51 public final static short BUBBLE_SERIES_TYPE_NUMERIC = 1; 52 public final static short BUBBLE_SERIES_TYPE_SEQUENCE = 2; 53 public final static short BUBBLE_SERIES_TYPE_TEXT = 3; 54 private short field_6_numBubbleValues; 55 56 57 public SeriesRecord() 58 { 59 60 } 61 62 70 71 public SeriesRecord(short id, short size, byte [] data) 72 { 73 super(id, size, data); 74 75 } 76 77 86 87 public SeriesRecord(short id, short size, byte [] data, int offset) 88 { 89 super(id, size, data, offset); 90 91 } 92 93 98 protected void validateSid(short id) 99 { 100 if (id != sid) 101 { 102 throw new RecordFormatException("Not a Series record"); 103 } 104 } 105 106 protected void fillFields(byte [] data, short size, int offset) 107 { 108 109 int pos = 0; 110 field_1_categoryDataType = LittleEndian.getShort(data, pos + 0x0 + offset); 111 field_2_valuesDataType = LittleEndian.getShort(data, pos + 0x2 + offset); 112 field_3_numCategories = LittleEndian.getShort(data, pos + 0x4 + offset); 113 field_4_numValues = LittleEndian.getShort(data, pos + 0x6 + offset); 114 field_5_bubbleSeriesType = LittleEndian.getShort(data, pos + 0x8 + offset); 115 field_6_numBubbleValues = LittleEndian.getShort(data, pos + 0xa + offset); 116 117 } 118 119 public String toString() 120 { 121 StringBuffer buffer = new StringBuffer (); 122 123 buffer.append("[SERIES]\n"); 124 buffer.append(" .categoryDataType = ") 125 .append("0x").append(HexDump.toHex( getCategoryDataType ())) 126 .append(" (").append( getCategoryDataType() ).append(" )"); 127 buffer.append(System.getProperty("line.separator")); 128 buffer.append(" .valuesDataType = ") 129 .append("0x").append(HexDump.toHex( getValuesDataType ())) 130 .append(" (").append( getValuesDataType() ).append(" )"); 131 buffer.append(System.getProperty("line.separator")); 132 buffer.append(" .numCategories = ") 133 .append("0x").append(HexDump.toHex( getNumCategories ())) 134 .append(" (").append( getNumCategories() ).append(" )"); 135 buffer.append(System.getProperty("line.separator")); 136 buffer.append(" .numValues = ") 137 .append("0x").append(HexDump.toHex( getNumValues ())) 138 .append(" (").append( getNumValues() ).append(" )"); 139 buffer.append(System.getProperty("line.separator")); 140 buffer.append(" .bubbleSeriesType = ") 141 .append("0x").append(HexDump.toHex( getBubbleSeriesType ())) 142 .append(" (").append( getBubbleSeriesType() ).append(" )"); 143 buffer.append(System.getProperty("line.separator")); 144 buffer.append(" .numBubbleValues = ") 145 .append("0x").append(HexDump.toHex( getNumBubbleValues ())) 146 .append(" (").append( getNumBubbleValues() ).append(" )"); 147 buffer.append(System.getProperty("line.separator")); 148 149 buffer.append("[/SERIES]\n"); 150 return buffer.toString(); 151 } 152 153 public int serialize(int offset, byte[] data) 154 { 155 int pos = 0; 156 157 LittleEndian.putShort(data, 0 + offset, sid); 158 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 159 160 LittleEndian.putShort(data, 4 + offset + pos, field_1_categoryDataType); 161 LittleEndian.putShort(data, 6 + offset + pos, field_2_valuesDataType); 162 LittleEndian.putShort(data, 8 + offset + pos, field_3_numCategories); 163 LittleEndian.putShort(data, 10 + offset + pos, field_4_numValues); 164 LittleEndian.putShort(data, 12 + offset + pos, field_5_bubbleSeriesType); 165 LittleEndian.putShort(data, 14 + offset + pos, field_6_numBubbleValues); 166 167 return getRecordSize(); 168 } 169 170 173 public int getRecordSize() 174 { 175 return 4 + 2 + 2 + 2 + 2 + 2 + 2; 176 } 177 178 public short getSid() 179 { 180 return this.sid; 181 } 182 183 public Object clone() { 184 SeriesRecord rec = new SeriesRecord(); 185 186 rec.field_1_categoryDataType = field_1_categoryDataType; 187 rec.field_2_valuesDataType = field_2_valuesDataType; 188 rec.field_3_numCategories = field_3_numCategories; 189 rec.field_4_numValues = field_4_numValues; 190 rec.field_5_bubbleSeriesType = field_5_bubbleSeriesType; 191 rec.field_6_numBubbleValues = field_6_numBubbleValues; 192 return rec; 193 } 194 195 196 197 198 207 public short getCategoryDataType() 208 { 209 return field_1_categoryDataType; 210 } 211 212 222 public void setCategoryDataType(short field_1_categoryDataType) 223 { 224 this.field_1_categoryDataType = field_1_categoryDataType; 225 } 226 227 236 public short getValuesDataType() 237 { 238 return field_2_valuesDataType; 239 } 240 241 251 public void setValuesDataType(short field_2_valuesDataType) 252 { 253 this.field_2_valuesDataType = field_2_valuesDataType; 254 } 255 256 259 public short getNumCategories() 260 { 261 return field_3_numCategories; 262 } 263 264 267 public void setNumCategories(short field_3_numCategories) 268 { 269 this.field_3_numCategories = field_3_numCategories; 270 } 271 272 275 public short getNumValues() 276 { 277 return field_4_numValues; 278 } 279 280 283 public void setNumValues(short field_4_numValues) 284 { 285 this.field_4_numValues = field_4_numValues; 286 } 287 288 297 public short getBubbleSeriesType() 298 { 299 return field_5_bubbleSeriesType; 300 } 301 302 312 public void setBubbleSeriesType(short field_5_bubbleSeriesType) 313 { 314 this.field_5_bubbleSeriesType = field_5_bubbleSeriesType; 315 } 316 317 320 public short getNumBubbleValues() 321 { 322 return field_6_numBubbleValues; 323 } 324 325 328 public void setNumBubbleValues(short field_6_numBubbleValues) 329 { 330 this.field_6_numBubbleValues = field_6_numBubbleValues; 331 } 332 333 334 } 336 337 338 339 | Popular Tags |