X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fformula%2FFormulaError2.java;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fformula%2FFormulaError2.java;h=cb54334f617c13303e0b6f05993291b0f963538d;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/FormulaError2.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/FormulaError2.java new file mode 100644 index 000000000..cb54334f6 --- /dev/null +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/formula/FormulaError2.java @@ -0,0 +1,54 @@ +package org.simantics.spreadsheet.graph.formula; + +import java.util.HashMap; +import java.util.Map; +import org.apache.poi.util.Internal; +import org.simantics.databoard.binding.mutable.Variant; + +public enum FormulaError2{ + @Internal + _NO_ERROR(-1, "(no error)"),NULL(0x00, "#NULL"),DIV0(0x07,"#DIV/0!"),VALUE(0x0F, + "#VALUE!"),REF(0x17,"#REF!"),NAME(0x1D,"#NAME?"),NUM(0x24,"#NUM!"),NA(0x2A, "#N/A"), + CIRCULAR_REF(0xFFFFFFC4, "~CIRCULAR~REF~"),FUNCTION_NOT_IMPLEMENTED(0xFFFFFFE2,"~FUNCTION~NOT~IMPLEMENTED~"); + + private final String text; + //private final Integer longType; + //private final byte shortType; + + private static Map smap = new HashMap(); + + private FormulaError2(int type, String text){ + //this.longType = type; + //this.shortType = (byte)type; + this.text = text; + } + + static { + for(FormulaError2 error : values()) { + smap.put(error.getString(), error); + } + } + + public String getString(){ + return this.text; + } + + public static FormulaError2 forString(String errorName){ + FormulaError2 err = smap.get(errorName); + return err; + } + + public static FormulaError2 forObject(Object errorObj){ + if(errorObj instanceof Variant) + return forString(((Variant)errorObj).getValue().toString()); + else + return forString(errorObj.toString()); + } + + public static String handleErrorCall(Object value){ + if(value==null) return VALUE.getString(); + FormulaError2 error = FormulaError2.forObject(value); + if(error!=null) return error.getString(); + return VALUE.getString(); + } +} \ No newline at end of file