/**
  * Constructor
  *
  * @param code the code
  * @param desc the description
  */
 FormulaErrorCode(int code, string desc)
 {
     errorCode   = code;
     description = desc;
     FormulaErrorCode[] newcodes = new FormulaErrorCode[codes.Length + 1];
     System.Array.Copy(codes, 0, newcodes, 0, codes.Length);
     newcodes[codes.Length] = this;
     codes = newcodes;
 }
 /**
  * Constructor
  *
  * @param code the code
  * @param desc the description
  */
 FormulaErrorCode(int code,string desc)
 {
     errorCode = code;
     description = desc;
     FormulaErrorCode[] newcodes = new FormulaErrorCode[codes.Length + 1];
     System.Array.Copy(codes,0,newcodes,0,codes.Length);
     newcodes[codes.Length] = this;
     codes = newcodes;
 }
        /**
         * Returns the numerical value as a string
         *
         * @return The numerical value of the formula as a string
         */
        public override string getContents()
        {
            if (error == null)
            {
                error = FormulaErrorCode.getErrorCode(errorCode);
            }

            return(error != FormulaErrorCode.UNKNOWN ?
                   error.getDescription() : "ERROR " + errorCode);
        }
        /**
         * Gets the error type given just the code
         *
         * @param code the code to lookup
         * @return the error type
         */
        public static FormulaErrorCode getErrorCode(int code)
        {
            bool             found = false;
            FormulaErrorCode ec    = UNKNOWN;

            for (int i = 0; i < codes.Length && !found; i++)
            {
                if (codes[i].errorCode == code)
                {
                    found = true;
                    ec    = codes[i];
                }
            }
            return(ec);
        }
        /**
         * Gets the error type given the string value
         *
         * @param code the code to lookup
         * @return the error type
         */
        public static FormulaErrorCode getErrorCode(string code)
        {
            bool             found = false;
            FormulaErrorCode ec    = UNKNOWN;

            if (code == null || code.Length == 0)
            {
                return(ec);
            }

            for (int i = 0; i < codes.Length && !found; i++)
            {
                if (codes[i].description.Equals(code))
                {
                    found = true;
                    ec    = codes[i];
                }
            }
            return(ec);
        }