001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.*;
021:
022: /**
023: * The axis record defines the type of an axis.
024: * NOTE: This source is automatically generated please do not modify this file. Either subclass or
025: * remove the record in src/records/definitions.
026:
027: * @author Glen Stampoultzis (glens at apache.org)
028: */
029: public class AxisRecord extends Record {
030: public final static short sid = 0x101d;
031: private short field_1_axisType;
032: public final static short AXIS_TYPE_CATEGORY_OR_X_AXIS = 0;
033: public final static short AXIS_TYPE_VALUE_AXIS = 1;
034: public final static short AXIS_TYPE_SERIES_AXIS = 2;
035: private int field_2_reserved1;
036: private int field_3_reserved2;
037: private int field_4_reserved3;
038: private int field_5_reserved4;
039:
040: public AxisRecord() {
041:
042: }
043:
044: /**
045: * Constructs a Axis record and sets its fields appropriately.
046: *
047: * @param in the RecordInputstream to read the record from
048: */
049:
050: public AxisRecord(RecordInputStream in) {
051: super (in);
052:
053: }
054:
055: /**
056: * Checks the sid matches the expected side for this record
057: *
058: * @param id the expected sid.
059: */
060: protected void validateSid(short id) {
061: if (id != sid) {
062: throw new RecordFormatException("Not a Axis record");
063: }
064: }
065:
066: protected void fillFields(RecordInputStream in) {
067: field_1_axisType = in.readShort();
068: field_2_reserved1 = in.readInt();
069: field_3_reserved2 = in.readInt();
070: field_4_reserved3 = in.readInt();
071: field_5_reserved4 = in.readInt();
072: }
073:
074: public String toString() {
075: StringBuffer buffer = new StringBuffer();
076:
077: buffer.append("[AXIS]\n");
078: buffer.append(" .axisType = ").append("0x")
079: .append(HexDump.toHex(getAxisType())).append(" (")
080: .append(getAxisType()).append(" )");
081: buffer.append(System.getProperty("line.separator"));
082: buffer.append(" .reserved1 = ").append("0x")
083: .append(HexDump.toHex(getReserved1())).append(" (")
084: .append(getReserved1()).append(" )");
085: buffer.append(System.getProperty("line.separator"));
086: buffer.append(" .reserved2 = ").append("0x")
087: .append(HexDump.toHex(getReserved2())).append(" (")
088: .append(getReserved2()).append(" )");
089: buffer.append(System.getProperty("line.separator"));
090: buffer.append(" .reserved3 = ").append("0x")
091: .append(HexDump.toHex(getReserved3())).append(" (")
092: .append(getReserved3()).append(" )");
093: buffer.append(System.getProperty("line.separator"));
094: buffer.append(" .reserved4 = ").append("0x")
095: .append(HexDump.toHex(getReserved4())).append(" (")
096: .append(getReserved4()).append(" )");
097: buffer.append(System.getProperty("line.separator"));
098:
099: buffer.append("[/AXIS]\n");
100: return buffer.toString();
101: }
102:
103: public int serialize(int offset, byte[] data) {
104: int pos = 0;
105:
106: LittleEndian.putShort(data, 0 + offset, sid);
107: LittleEndian.putShort(data, 2 + offset,
108: (short) (getRecordSize() - 4));
109:
110: LittleEndian.putShort(data, 4 + offset + pos, field_1_axisType);
111: LittleEndian.putInt(data, 6 + offset + pos, field_2_reserved1);
112: LittleEndian.putInt(data, 10 + offset + pos, field_3_reserved2);
113: LittleEndian.putInt(data, 14 + offset + pos, field_4_reserved3);
114: LittleEndian.putInt(data, 18 + offset + pos, field_5_reserved4);
115:
116: return getRecordSize();
117: }
118:
119: /**
120: * Size of record (exluding 4 byte header)
121: */
122: public int getRecordSize() {
123: return 4 + 2 + 4 + 4 + 4 + 4;
124: }
125:
126: public short getSid() {
127: return sid;
128: }
129:
130: public Object clone() {
131: AxisRecord rec = new AxisRecord();
132:
133: rec.field_1_axisType = field_1_axisType;
134: rec.field_2_reserved1 = field_2_reserved1;
135: rec.field_3_reserved2 = field_3_reserved2;
136: rec.field_4_reserved3 = field_4_reserved3;
137: rec.field_5_reserved4 = field_5_reserved4;
138: return rec;
139: }
140:
141: /**
142: * Get the axis type field for the Axis record.
143: *
144: * @return One of
145: * AXIS_TYPE_CATEGORY_OR_X_AXIS
146: * AXIS_TYPE_VALUE_AXIS
147: * AXIS_TYPE_SERIES_AXIS
148: */
149: public short getAxisType() {
150: return field_1_axisType;
151: }
152:
153: /**
154: * Set the axis type field for the Axis record.
155: *
156: * @param field_1_axisType
157: * One of
158: * AXIS_TYPE_CATEGORY_OR_X_AXIS
159: * AXIS_TYPE_VALUE_AXIS
160: * AXIS_TYPE_SERIES_AXIS
161: */
162: public void setAxisType(short field_1_axisType) {
163: this .field_1_axisType = field_1_axisType;
164: }
165:
166: /**
167: * Get the reserved1 field for the Axis record.
168: */
169: public int getReserved1() {
170: return field_2_reserved1;
171: }
172:
173: /**
174: * Set the reserved1 field for the Axis record.
175: */
176: public void setReserved1(int field_2_reserved1) {
177: this .field_2_reserved1 = field_2_reserved1;
178: }
179:
180: /**
181: * Get the reserved2 field for the Axis record.
182: */
183: public int getReserved2() {
184: return field_3_reserved2;
185: }
186:
187: /**
188: * Set the reserved2 field for the Axis record.
189: */
190: public void setReserved2(int field_3_reserved2) {
191: this .field_3_reserved2 = field_3_reserved2;
192: }
193:
194: /**
195: * Get the reserved3 field for the Axis record.
196: */
197: public int getReserved3() {
198: return field_4_reserved3;
199: }
200:
201: /**
202: * Set the reserved3 field for the Axis record.
203: */
204: public void setReserved3(int field_4_reserved3) {
205: this .field_4_reserved3 = field_4_reserved3;
206: }
207:
208: /**
209: * Get the reserved4 field for the Axis record.
210: */
211: public int getReserved4() {
212: return field_5_reserved4;
213: }
214:
215: /**
216: * Set the reserved4 field for the Axis record.
217: */
218: public void setReserved4(int field_5_reserved4) {
219: this .field_5_reserved4 = field_5_reserved4;
220: }
221:
222: } // END OF CLASS
|