1 ////////////////////////////////////////////////////////////////////////////////
2 // MillScript-Excel: an Open Spice interpreter and batch website creation tool
3 // Copyright (C) 2006 Open World Ltd, Kevin Rogers
4 //
5 // This file is part of MillScript-Excel.
6 //
7 // MillScript-Excel is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 2 of the License, or (at your option)
10 // any later version.
11 //
12 // MillScript-Excel is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU General Public License along with
18 // MillScript-Excel; if not, write to the Free Software Foundation, Inc., 59 Temple
19 // Place, Suite 330, Boston, MA 02111-1307 USA
20 ////////////////////////////////////////////////////////////////////////////////
21 package org.millscript.office.spreadsheet.formula;
22
23 import org.millscript.office.excel.alerts.BIFFAlert;
24
25 /**
26 *
27 */
28 public enum Error {
29
30 NULL( "#NULL!" ),
31 DIV_BY_ZERO( "#DIV/0!" ),
32 VALUE( "#VALUE!" ),
33 REF( "#REF!" ),
34 NAME( "#NAME?" ),
35 NUM( "#NUM!" ),
36 N_A( "#N/A!" );
37
38 private final String displayName;
39
40 private Error( final String disp ) {
41 this.displayName = disp;
42 }
43
44 public static Error getError( final int code ) {
45 switch ( code ) {
46 case 0x00:
47 return NULL;
48 case 0x07:
49 return DIV_BY_ZERO;
50 case 0x0F:
51 return VALUE;
52 case 0x17:
53 return REF;
54 case 0x1D:
55 return NAME;
56 case 0x24:
57 return NUM;
58 case 0x2A:
59 return N_A;
60 default:
61 throw new BIFFAlert(
62 "Unknown error code for error token"
63 ).culprit( "error code", code ).mishap();
64 }
65 }
66
67 /**
68 * @see java.lang.Enum#toString()
69 */
70 @Override
71 public String toString() {
72 return this.displayName;
73 }
74
75 }