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
78 private int field_1_row;
79 private short field_2_column;
80 private short field_3_xf_index;
81 private byte field_4_bBoolErr;
82 private byte field_5_fError;
83
84
85
86 public BoolErrRecord()
87 {
88 }
89
90
97
98 public BoolErrRecord(short id, short size, byte [] data)
99 {
100 super(id, size, data);
101 }
102
103
111
112 public BoolErrRecord(short id, short size, byte [] data, int offset)
113 {
114 super(id, size, data, offset);
115 }
116
117
124
125 protected void fillFields(byte [] data, short size, int offset)
126 {
127
128 field_1_row = LittleEndian.getUShort(data, 0 + offset);
129 field_2_column = LittleEndian.getShort(data, 2 + offset);
130 field_3_xf_index = LittleEndian.getShort(data, 4 + offset);
131 field_4_bBoolErr = data[ 6 + offset ];
132 field_5_fError = data[ 7 + offset ];
133 }
134
135
136 public void setRow(int row)
137 {
138 field_1_row = row;
139 }
140
141 public void setColumn(short col)
142 {
143 field_2_column = col;
144 }
145
146
151
152 public void setXFIndex(short xf)
153 {
154 field_3_xf_index = xf;
155 }
156
157
162
163 public void setValue(boolean value)
164 {
165 field_4_bBoolErr = value ? ( byte ) 1
166 : ( byte ) 0;
167 field_5_fError = ( byte ) 0;
168 }
169
170
175
176 public void setValue(byte value)
177 {
178 field_4_bBoolErr = value;
179 field_5_fError = ( byte ) 1;
180 }
181
182
183 public int getRow()
184 {
185 return field_1_row;
186 }
187
188 public short getColumn()
189 {
190 return field_2_column;
191 }
192
193
198
199 public short getXFIndex()
200 {
201 return field_3_xf_index;
202 }
203
204
209
210 public boolean getBooleanValue()
211 {
212 return (field_4_bBoolErr != 0);
213 }
214
215
220
221 public byte getErrorValue()
222 {
223 return field_4_bBoolErr;
224 }
225
226
231
232 public boolean isBoolean()
233 {
234 return (field_5_fError == ( byte ) 0);
235 }
236
237
242
243 public boolean isError()
244 {
245 return (field_5_fError != ( byte ) 0);
246 }
247
248 public String toString()
249 {
250 StringBuffer buffer = new StringBuffer();
251
252 buffer.append("[BOOLERR]\n");
253 buffer.append(" .row = ")
254 .append(Integer.toHexString(getRow())).append("\n");
255 buffer.append(" .col = ")
256 .append(Integer.toHexString(getColumn())).append("\n");
257 buffer.append(" .xfindex = ")
258 .append(Integer.toHexString(getXFIndex())).append("\n");
259 if (isBoolean())
260 {
261 buffer.append(" .booleanValue = ").append(getBooleanValue())
262 .append("\n");
263 }
264 else
265 {
266 buffer.append(" .errorValue = ").append(getErrorValue())
267 .append("\n");
268 }
269 buffer.append("[/BOOLERR]\n");
270 return buffer.toString();
271 }
272
273
280
281 public int serialize(int offset, byte [] data)
282 {
283 LittleEndian.putShort(data, 0 + offset, sid);
284 LittleEndian.putShort(data, 2 + offset, ( short ) 8);
285
286 LittleEndian.putShort(data, 4 + offset, ( short ) getRow());
287 LittleEndian.putShort(data, 6 + offset, getColumn());
288 LittleEndian.putShort(data, 8 + offset, getXFIndex());
289 data[ 10 + offset ] = field_4_bBoolErr;
290 data[ 11 + offset ] = field_5_fError;
291 return getRecordSize();
292 }
293
294 public int getRecordSize()
295 {
296 return 12;
297 }
298
299
305
306 protected void validateSid(short id)
307 {
308 if (id != this.sid)
309 {
310 throw new RecordFormatException("Not a valid BoolErrRecord");
311 }
312 }
313
314 public short getSid()
315 {
316 return this.sid;
317 }
318
319 public boolean isBefore(CellValueRecordInterface i)
320 {
321 if (this.getRow() > i.getRow())
322 {
323 return false;
324 }
325 if ((this.getRow() == i.getRow())
326 && (this.getColumn() > i.getColumn()))
327 {
328 return false;
329 }
330 if ((this.getRow() == i.getRow())
331 && (this.getColumn() == i.getColumn()))
332 {
333 return false;
334 }
335 return true;
336 }
337
338 public boolean isAfter(CellValueRecordInterface i)
339 {
340 if (this.getRow() < i.getRow())
341 {
342 return false;
343 }
344 if ((this.getRow() == i.getRow())
345 && (this.getColumn() < i.getColumn()))
346 {
347 return false;
348 }
349 if ((this.getRow() == i.getRow())
350 && (this.getColumn() == i.getColumn()))
351 {
352 return false;
353 }
354 return true;
355 }
356
357 public boolean isEqual(CellValueRecordInterface i)
358 {
359 return ((this.getRow() == i.getRow())
360 && (this.getColumn() == i.getColumn()));
361 }
362
363 public boolean isInValueSection()
364 {
365 return true;
366 }
367
368 public boolean isValue()
369 {
370 return true;
371 }
372
373 public int compareTo(Object obj)
374 {
375 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
376
377 if ((this.getRow() == loc.getRow())
378 && (this.getColumn() == loc.getColumn()))
379 {
380 return 0;
381 }
382 if (this.getRow() < loc.getRow())
383 {
384 return -1;
385 }
386 if (this.getRow() > loc.getRow())
387 {
388 return 1;
389 }
390 if (this.getColumn() < loc.getColumn())
391 {
392 return -1;
393 }
394 if (this.getColumn() > loc.getColumn())
395 {
396 return 1;
397 }
398 return -1;
399 }
400
401 public boolean equals(Object obj)
402 {
403 if (!(obj instanceof CellValueRecordInterface))
404 {
405 return false;
406 }
407 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
408
409 if ((this.getRow() == loc.getRow())
410 && (this.getColumn() == loc.getColumn()))
411 {
412 return true;
413 }
414 return false;
415 }
416 }
417