X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fsolver%2Fformula%2FFormulaError2.java;fp=bundles%2Forg.simantics.spreadsheet%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fsolver%2Fformula%2FFormulaError2.java;h=d0f2b92abf67ce8ce7e267fdddbbda075ea6de23;hb=c07a3818f0024e932a27eb85cbfd3f2291475a65;hp=0000000000000000000000000000000000000000;hpb=6c99e980d250fb9201aba93be7dcb1f55564dccd;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/formula/FormulaError2.java b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/formula/FormulaError2.java new file mode 100644 index 000000000..d0f2b92ab --- /dev/null +++ b/bundles/org.simantics.spreadsheet/src/org/simantics/spreadsheet/solver/formula/FormulaError2.java @@ -0,0 +1,55 @@ +package org.simantics.spreadsheet.solver.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