1 2 /* ==================================================================== 3 * The Apache Software License, Version 1.1 4 * 5 * Copyright (c) 2002 The Apache Software Foundation. All rights 6 * reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. The end-user documentation included with the redistribution, 21 * if any, must include the following acknowledgment: 22 * "This product includes software developed by the 23 * Apache Software Foundation (http://www.apache.org/)." 24 * Alternately, this acknowledgment may appear in the software itself, 25 * if and wherever such third-party acknowledgments normally appear. 26 * 27 * 4. The names "Apache" and "Apache Software Foundation" and 28 * "Apache POI" must not be used to endorse or promote products 29 * derived from this software without prior written permission. For 30 * written permission, please contact apache@apache.org. 31 * 32 * 5. Products derived from this software may not be called "Apache", 33 * "Apache POI", nor may "Apache" appear in their name, without 34 * prior written permission of the Apache Software Foundation. 35 * 36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 39 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 47 * SUCH DAMAGE. 48 * ==================================================================== 49 * 50 * This software consists of voluntary contributions made by many 51 * individuals on behalf of the Apache Software Foundation. For more 52 * information on the Apache Software Foundation, please see 53 * <http://www.apache.org/>. 54 */ 55 56 57 package org.apache.poi.hssf.record; 58 59 60 61 import org.apache.poi.util.*; 62 63 /** 64 * The series record describes the overall data for a series. 65 * NOTE: This source is automatically generated please do not modify this file. Either subclass or 66 * remove the record in src/records/definitions. 67 68 * @author Glen Stampoultzis (glens at apache.org) 69 */ 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 /** 100 * Constructs a Series record and sets its fields appropriately. 101 * 102 * @param id id must be 0x1003 or an exception 103 * will be throw upon validation 104 * @param size size the size of the data area of the record 105 * @param data data of the record (should not contain sid/len) 106 */ 107 108 public SeriesRecord(short id, short size, byte [] data) 109 { 110 super(id, size, data); 111 } 112 113 /** 114 * Constructs a Series record and sets its fields appropriately. 115 * 116 * @param id id must be 0x1003 or an exception 117 * will be throw upon validation 118 * @param size size the size of the data area of the record 119 * @param data data of the record (should not contain sid/len) 120 * @param offset of the record's data 121 */ 122 123 public SeriesRecord(short id, short size, byte [] data, int offset) 124 { 125 super(id, size, data, offset); 126 } 127 128 /** 129 * Checks the sid matches the expected side for this record 130 * 131 * @param id the expected sid. 132 */ 133 protected void validateSid(short id) 134 { 135 if (id != sid) 136 { 137 throw new RecordFormatException("Not a Series record"); 138 } 139 } 140 141 protected void fillFields(byte [] data, short size, int offset) 142 { 143 field_1_categoryDataType = LittleEndian.getShort(data, 0x0 + offset); 144 field_2_valuesDataType = LittleEndian.getShort(data, 0x2 + offset); 145 field_3_numCategories = LittleEndian.getShort(data, 0x4 + offset); 146 field_4_numValues = LittleEndian.getShort(data, 0x6 + offset); 147 field_5_bubbleSeriesType = LittleEndian.getShort(data, 0x8 + offset); 148 field_6_numBubbleValues = LittleEndian.getShort(data, 0xa + offset); 149 150 } 151 152 public String toString() 153 { 154 StringBuffer buffer = new StringBuffer(); 155 156 buffer.append("[Series]\n"); 157 158 buffer.append(" .categoryDataType = ") 159 .append("0x") 160 .append(HexDump.toHex((short)getCategoryDataType())) 161 .append(" (").append(getCategoryDataType()).append(" )\n"); 162 163 buffer.append(" .valuesDataType = ") 164 .append("0x") 165 .append(HexDump.toHex((short)getValuesDataType())) 166 .append(" (").append(getValuesDataType()).append(" )\n"); 167 168 buffer.append(" .numCategories = ") 169 .append("0x") 170 .append(HexDump.toHex((short)getNumCategories())) 171 .append(" (").append(getNumCategories()).append(" )\n"); 172 173 buffer.append(" .numValues = ") 174 .append("0x") 175 .append(HexDump.toHex((short)getNumValues())) 176 .append(" (").append(getNumValues()).append(" )\n"); 177 178 buffer.append(" .bubbleSeriesType = ") 179 .append("0x") 180 .append(HexDump.toHex((short)getBubbleSeriesType())) 181 .append(" (").append(getBubbleSeriesType()).append(" )\n"); 182 183 buffer.append(" .numBubbleValues = ") 184 .append("0x") 185 .append(HexDump.toHex((short)getNumBubbleValues())) 186 .append(" (").append(getNumBubbleValues()).append(" )\n"); 187 188 buffer.append("[/Series]\n"); 189 return buffer.toString(); 190 } 191 192 public int serialize(int offset, byte[] data) 193 { 194 LittleEndian.putShort(data, 0 + offset, sid); 195 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 196 197 LittleEndian.putShort(data, 4 + offset, field_1_categoryDataType); 198 LittleEndian.putShort(data, 6 + offset, field_2_valuesDataType); 199 LittleEndian.putShort(data, 8 + offset, field_3_numCategories); 200 LittleEndian.putShort(data, 10 + offset, field_4_numValues); 201 LittleEndian.putShort(data, 12 + offset, field_5_bubbleSeriesType); 202 LittleEndian.putShort(data, 14 + offset, field_6_numBubbleValues); 203 204 return getRecordSize(); 205 } 206 207 /** 208 * Size of record (exluding 4 byte header) 209 */ 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 221 /** 222 * Get the category data type field for the Series record. 223 * 224 * @return One of 225 * CATEGORY_DATA_TYPE_DATES 226 * CATEGORY_DATA_TYPE_NUMERIC 227 * CATEGORY_DATA_TYPE_SEQUENCE 228 * CATEGORY_DATA_TYPE_TEXT 229 */ 230 public short getCategoryDataType() 231 { 232 return field_1_categoryDataType; 233 } 234 235 /** 236 * Set the category data type field for the Series record. 237 * 238 * @param field_1_categoryDataType 239 * One of 240 * CATEGORY_DATA_TYPE_DATES 241 * CATEGORY_DATA_TYPE_NUMERIC 242 * CATEGORY_DATA_TYPE_SEQUENCE 243 * CATEGORY_DATA_TYPE_TEXT 244 */ 245 public void setCategoryDataType(short field_1_categoryDataType) 246 { 247 this.field_1_categoryDataType = field_1_categoryDataType; 248 } 249 250 /** 251 * Get the values data type field for the Series record. 252 * 253 * @return One of 254 * VALUES_DATA_TYPE_DATES 255 * VALUES_DATA_TYPE_NUMERIC 256 * VALUES_DATA_TYPE_SEQUENCE 257 * VALUES_DATA_TYPE_TEXT 258 */ 259 public short getValuesDataType() 260 { 261 return field_2_valuesDataType; 262 } 263 264 /** 265 * Set the values data type field for the Series record. 266 * 267 * @param field_2_valuesDataType 268 * One of 269 * VALUES_DATA_TYPE_DATES 270 * VALUES_DATA_TYPE_NUMERIC 271 * VALUES_DATA_TYPE_SEQUENCE 272 * VALUES_DATA_TYPE_TEXT 273 */ 274 public void setValuesDataType(short field_2_valuesDataType) 275 { 276 this.field_2_valuesDataType = field_2_valuesDataType; 277 } 278 279 /** 280 * Get the num categories field for the Series record. 281 */ 282 public short getNumCategories() 283 { 284 return field_3_numCategories; 285 } 286 287 /** 288 * Set the num categories field for the Series record. 289 */ 290 public void setNumCategories(short field_3_numCategories) 291 { 292 this.field_3_numCategories = field_3_numCategories; 293 } 294 295 /** 296 * Get the num values field for the Series record. 297 */ 298 public short getNumValues() 299 { 300 return field_4_numValues; 301 } 302 303 /** 304 * Set the num values field for the Series record. 305 */ 306 public void setNumValues(short field_4_numValues) 307 { 308 this.field_4_numValues = field_4_numValues; 309 } 310 311 /** 312 * Get the bubble series type field for the Series record. 313 * 314 * @return One of 315 * BUBBLE_SERIES_TYPE_DATES 316 * BUBBLE_SERIES_TYPE_NUMERIC 317 * BUBBLE_SERIES_TYPE_SEQUENCE 318 * BUBBLE_SERIES_TYPE_TEXT 319 */ 320 public short getBubbleSeriesType() 321 { 322 return field_5_bubbleSeriesType; 323 } 324 325 /** 326 * Set the bubble series type field for the Series record. 327 * 328 * @param field_5_bubbleSeriesType 329 * One of 330 * BUBBLE_SERIES_TYPE_DATES 331 * BUBBLE_SERIES_TYPE_NUMERIC 332 * BUBBLE_SERIES_TYPE_SEQUENCE 333 * BUBBLE_SERIES_TYPE_TEXT 334 */ 335 public void setBubbleSeriesType(short field_5_bubbleSeriesType) 336 { 337 this.field_5_bubbleSeriesType = field_5_bubbleSeriesType; 338 } 339 340 /** 341 * Get the num bubble values field for the Series record. 342 */ 343 public short getNumBubbleValues() 344 { 345 return field_6_numBubbleValues; 346 } 347 348 /** 349 * Set the num bubble values field for the Series record. 350 */ 351 public void setNumBubbleValues(short field_6_numBubbleValues) 352 { 353 this.field_6_numBubbleValues = field_6_numBubbleValues; 354 } 355 356 357 } // END OF CLASS 358 359 360 361 362