1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 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 60 61 public AxisRecord(short id, short size, byte [] data) 62 { 63 super(id, size, data); 64 65 } 66 67 76 77 public AxisRecord(short id, short size, byte [] data, int offset) 78 { 79 super(id, size, data, offset); 80 81 } 82 83 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 toString() 109 { 110 StringBuffer buffer = new StringBuffer (); 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 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 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 189 public short getAxisType() 190 { 191 return field_1_axisType; 192 } 193 194 203 public void setAxisType(short field_1_axisType) 204 { 205 this.field_1_axisType = field_1_axisType; 206 } 207 208 211 public int getReserved1() 212 { 213 return field_2_reserved1; 214 } 215 216 219 public void setReserved1(int field_2_reserved1) 220 { 221 this.field_2_reserved1 = field_2_reserved1; 222 } 223 224 227 public int getReserved2() 228 { 229 return field_3_reserved2; 230 } 231 232 235 public void setReserved2(int field_3_reserved2) 236 { 237 this.field_3_reserved2 = field_3_reserved2; 238 } 239 240 243 public int getReserved3() 244 { 245 return field_4_reserved3; 246 } 247 248 251 public void setReserved3(int field_4_reserved3) 252 { 253 this.field_4_reserved3 = field_4_reserved3; 254 } 255 256 259 public int getReserved4() 260 { 261 return field_5_reserved4; 262 } 263 264 267 public void setReserved4(int field_5_reserved4) 268 { 269 this.field_5_reserved4 = field_5_reserved4; 270 } 271 272 273 } 275 276 277 278 | Popular Tags |