1 /
55
56
61 package org.apache.poi.hssf.record;
62
63 import org.apache.poi.util.LittleEndian;
64
65
71
72 public class BoolErrRecord
73 extends Record
74 implements CellValueRecordInterface, Comparable
75 {
76 public final static short sid = 0x205;
77 private short field_1_row;
78 private short field_2_column;
79 private short field_3_xf_index;
80 private byte field_4_bBoolErr;
81 private byte field_5_fError;
82
83
84
85 public BoolErrRecord()
86 {
87 }
88
89
96
97 public BoolErrRecord(short id, short size, byte [] data)
98 {
99 super(id, size, data);
100 }
101
102
110
111 public BoolErrRecord(short id, short size, byte [] data, int offset)
112 {
113 super(id, size, data, offset);
114 }
115
116
123
124 protected void fillFields(byte [] data, short size, int offset)
125 {
126 field_1_row = LittleEndian.getShort(data, 0 + offset);
127 field_2_column = LittleEndian.getShort(data, 2 + offset);
128 field_3_xf_index = LittleEndian.getShort(data, 4 + offset);
129 field_4_bBoolErr = data[ 6 + offset ];
130 field_5_fError = data[ 7 + offset ];
131 }
132
133 public void setRow(short row)
134 {
135 field_1_row = row;
136 }
137
138 public void setColumn(short col)
139 {
140 field_2_column = col;
141 }
142
143
148
149 public void setXFIndex(short xf)
150 {
151 field_3_xf_index = xf;
152 }
153
154
159
160 public void setValue(boolean value)
161 {
162 field_4_bBoolErr = value ? ( byte ) 1
163 : ( byte ) 0;
164 field_5_fError = ( byte ) 0;
165 }
166
167
172
173 public void setValue(byte value)
174 {
175 field_4_bBoolErr = value;
176 field_5_fError = ( byte ) 1;
177 }
178
179 public short getRow()
180 {
181 return field_1_row;
182 }
183
184 public short getColumn()
185 {
186 return field_2_column;
187 }
188
189
194
195 public short getXFIndex()
196 {
197 return field_3_xf_index;
198 }
199
200
205
206 public boolean getBooleanValue()
207 {
208 return (field_4_bBoolErr != 0);
209 }
210
211
216
217 public byte getErrorValue()
218 {
219 return field_4_bBoolErr;
220 }
221
222
227
228 public boolean isBoolean()
229 {
230 return (field_5_fError == ( byte ) 0);
231 }
232
233
238
239 public boolean isError()
240 {
241 return (field_5_fError != ( byte ) 0);
242 }
243
244 public String toString()
245 {
246 StringBuffer buffer = new StringBuffer();
247
248 buffer.append("[BOOLERR]\n");
249 buffer.append(" .row = ")
250 .append(Integer.toHexString(getRow())).append("\n");
251 buffer.append(" .col = ")
252 .append(Integer.toHexString(getColumn())).append("\n");
253 buffer.append(" .xfindex = ")
254 .append(Integer.toHexString(getXFIndex())).append("\n");
255 if (isBoolean())
256 {
257 buffer.append(" .booleanValue = ").append(getBooleanValue())
258 .append("\n");
259 }
260 else
261 {
262 buffer.append(" .errorValue = ").append(getErrorValue())
263 .append("\n");
264 }
265 buffer.append("[/BOOLERR]\n");
266 return buffer.toString();
267 }
268
269
276
277 public int serialize(int offset, byte [] data)
278 {
279 LittleEndian.putShort(data, 0 + offset, sid);
280 LittleEndian.putShort(data, 2 + offset, ( short ) 8);
281 LittleEndian.putShort(data, 4 + offset, getRow());
282 LittleEndian.putShort(data, 6 + offset, getColumn());
283 LittleEndian.putShort(data, 8 + offset, getXFIndex());
284 data[ 10 + offset ] = field_4_bBoolErr;
285 data[ 11 + offset ] = field_5_fError;
286 return getRecordSize();
287 }
288
289 public int getRecordSize()
290 {
291 return 12;
292 }
293
294
300
301 protected void validateSid(short id)
302 {
303 if (id != this.sid)
304 {
305 throw new RecordFormatException("Not a valid BoolErrRecord");
306 }
307 }
308
309 public short getSid()
310 {
311 return this.sid;
312 }
313
314 public boolean isBefore(CellValueRecordInterface i)
315 {
316 if (this.getRow() > i.getRow())
317 {
318 return false;
319 }
320 if ((this.getRow() == i.getRow())
321 && (this.getColumn() > i.getColumn()))
322 {
323 return false;
324 }
325 if ((this.getRow() == i.getRow())
326 && (this.getColumn() == i.getColumn()))
327 {
328 return false;
329 }
330 return true;
331 }
332
333 public boolean isAfter(CellValueRecordInterface i)
334 {
335 if (this.getRow() < i.getRow())
336 {
337 return false;
338 }
339 if ((this.getRow() == i.getRow())
340 && (this.getColumn() < i.getColumn()))
341 {
342 return false;
343 }
344 if ((this.getRow() == i.getRow())
345 && (this.getColumn() == i.getColumn()))
346 {
347 return false;
348 }
349 return true;
350 }
351
352 public boolean isEqual(CellValueRecordInterface i)
353 {
354 return ((this.getRow() == i.getRow())
355 && (this.getColumn() == i.getColumn()));
356 }
357
358 public boolean isInValueSection()
359 {
360 return true;
361 }
362
363 public boolean isValue()
364 {
365 return true;
366 }
367
368 public int compareTo(Object obj)
369 {
370 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
371
372 if ((this.getRow() == loc.getRow())
373 && (this.getColumn() == loc.getColumn()))
374 {
375 return 0;
376 }
377 if (this.getRow() < loc.getRow())
378 {
379 return -1;
380 }
381 if (this.getRow() > loc.getRow())
382 {
383 return 1;
384 }
385 if (this.getColumn() < loc.getColumn())
386 {
387 return -1;
388 }
389 if (this.getColumn() > loc.getColumn())
390 {
391 return 1;
392 }
393 return -1;
394 }
395
396 public boolean equals(Object obj)
397 {
398 if (!(obj instanceof CellValueRecordInterface))
399 {
400 return false;
401 }
402 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
403
404 if ((this.getRow() == loc.getRow())
405 && (this.getColumn() == loc.getColumn()))
406 {
407 return true;
408 }
409 return false;
410 }
411 }
412