1 package org.simantics.spreadsheet.graph.formula;
3 import java.util.HashMap;
5 import org.apache.poi.util.Internal;
6 import org.simantics.databoard.binding.mutable.Variant;
8 public enum FormulaError2{
10 _NO_ERROR(-1, "(no error)"),NULL(0x00, "#NULL"),DIV0(0x07,"#DIV/0!"),VALUE(0x0F,
11 "#VALUE!"),REF(0x17,"#REF!"),NAME(0x1D,"#NAME?"),NUM(0x24,"#NUM!"),NA(0x2A, "#N/A"),
12 CIRCULAR_REF(0xFFFFFFC4, "~CIRCULAR~REF~"),FUNCTION_NOT_IMPLEMENTED(0xFFFFFFE2,"~FUNCTION~NOT~IMPLEMENTED~");
14 private final String text;
15 //private final Integer longType;
16 //private final byte shortType;
18 private static Map<String, FormulaError2> smap = new HashMap<String, FormulaError2>();
20 private FormulaError2(int type, String text){
21 //this.longType = type;
22 //this.shortType = (byte)type;
27 for(FormulaError2 error : values()) {
28 smap.put(error.getString(), error);
32 public String getString(){
36 public static FormulaError2 forString(String errorName){
37 FormulaError2 err = smap.get(errorName);
41 public static FormulaError2 forObject(Object errorObj){
42 if(errorObj instanceof Variant)
43 return forString(((Variant)errorObj).getValue().toString());
45 return forString(errorObj.toString());
48 public static String handleErrorCall(Object value){
49 if(value==null) return VALUE.getString();
50 FormulaError2 error = FormulaError2.forObject(value);
51 if(error!=null) return error.getString();
52 return VALUE.getString();