KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > read > biff > ErrorRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.read.biff;
21
22 import jxl.ErrorCell;
23 import jxl.CellType;
24 import jxl.biff.FormattingRecords;
25
26 /**
27  * A cell containing an error code. This will usually be the result
28  * of some error during the calculation of a formula
29  */

30 class ErrorRecord extends CellValue implements ErrorCell
31 {
32   /**
33    * The error code if this cell evaluates to an error, otherwise zer0
34    */

35   private int errorCode;
36
37   /**
38    * Constructs this object
39    *
40    * @param t the raw data
41    * @param fr the formatting records
42    * @param si the sheet
43    */

44   public ErrorRecord(Record t, FormattingRecords fr, SheetImpl si)
45   {
46     super(t, fr, si);
47
48     byte[] data = getRecord().getData();
49
50     errorCode = data[6];
51   }
52
53   /**
54    * Interface method which gets the error code for this cell. If this cell
55    * does not represent an error, then it returns 0. Always use the
56    * method isError() to determine this prior to calling this method
57    *
58    * @return the error code if this cell contains an error, 0 otherwise
59    */

60   public int getErrorCode()
61   {
62     return errorCode;
63   }
64
65   /**
66    * Returns the numerical value as a string
67    *
68    * @return The numerical value of the formula as a string
69    */

70   public String JavaDoc getContents()
71   {
72     return "ERROR " + errorCode;
73   }
74
75   /**
76    * Returns the cell type
77    *
78    * @return The cell type
79    */

80   public CellType getType()
81   {
82     return CellType.ERROR;
83   }
84 }
85
86
Popular Tags