KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > AxisRecord


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19
20 package org.apache.poi.hssf.record;
21
22
23
24 import org.apache.poi.util.*;
25
26 /**
27  * The axis record defines the type of an axis.
28  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29  * remove the record in src/records/definitions.
30
31  * @author Glen Stampoultzis (glens at apache.org)
32  */

33 public class AxisRecord
34     extends Record
35 {
36     public final static short sid = 0x101d;
37     private short field_1_axisType;
38     public final static short AXIS_TYPE_CATEGORY_OR_X_AXIS = 0;
39     public final static short AXIS_TYPE_VALUE_AXIS = 1;
40     public final static short AXIS_TYPE_SERIES_AXIS = 2;
41     private int field_2_reserved1;
42     private int field_3_reserved2;
43     private int field_4_reserved3;
44     private int field_5_reserved4;
45
46
47     public AxisRecord()
48     {
49
50     }
51
52     /**
53      * Constructs a Axis record and sets its fields appropriately.
54      *
55      * @param id id must be 0x101d or an exception
56      * will be throw upon validation
57      * @param size size the size of the data area of the record
58      * @param data data of the record (should not contain sid/len)
59      */

60
61     public AxisRecord(short id, short size, byte [] data)
62     {
63         super(id, size, data);
64     
65     }
66
67     /**
68      * Constructs a Axis record and sets its fields appropriately.
69      *
70      * @param id id must be 0x101d or an exception
71      * will be throw upon validation
72      * @param size size the size of the data area of the record
73      * @param data data of the record (should not contain sid/len)
74      * @param offset of the record's data
75      */

76
77     public AxisRecord(short id, short size, byte [] data, int offset)
78     {
79         super(id, size, data, offset);
80     
81     }
82
83     /**
84      * Checks the sid matches the expected side for this record
85      *
86      * @param id the expected sid.
87      */

88     protected void validateSid(short id)
89     {
90         if (id != sid)
91         {
92             throw new RecordFormatException("Not a Axis record");
93         }
94     }
95
96     protected void fillFields(byte [] data, short size, int offset)
97     {
98
99         int pos = 0;
100         field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset);
101         field_2_reserved1 = LittleEndian.getInt(data, pos + 0x2 + offset);
102         field_3_reserved2 = LittleEndian.getInt(data, pos + 0x6 + offset);
103         field_4_reserved3 = LittleEndian.getInt(data, pos + 0xa + offset);
104         field_5_reserved4 = LittleEndian.getInt(data, pos + 0xe + offset);
105
106     }
107
108     public String JavaDoc toString()
109     {
110         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
111
112         buffer.append("[AXIS]\n");
113         buffer.append(" .axisType = ")
114             .append("0x").append(HexDump.toHex( getAxisType ()))
115             .append(" (").append( getAxisType() ).append(" )");
116         buffer.append(System.getProperty("line.separator"));
117         buffer.append(" .reserved1 = ")
118             .append("0x").append(HexDump.toHex( getReserved1 ()))
119             .append(" (").append( getReserved1() ).append(" )");
120         buffer.append(System.getProperty("line.separator"));
121         buffer.append(" .reserved2 = ")
122             .append("0x").append(HexDump.toHex( getReserved2 ()))
123             .append(" (").append( getReserved2() ).append(" )");
124         buffer.append(System.getProperty("line.separator"));
125         buffer.append(" .reserved3 = ")
126             .append("0x").append(HexDump.toHex( getReserved3 ()))
127             .append(" (").append( getReserved3() ).append(" )");
128         buffer.append(System.getProperty("line.separator"));
129         buffer.append(" .reserved4 = ")
130             .append("0x").append(HexDump.toHex( getReserved4 ()))
131             .append(" (").append( getReserved4() ).append(" )");
132         buffer.append(System.getProperty("line.separator"));
133
134         buffer.append("[/AXIS]\n");
135         return buffer.toString();
136     }
137
138     public int serialize(int offset, byte[] data)
139     {
140         int pos = 0;
141
142         LittleEndian.putShort(data, 0 + offset, sid);
143         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
144
145         LittleEndian.putShort(data, 4 + offset + pos, field_1_axisType);
146         LittleEndian.putInt(data, 6 + offset + pos, field_2_reserved1);
147         LittleEndian.putInt(data, 10 + offset + pos, field_3_reserved2);
148         LittleEndian.putInt(data, 14 + offset + pos, field_4_reserved3);
149         LittleEndian.putInt(data, 18 + offset + pos, field_5_reserved4);
150
151         return getRecordSize();
152     }
153
154     /**
155      * Size of record (exluding 4 byte header)
156      */

157     public int getRecordSize()
158     {
159         return 4 + 2 + 4 + 4 + 4 + 4;
160     }
161
162     public short getSid()
163     {
164         return this.sid;
165     }
166
167     public Object JavaDoc clone() {
168         AxisRecord rec = new AxisRecord();
169     
170         rec.field_1_axisType = field_1_axisType;
171         rec.field_2_reserved1 = field_2_reserved1;
172         rec.field_3_reserved2 = field_3_reserved2;
173         rec.field_4_reserved3 = field_4_reserved3;
174         rec.field_5_reserved4 = field_5_reserved4;
175         return rec;
176     }
177
178
179
180
181     /**
182      * Get the axis type field for the Axis record.
183      *
184      * @return One of
185      * AXIS_TYPE_CATEGORY_OR_X_AXIS
186      * AXIS_TYPE_VALUE_AXIS
187      * AXIS_TYPE_SERIES_AXIS
188      */

189     public short getAxisType()
190     {
191         return field_1_axisType;
192     }
193
194     /**
195      * Set the axis type field for the Axis record.
196      *
197      * @param field_1_axisType
198      * One of
199      * AXIS_TYPE_CATEGORY_OR_X_AXIS
200      * AXIS_TYPE_VALUE_AXIS
201      * AXIS_TYPE_SERIES_AXIS
202      */

203     public void setAxisType(short field_1_axisType)
204     {
205         this.field_1_axisType = field_1_axisType;
206     }
207
208     /**
209      * Get the reserved1 field for the Axis record.
210      */

211     public int getReserved1()
212     {
213         return field_2_reserved1;
214     }
215
216     /**
217      * Set the reserved1 field for the Axis record.
218      */

219     public void setReserved1(int field_2_reserved1)
220     {
221         this.field_2_reserved1 = field_2_reserved1;
222     }
223
224     /**
225      * Get the reserved2 field for the Axis record.
226      */

227     public int getReserved2()
228     {
229         return field_3_reserved2;
230     }
231
232     /**
233      * Set the reserved2 field for the Axis record.
234      */

235     public void setReserved2(int field_3_reserved2)
236     {
237         this.field_3_reserved2 = field_3_reserved2;
238     }
239
240     /**
241      * Get the reserved3 field for the Axis record.
242      */

243     public int getReserved3()
244     {
245         return field_4_reserved3;
246     }
247
248     /**
249      * Set the reserved3 field for the Axis record.
250      */

251     public void setReserved3(int field_4_reserved3)
252     {
253         this.field_4_reserved3 = field_4_reserved3;
254     }
255
256     /**
257      * Get the reserved4 field for the Axis record.
258      */

259     public int getReserved4()
260     {
261         return field_5_reserved4;
262     }
263
264     /**
265      * Set the reserved4 field for the Axis record.
266      */

267     public void setReserved4(int field_5_reserved4)
268     {
269         this.field_5_reserved4 = field_5_reserved4;
270     }
271
272
273 } // END OF CLASS
274

275
276
277
278
Popular Tags