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 options record provides unit information and other various tidbits about the 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 Andrew C. Oliver(acoliver at apache.org)
69    */
70   public class AxisOptionsRecord
71       extends Record
72   {
73       public final static short      sid                             = 0x1062;
74       private  short      field_1_minimumCategory;
75       private  short      field_2_maximumCategory;
76       private  short      field_3_majorUnitValue;
77       private  short      field_4_majorUnit;
78       private  short      field_5_minorUnitValue;
79       private  short      field_6_minorUnit;
80       private  short      field_7_baseUnit;
81       private  short      field_8_crossingPoint;
82       private  short      field_9_options;
83       private  BitField   defaultMinimum                              = new BitField(0x1);
84       private  BitField   defaultMaximum                              = new BitField(0x2);
85       private  BitField   defaultMajor                                = new BitField(0x4);
86       private  BitField   defaultMinorUnit                            = new BitField(0x8);
87       private  BitField   isDate                                      = new BitField(0x10);
88       private  BitField   defaultBase                                 = new BitField(0x20);
89       private  BitField   defaultCross                                = new BitField(0x40);
90       private  BitField   defaultDateSettings                         = new BitField(0x80);
91   
92   
93       public AxisOptionsRecord()
94       {
95   
96       }
97   
98       /**
99        * Constructs a AxisOptions record and sets its fields appropriately.
100       *
101       * @param id    id must be 0x1062 or an exception
102       *              will be throw upon validation
103       * @param size  size the size of the data area of the record
104       * @param data  data of the record (should not contain sid/len)
105       */
106  
107      public AxisOptionsRecord(short id, short size, byte [] data)
108      {
109          super(id, size, data);
110      
111      }
112  
113      /**
114       * Constructs a AxisOptions record and sets its fields appropriately.
115       *
116       * @param id    id must be 0x1062 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 AxisOptionsRecord(short id, short size, byte [] data, int offset)
124      {
125          super(id, size, data, offset);
126      
127      }
128  
129      /**
130       * Checks the sid matches the expected side for this record
131       *
132       * @param id   the expected sid.
133       */
134      protected void validateSid(short id)
135      {
136          if (id != sid)
137          {
138              throw new RecordFormatException("Not a AxisOptions record");
139          }
140      }
141  
142      protected void fillFields(byte [] data, short size, int offset)
143      {
144  
145          int pos = 0;
146          field_1_minimumCategory        = LittleEndian.getShort(data, pos + 0x0 + offset);
147          field_2_maximumCategory        = LittleEndian.getShort(data, pos + 0x2 + offset);
148          field_3_majorUnitValue         = LittleEndian.getShort(data, pos + 0x4 + offset);
149          field_4_majorUnit              = LittleEndian.getShort(data, pos + 0x6 + offset);
150          field_5_minorUnitValue         = LittleEndian.getShort(data, pos + 0x8 + offset);
151          field_6_minorUnit              = LittleEndian.getShort(data, pos + 0xa + offset);
152          field_7_baseUnit               = LittleEndian.getShort(data, pos + 0xc + offset);
153          field_8_crossingPoint          = LittleEndian.getShort(data, pos + 0xe + offset);
154          field_9_options                = LittleEndian.getShort(data, pos + 0x10 + offset);
155  
156      }
157  
158      public String toString()
159      {
160          StringBuffer buffer = new StringBuffer();
161  
162          buffer.append("[AXCEXT]\n");
163          buffer.append("    .minimumCategory      = ")
164              .append("0x").append(HexDump.toHex(  getMinimumCategory ()))
165              .append(" (").append( getMinimumCategory() ).append(" )");
166          buffer.append(System.getProperty("line.separator")); 
167          buffer.append("    .maximumCategory      = ")
168              .append("0x").append(HexDump.toHex(  getMaximumCategory ()))
169              .append(" (").append( getMaximumCategory() ).append(" )");
170          buffer.append(System.getProperty("line.separator")); 
171          buffer.append("    .majorUnitValue       = ")
172              .append("0x").append(HexDump.toHex(  getMajorUnitValue ()))
173              .append(" (").append( getMajorUnitValue() ).append(" )");
174          buffer.append(System.getProperty("line.separator")); 
175          buffer.append("    .majorUnit            = ")
176              .append("0x").append(HexDump.toHex(  getMajorUnit ()))
177              .append(" (").append( getMajorUnit() ).append(" )");
178          buffer.append(System.getProperty("line.separator")); 
179          buffer.append("    .minorUnitValue       = ")
180              .append("0x").append(HexDump.toHex(  getMinorUnitValue ()))
181              .append(" (").append( getMinorUnitValue() ).append(" )");
182          buffer.append(System.getProperty("line.separator")); 
183          buffer.append("    .minorUnit            = ")
184              .append("0x").append(HexDump.toHex(  getMinorUnit ()))
185              .append(" (").append( getMinorUnit() ).append(" )");
186          buffer.append(System.getProperty("line.separator")); 
187          buffer.append("    .baseUnit             = ")
188              .append("0x").append(HexDump.toHex(  getBaseUnit ()))
189              .append(" (").append( getBaseUnit() ).append(" )");
190          buffer.append(System.getProperty("line.separator")); 
191          buffer.append("    .crossingPoint        = ")
192              .append("0x").append(HexDump.toHex(  getCrossingPoint ()))
193              .append(" (").append( getCrossingPoint() ).append(" )");
194          buffer.append(System.getProperty("line.separator")); 
195          buffer.append("    .options              = ")
196              .append("0x").append(HexDump.toHex(  getOptions ()))
197              .append(" (").append( getOptions() ).append(" )");
198          buffer.append(System.getProperty("line.separator")); 
199          buffer.append("         .defaultMinimum           = ").append(isDefaultMinimum()).append('\n'); 
200          buffer.append("         .defaultMaximum           = ").append(isDefaultMaximum()).append('\n'); 
201          buffer.append("         .defaultMajor             = ").append(isDefaultMajor()).append('\n'); 
202          buffer.append("         .defaultMinorUnit         = ").append(isDefaultMinorUnit()).append('\n'); 
203          buffer.append("         .isDate                   = ").append(isIsDate()).append('\n'); 
204          buffer.append("         .defaultBase              = ").append(isDefaultBase()).append('\n'); 
205          buffer.append("         .defaultCross             = ").append(isDefaultCross()).append('\n'); 
206          buffer.append("         .defaultDateSettings      = ").append(isDefaultDateSettings()).append('\n'); 
207  
208          buffer.append("[/AXCEXT]\n");
209          return buffer.toString();
210      }
211  
212      public int serialize(int offset, byte[] data)
213      {
214          int pos = 0;
215  
216          LittleEndian.putShort(data, 0 + offset, sid);
217          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
218  
219          LittleEndian.putShort(data, 4 + offset + pos, field_1_minimumCategory);
220          LittleEndian.putShort(data, 6 + offset + pos, field_2_maximumCategory);
221          LittleEndian.putShort(data, 8 + offset + pos, field_3_majorUnitValue);
222          LittleEndian.putShort(data, 10 + offset + pos, field_4_majorUnit);
223          LittleEndian.putShort(data, 12 + offset + pos, field_5_minorUnitValue);
224          LittleEndian.putShort(data, 14 + offset + pos, field_6_minorUnit);
225          LittleEndian.putShort(data, 16 + offset + pos, field_7_baseUnit);
226          LittleEndian.putShort(data, 18 + offset + pos, field_8_crossingPoint);
227          LittleEndian.putShort(data, 20 + offset + pos, field_9_options);
228  
229          return getRecordSize();
230      }
231  
232      /**
233       * Size of record (exluding 4 byte header)
234       */
235      public int getRecordSize()
236      {
237          return 4  + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
238      }
239  
240      public short getSid()
241      {
242          return this.sid;
243      }
244  
245      public Object clone() {
246          AxisOptionsRecord rec = new AxisOptionsRecord();
247      
248          rec.field_1_minimumCategory = field_1_minimumCategory;
249          rec.field_2_maximumCategory = field_2_maximumCategory;
250          rec.field_3_majorUnitValue = field_3_majorUnitValue;
251          rec.field_4_majorUnit = field_4_majorUnit;
252          rec.field_5_minorUnitValue = field_5_minorUnitValue;
253          rec.field_6_minorUnit = field_6_minorUnit;
254          rec.field_7_baseUnit = field_7_baseUnit;
255          rec.field_8_crossingPoint = field_8_crossingPoint;
256          rec.field_9_options = field_9_options;
257          return rec;
258      }
259  
260  
261  
262  
263      /**
264       * Get the minimum category field for the AxisOptions record.
265       */
266      public short getMinimumCategory()
267      {
268          return field_1_minimumCategory;
269      }
270  
271      /**
272       * Set the minimum category field for the AxisOptions record.
273       */
274      public void setMinimumCategory(short field_1_minimumCategory)
275      {
276          this.field_1_minimumCategory = field_1_minimumCategory;
277      }
278  
279      /**
280       * Get the maximum category field for the AxisOptions record.
281       */
282      public short getMaximumCategory()
283      {
284          return field_2_maximumCategory;
285      }
286  
287      /**
288       * Set the maximum category field for the AxisOptions record.
289       */
290      public void setMaximumCategory(short field_2_maximumCategory)
291      {
292          this.field_2_maximumCategory = field_2_maximumCategory;
293      }
294  
295      /**
296       * Get the major unit value field for the AxisOptions record.
297       */
298      public short getMajorUnitValue()
299      {
300          return field_3_majorUnitValue;
301      }
302  
303      /**
304       * Set the major unit value field for the AxisOptions record.
305       */
306      public void setMajorUnitValue(short field_3_majorUnitValue)
307      {
308          this.field_3_majorUnitValue = field_3_majorUnitValue;
309      }
310  
311      /**
312       * Get the major unit field for the AxisOptions record.
313       */
314      public short getMajorUnit()
315      {
316          return field_4_majorUnit;
317      }
318  
319      /**
320       * Set the major unit field for the AxisOptions record.
321       */
322      public void setMajorUnit(short field_4_majorUnit)
323      {
324          this.field_4_majorUnit = field_4_majorUnit;
325      }
326  
327      /**
328       * Get the minor unit value field for the AxisOptions record.
329       */
330      public short getMinorUnitValue()
331      {
332          return field_5_minorUnitValue;
333      }
334  
335      /**
336       * Set the minor unit value field for the AxisOptions record.
337       */
338      public void setMinorUnitValue(short field_5_minorUnitValue)
339      {
340          this.field_5_minorUnitValue = field_5_minorUnitValue;
341      }
342  
343      /**
344       * Get the minor unit field for the AxisOptions record.
345       */
346      public short getMinorUnit()
347      {
348          return field_6_minorUnit;
349      }
350  
351      /**
352       * Set the minor unit field for the AxisOptions record.
353       */
354      public void setMinorUnit(short field_6_minorUnit)
355      {
356          this.field_6_minorUnit = field_6_minorUnit;
357      }
358  
359      /**
360       * Get the base unit field for the AxisOptions record.
361       */
362      public short getBaseUnit()
363      {
364          return field_7_baseUnit;
365      }
366  
367      /**
368       * Set the base unit field for the AxisOptions record.
369       */
370      public void setBaseUnit(short field_7_baseUnit)
371      {
372          this.field_7_baseUnit = field_7_baseUnit;
373      }
374  
375      /**
376       * Get the crossing point field for the AxisOptions record.
377       */
378      public short getCrossingPoint()
379      {
380          return field_8_crossingPoint;
381      }
382  
383      /**
384       * Set the crossing point field for the AxisOptions record.
385       */
386      public void setCrossingPoint(short field_8_crossingPoint)
387      {
388          this.field_8_crossingPoint = field_8_crossingPoint;
389      }
390  
391      /**
392       * Get the options field for the AxisOptions record.
393       */
394      public short getOptions()
395      {
396          return field_9_options;
397      }
398  
399      /**
400       * Set the options field for the AxisOptions record.
401       */
402      public void setOptions(short field_9_options)
403      {
404          this.field_9_options = field_9_options;
405      }
406  
407      /**
408       * Sets the default minimum field value.
409       * use the default minimum category
410       */
411      public void setDefaultMinimum(boolean value)
412      {
413          field_9_options = defaultMinimum.setShortBoolean(field_9_options, value);
414      }
415  
416      /**
417       * use the default minimum category
418       * @return  the default minimum field value.
419       */
420      public boolean isDefaultMinimum()
421      {
422          return defaultMinimum.isSet(field_9_options);
423      }
424  
425      /**
426       * Sets the default maximum field value.
427       * use the default maximum category
428       */
429      public void setDefaultMaximum(boolean value)
430      {
431          field_9_options = defaultMaximum.setShortBoolean(field_9_options, value);
432      }
433  
434      /**
435       * use the default maximum category
436       * @return  the default maximum field value.
437       */
438      public boolean isDefaultMaximum()
439      {
440          return defaultMaximum.isSet(field_9_options);
441      }
442  
443      /**
444       * Sets the default major field value.
445       * use the default major unit
446       */
447      public void setDefaultMajor(boolean value)
448      {
449          field_9_options = defaultMajor.setShortBoolean(field_9_options, value);
450      }
451  
452      /**
453       * use the default major unit
454       * @return  the default major field value.
455       */
456      public boolean isDefaultMajor()
457      {
458          return defaultMajor.isSet(field_9_options);
459      }
460  
461      /**
462       * Sets the default minor unit field value.
463       * use the default minor unit
464       */
465      public void setDefaultMinorUnit(boolean value)
466      {
467          field_9_options = defaultMinorUnit.setShortBoolean(field_9_options, value);
468      }
469  
470      /**
471       * use the default minor unit
472       * @return  the default minor unit field value.
473       */
474      public boolean isDefaultMinorUnit()
475      {
476          return defaultMinorUnit.isSet(field_9_options);
477      }
478  
479      /**
480       * Sets the isDate field value.
481       * this is a date axis
482       */
483      public void setIsDate(boolean value)
484      {
485          field_9_options = isDate.setShortBoolean(field_9_options, value);
486      }
487  
488      /**
489       * this is a date axis
490       * @return  the isDate field value.
491       */
492      public boolean isIsDate()
493      {
494          return isDate.isSet(field_9_options);
495      }
496  
497      /**
498       * Sets the default base field value.
499       * use the default base unit
500       */
501      public void setDefaultBase(boolean value)
502      {
503          field_9_options = defaultBase.setShortBoolean(field_9_options, value);
504      }
505  
506      /**
507       * use the default base unit
508       * @return  the default base field value.
509       */
510      public boolean isDefaultBase()
511      {
512          return defaultBase.isSet(field_9_options);
513      }
514  
515      /**
516       * Sets the default cross field value.
517       * use the default crossing point
518       */
519      public void setDefaultCross(boolean value)
520      {
521          field_9_options = defaultCross.setShortBoolean(field_9_options, value);
522      }
523  
524      /**
525       * use the default crossing point
526       * @return  the default cross field value.
527       */
528      public boolean isDefaultCross()
529      {
530          return defaultCross.isSet(field_9_options);
531      }
532  
533      /**
534       * Sets the default date settings field value.
535       * use default date setttings for this axis
536       */
537      public void setDefaultDateSettings(boolean value)
538      {
539          field_9_options = defaultDateSettings.setShortBoolean(field_9_options, value);
540      }
541  
542      /**
543       * use default date setttings for this axis
544       * @return  the default date settings field value.
545       */
546      public boolean isDefaultDateSettings()
547      {
548          return defaultDateSettings.isSet(field_9_options);
549      }
550  
551  
552  }  // END OF CLASS
553  
554  
555  
556  
557