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.BitField;
62   import org.apache.poi.util.LittleEndian;
63   import org.apache.poi.util.StringUtil;
64   import org.apache.poi.util.HexDump;
65   
66   /**
67    * The series record describes the overall data for a series.
68    * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
69    *       remove the record in src/records/definitions.
70   
71    * @author Glen Stampoultzis (glens at apache.org)
72    */
73   public class SeriesRecord
74       extends Record
75   {
76       public final static short      sid                             = 0x1003;
77       private  short      field_1_categoryDataType;
78       public final static short       CATEGORY_DATA_TYPE_DATES       = 0;
79       public final static short       CATEGORY_DATA_TYPE_NUMERIC     = 1;
80       public final static short       CATEGORY_DATA_TYPE_SEQUENCE    = 2;
81       public final static short       CATEGORY_DATA_TYPE_TEXT        = 3;
82       private  short      field_2_valuesDataType;
83       public final static short       VALUES_DATA_TYPE_DATES         = 0;
84       public final static short       VALUES_DATA_TYPE_NUMERIC       = 1;
85       public final static short       VALUES_DATA_TYPE_SEQUENCE      = 2;
86       public final static short       VALUES_DATA_TYPE_TEXT          = 3;
87       private  short      field_3_numCategories;
88       private  short      field_4_numValues;
89       private  short      field_5_bubbleSeriesType;
90       public final static short       BUBBLE_SERIES_TYPE_DATES       = 0;
91       public final static short       BUBBLE_SERIES_TYPE_NUMERIC     = 1;
92       public final static short       BUBBLE_SERIES_TYPE_SEQUENCE    = 2;
93       public final static short       BUBBLE_SERIES_TYPE_TEXT        = 3;
94       private  short      field_6_numBubbleValues;
95   
96   
97       public SeriesRecord()
98       {
99   
100      }
101  
102      /**
103       * Constructs a Series record and sets its fields appropriately.
104       *
105       * @param id    id must be 0x1003 or an exception
106       *              will be throw upon validation
107       * @param size  size the size of the data area of the record
108       * @param data  data of the record (should not contain sid/len)
109       */
110  
111      public SeriesRecord(short id, short size, byte [] data)
112      {
113          super(id, size, data);
114      }
115  
116      /**
117       * Constructs a Series record and sets its fields appropriately.
118       *
119       * @param id    id must be 0x1003 or an exception
120       *              will be throw upon validation
121       * @param size  size the size of the data area of the record
122       * @param data  data of the record (should not contain sid/len)
123       * @param offset of the record's data
124       */
125  
126      public SeriesRecord(short id, short size, byte [] data, int offset)
127      {
128          super(id, size, data, offset);
129      }
130  
131      /**
132       * Checks the sid matches the expected side for this record
133       *
134       * @param id   the expected sid.
135       */
136      protected void validateSid(short id)
137      {
138          if (id != sid)
139          {
140              throw new RecordFormatException("Not a Series record");
141          }
142      }
143  
144      protected void fillFields(byte [] data, short size, int offset)
145      {
146          field_1_categoryDataType        = LittleEndian.getShort(data, 0x0 + offset);
147          field_2_valuesDataType          = LittleEndian.getShort(data, 0x2 + offset);
148          field_3_numCategories           = LittleEndian.getShort(data, 0x4 + offset);
149          field_4_numValues               = LittleEndian.getShort(data, 0x6 + offset);
150          field_5_bubbleSeriesType        = LittleEndian.getShort(data, 0x8 + offset);
151          field_6_numBubbleValues         = LittleEndian.getShort(data, 0xa + offset);
152  
153      }
154  
155      public String toString()
156      {
157          StringBuffer buffer = new StringBuffer();
158  
159          buffer.append("[Series]\n");
160  
161          buffer.append("    .categoryDataType     = ")
162              .append("0x")
163              .append(HexDump.toHex((short)getCategoryDataType()))
164              .append(" (").append(getCategoryDataType()).append(" )\n");
165  
166          buffer.append("    .valuesDataType       = ")
167              .append("0x")
168              .append(HexDump.toHex((short)getValuesDataType()))
169              .append(" (").append(getValuesDataType()).append(" )\n");
170  
171          buffer.append("    .numCategories        = ")
172              .append("0x")
173              .append(HexDump.toHex((short)getNumCategories()))
174              .append(" (").append(getNumCategories()).append(" )\n");
175  
176          buffer.append("    .numValues            = ")
177              .append("0x")
178              .append(HexDump.toHex((short)getNumValues()))
179              .append(" (").append(getNumValues()).append(" )\n");
180  
181          buffer.append("    .bubbleSeriesType     = ")
182              .append("0x")
183              .append(HexDump.toHex((short)getBubbleSeriesType()))
184              .append(" (").append(getBubbleSeriesType()).append(" )\n");
185  
186          buffer.append("    .numBubbleValues      = ")
187              .append("0x")
188              .append(HexDump.toHex((short)getNumBubbleValues()))
189              .append(" (").append(getNumBubbleValues()).append(" )\n");
190  
191          buffer.append("[/Series]\n");
192          return buffer.toString();
193      }
194  
195      public int serialize(int offset, byte[] data)
196      {
197          LittleEndian.putShort(data, 0 + offset, sid);
198          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
199  
200          LittleEndian.putShort(data, 4 + offset, field_1_categoryDataType);
201          LittleEndian.putShort(data, 6 + offset, field_2_valuesDataType);
202          LittleEndian.putShort(data, 8 + offset, field_3_numCategories);
203          LittleEndian.putShort(data, 10 + offset, field_4_numValues);
204          LittleEndian.putShort(data, 12 + offset, field_5_bubbleSeriesType);
205          LittleEndian.putShort(data, 14 + offset, field_6_numBubbleValues);
206  
207          return getRecordSize();
208      }
209  
210      /**
211       * Size of record (exluding 4 byte header)
212       */
213      public int getRecordSize()
214      {
215          return 4 + 2 + 2 + 2 + 2 + 2 + 2;
216      }
217  
218      public short getSid()
219      {
220          return this.sid;
221      }
222  
223  
224      /**
225       * Get the category data type field for the Series record.
226       *
227       * @return  One of 
228       *        CATEGORY_DATA_TYPE_DATES
229       *        CATEGORY_DATA_TYPE_NUMERIC
230       *        CATEGORY_DATA_TYPE_SEQUENCE
231       *        CATEGORY_DATA_TYPE_TEXT
232       */
233      public short getCategoryDataType()
234      {
235          return field_1_categoryDataType;
236      }
237  
238      /**
239       * Set the category data type field for the Series record.
240       *
241       * @param field_1_categoryDataType
242       *        One of 
243       *        CATEGORY_DATA_TYPE_DATES
244       *        CATEGORY_DATA_TYPE_NUMERIC
245       *        CATEGORY_DATA_TYPE_SEQUENCE
246       *        CATEGORY_DATA_TYPE_TEXT
247       */
248      public void setCategoryDataType(short field_1_categoryDataType)
249      {
250          this.field_1_categoryDataType = field_1_categoryDataType;
251      }
252  
253      /**
254       * Get the values data type field for the Series record.
255       *
256       * @return  One of 
257       *        VALUES_DATA_TYPE_DATES
258       *        VALUES_DATA_TYPE_NUMERIC
259       *        VALUES_DATA_TYPE_SEQUENCE
260       *        VALUES_DATA_TYPE_TEXT
261       */
262      public short getValuesDataType()
263      {
264          return field_2_valuesDataType;
265      }
266  
267      /**
268       * Set the values data type field for the Series record.
269       *
270       * @param field_2_valuesDataType
271       *        One of 
272       *        VALUES_DATA_TYPE_DATES
273       *        VALUES_DATA_TYPE_NUMERIC
274       *        VALUES_DATA_TYPE_SEQUENCE
275       *        VALUES_DATA_TYPE_TEXT
276       */
277      public void setValuesDataType(short field_2_valuesDataType)
278      {
279          this.field_2_valuesDataType = field_2_valuesDataType;
280      }
281  
282      /**
283       * Get the num categories field for the Series record.
284       */
285      public short getNumCategories()
286      {
287          return field_3_numCategories;
288      }
289  
290      /**
291       * Set the num categories field for the Series record.
292       */
293      public void setNumCategories(short field_3_numCategories)
294      {
295          this.field_3_numCategories = field_3_numCategories;
296      }
297  
298      /**
299       * Get the num values field for the Series record.
300       */
301      public short getNumValues()
302      {
303          return field_4_numValues;
304      }
305  
306      /**
307       * Set the num values field for the Series record.
308       */
309      public void setNumValues(short field_4_numValues)
310      {
311          this.field_4_numValues = field_4_numValues;
312      }
313  
314      /**
315       * Get the bubble series type field for the Series record.
316       *
317       * @return  One of 
318       *        BUBBLE_SERIES_TYPE_DATES
319       *        BUBBLE_SERIES_TYPE_NUMERIC
320       *        BUBBLE_SERIES_TYPE_SEQUENCE
321       *        BUBBLE_SERIES_TYPE_TEXT
322       */
323      public short getBubbleSeriesType()
324      {
325          return field_5_bubbleSeriesType;
326      }
327  
328      /**
329       * Set the bubble series type field for the Series record.
330       *
331       * @param field_5_bubbleSeriesType
332       *        One of 
333       *        BUBBLE_SERIES_TYPE_DATES
334       *        BUBBLE_SERIES_TYPE_NUMERIC
335       *        BUBBLE_SERIES_TYPE_SEQUENCE
336       *        BUBBLE_SERIES_TYPE_TEXT
337       */
338      public void setBubbleSeriesType(short field_5_bubbleSeriesType)
339      {
340          this.field_5_bubbleSeriesType = field_5_bubbleSeriesType;
341      }
342  
343      /**
344       * Get the num bubble values field for the Series record.
345       */
346      public short getNumBubbleValues()
347      {
348          return field_6_numBubbleValues;
349      }
350  
351      /**
352       * Set the num bubble values field for the Series record.
353       */
354      public void setNumBubbleValues(short field_6_numBubbleValues)
355      {
356          this.field_6_numBubbleValues = field_6_numBubbleValues;
357      }
358  
359  
360  }  // END OF CLASS
361  
362  
363  
364  
365