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 axis record defines the type of an axis.
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 AxisRecord
71       extends Record
72   {
73       public final static short      sid                             = 0x101d;
74       private  short      field_1_axisType;
75       public final static short       AXIS_TYPE_CATEGORY_OR_X_AXIS   = 0;
76       public final static short       AXIS_TYPE_VALUE_AXIS           = 1;
77       public final static short       AXIS_TYPE_SERIES_AXIS          = 2;
78       private  int        field_2_reserved1;
79       private  int        field_3_reserved2;
80       private  int        field_4_reserved3;
81       private  int        field_5_reserved4;
82   
83   
84       public AxisRecord()
85       {
86   
87       }
88   
89       /**
90        * Constructs a Axis record and sets its fields appropriately.
91        *
92        * @param id    id must be 0x101d or an exception
93        *              will be throw upon validation
94        * @param size  size the size of the data area of the record
95        * @param data  data of the record (should not contain sid/len)
96        */
97   
98       public AxisRecord(short id, short size, byte [] data)
99       {
100          super(id, size, data);
101      
102      }
103  
104      /**
105       * Constructs a Axis record and sets its fields appropriately.
106       *
107       * @param id    id must be 0x101d or an exception
108       *              will be throw upon validation
109       * @param size  size the size of the data area of the record
110       * @param data  data of the record (should not contain sid/len)
111       * @param offset of the record's data
112       */
113  
114      public AxisRecord(short id, short size, byte [] data, int offset)
115      {
116          super(id, size, data, offset);
117      
118      }
119  
120      /**
121       * Checks the sid matches the expected side for this record
122       *
123       * @param id   the expected sid.
124       */
125      protected void validateSid(short id)
126      {
127          if (id != sid)
128          {
129              throw new RecordFormatException("Not a Axis record");
130          }
131      }
132  
133      protected void fillFields(byte [] data, short size, int offset)
134      {
135  
136          int pos = 0;
137          field_1_axisType               = LittleEndian.getShort(data, pos + 0x0 + offset);
138          field_2_reserved1              = LittleEndian.getInt(data, pos + 0x2 + offset);
139          field_3_reserved2              = LittleEndian.getInt(data, pos + 0x6 + offset);
140          field_4_reserved3              = LittleEndian.getInt(data, pos + 0xa + offset);
141          field_5_reserved4              = LittleEndian.getInt(data, pos + 0xe + offset);
142  
143      }
144  
145      public String toString()
146      {
147          StringBuffer buffer = new StringBuffer();
148  
149          buffer.append("[AXIS]\n");
150          buffer.append("    .axisType             = ")
151              .append("0x").append(HexDump.toHex(  getAxisType ()))
152              .append(" (").append( getAxisType() ).append(" )");
153          buffer.append(System.getProperty("line.separator")); 
154          buffer.append("    .reserved1            = ")
155              .append("0x").append(HexDump.toHex(  getReserved1 ()))
156              .append(" (").append( getReserved1() ).append(" )");
157          buffer.append(System.getProperty("line.separator")); 
158          buffer.append("    .reserved2            = ")
159              .append("0x").append(HexDump.toHex(  getReserved2 ()))
160              .append(" (").append( getReserved2() ).append(" )");
161          buffer.append(System.getProperty("line.separator")); 
162          buffer.append("    .reserved3            = ")
163              .append("0x").append(HexDump.toHex(  getReserved3 ()))
164              .append(" (").append( getReserved3() ).append(" )");
165          buffer.append(System.getProperty("line.separator")); 
166          buffer.append("    .reserved4            = ")
167              .append("0x").append(HexDump.toHex(  getReserved4 ()))
168              .append(" (").append( getReserved4() ).append(" )");
169          buffer.append(System.getProperty("line.separator")); 
170  
171          buffer.append("[/AXIS]\n");
172          return buffer.toString();
173      }
174  
175      public int serialize(int offset, byte[] data)
176      {
177          int pos = 0;
178  
179          LittleEndian.putShort(data, 0 + offset, sid);
180          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
181  
182          LittleEndian.putShort(data, 4 + offset + pos, field_1_axisType);
183          LittleEndian.putInt(data, 6 + offset + pos, field_2_reserved1);
184          LittleEndian.putInt(data, 10 + offset + pos, field_3_reserved2);
185          LittleEndian.putInt(data, 14 + offset + pos, field_4_reserved3);
186          LittleEndian.putInt(data, 18 + offset + pos, field_5_reserved4);
187  
188          return getRecordSize();
189      }
190  
191      /**
192       * Size of record (exluding 4 byte header)
193       */
194      public int getRecordSize()
195      {
196          return 4  + 2 + 4 + 4 + 4 + 4;
197      }
198  
199      public short getSid()
200      {
201          return this.sid;
202      }
203  
204      public Object clone() {
205          AxisRecord rec = new AxisRecord();
206      
207          rec.field_1_axisType = field_1_axisType;
208          rec.field_2_reserved1 = field_2_reserved1;
209          rec.field_3_reserved2 = field_3_reserved2;
210          rec.field_4_reserved3 = field_4_reserved3;
211          rec.field_5_reserved4 = field_5_reserved4;
212          return rec;
213      }
214  
215  
216  
217  
218      /**
219       * Get the axis type field for the Axis record.
220       *
221       * @return  One of 
222       *        AXIS_TYPE_CATEGORY_OR_X_AXIS
223       *        AXIS_TYPE_VALUE_AXIS
224       *        AXIS_TYPE_SERIES_AXIS
225       */
226      public short getAxisType()
227      {
228          return field_1_axisType;
229      }
230  
231      /**
232       * Set the axis type field for the Axis record.
233       *
234       * @param field_1_axisType
235       *        One of 
236       *        AXIS_TYPE_CATEGORY_OR_X_AXIS
237       *        AXIS_TYPE_VALUE_AXIS
238       *        AXIS_TYPE_SERIES_AXIS
239       */
240      public void setAxisType(short field_1_axisType)
241      {
242          this.field_1_axisType = field_1_axisType;
243      }
244  
245      /**
246       * Get the reserved1 field for the Axis record.
247       */
248      public int getReserved1()
249      {
250          return field_2_reserved1;
251      }
252  
253      /**
254       * Set the reserved1 field for the Axis record.
255       */
256      public void setReserved1(int field_2_reserved1)
257      {
258          this.field_2_reserved1 = field_2_reserved1;
259      }
260  
261      /**
262       * Get the reserved2 field for the Axis record.
263       */
264      public int getReserved2()
265      {
266          return field_3_reserved2;
267      }
268  
269      /**
270       * Set the reserved2 field for the Axis record.
271       */
272      public void setReserved2(int field_3_reserved2)
273      {
274          this.field_3_reserved2 = field_3_reserved2;
275      }
276  
277      /**
278       * Get the reserved3 field for the Axis record.
279       */
280      public int getReserved3()
281      {
282          return field_4_reserved3;
283      }
284  
285      /**
286       * Set the reserved3 field for the Axis record.
287       */
288      public void setReserved3(int field_4_reserved3)
289      {
290          this.field_4_reserved3 = field_4_reserved3;
291      }
292  
293      /**
294       * Get the reserved4 field for the Axis record.
295       */
296      public int getReserved4()
297      {
298          return field_5_reserved4;
299      }
300  
301      /**
302       * Set the reserved4 field for the Axis record.
303       */
304      public void setReserved4(int field_5_reserved4)
305      {
306          this.field_5_reserved4 = field_5_reserved4;
307      }
308  
309  
310  }  // END OF CLASS
311  
312  
313  
314  
315