/// <summary>
        /// Sets the value at the specified position to the specified value. </summary>
        /// <param name="value"> the value to set the cell to. </param>
        /// <param name="row"> the row of the cell for which to set the value. </param>
        /// <param name="col"> the col of the cell for which to set the value. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;
            StateMod_ReservoirAccount rac = (StateMod_ReservoirAccount)_data.get(row);

            // necessary for table models that display accounts for 1+ reservoirs,
            // so that the -1st column (ID) can also be displayed.  By doing it
            // this way, code can be shared between the two kinds of table models
            // and less maintenance is necessary.
            if (!__singleReservoir)
            {
                col--;
            }

            switch (col)
            {
            case COL_RESERVOIR_ID:
                rac.setCgoto((string)value);
                break;

            case COL_OWNER_ID:
                rac.setID((string)value);
                break;

            case COL_OWNER_ACCOUNT:
                rac.setName((string)value);
                break;

            case COL_MAX_STORAGE:
                dval = ((double?)value).Value;
                rac.setOwnmax(dval);
                break;

            case COL_INITIAL_STORAGE:
                dval = ((double?)value).Value;
                rac.setCurown(dval);
                break;

            case COL_PRORATE_EVAP:
                if (value is double?)
                {
                    dval = ((double?)value).Value;
                    rac.setPcteva(dval);
                }
                else if (value is string)
                {
                    int    index = ((string)value).IndexOf(" -", StringComparison.Ordinal);
                    string s     = ((string)value).Substring(0, index);
                    dval = (Convert.ToDouble(s));
                    rac.setPcteva(dval);
                }
                break;

            case COL_OWNERSHIP_TIE:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    rac.setN2own(ival);
                }
                else if (value is string)
                {
                    string n2owns = (string)value;
                    int    index  = n2owns.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(n2owns.Substring(0, index)));
                    rac.setN2own(ival);
                }
                break;
            }

            if (!__singleReservoir)
            {
                col++;
            }

            base.setValueAt(value, row, col);
        }
        /// <summary>
        /// Read reservoir information in and store in a Vector. </summary>
        /// <param name="filename"> Name of file to read. </param>
        /// <exception cref="Exception"> if there is an error reading the file. </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public static java.util.List<StateMod_Reservoir> readStateModFile(String filename) throws Exception
        public static IList <StateMod_Reservoir> readStateModFile(string filename)
        {
            string routine = "StateMod_Reservoir.readStateModFile";
            IList <StateMod_Reservoir> theReservoirs = new List <StateMod_Reservoir>();
            string         iline = null;
            IList <object> v     = new List <object>(9);

            int[]                     format_0   = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING };
            int[]                     format_0w  = new int[] { 12, 24, 12, 8, 8, 1, 12 };
            int[]                     format_1   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER };
            int[]                     format_1w  = new int[] { 24, 8, 8, 8, 8, 8, 8, 8, 8 };
            int[]                     format_2   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER };
            int[]                     format_2w  = new int[] { 12, 12, 8, 8, 8, 8 };
            int[]                     format_3   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE };
            int[]                     format_3w  = new int[] { 24, 12, 8 };
            int[]                     format_4   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE };
            int[]                     format_4w  = new int[] { 24, 8, 8, 8 };
            StreamReader              @in        = null;
            StateMod_Reservoir        aReservoir = null;
            StateMod_ReservoirAccount anAccount  = null;
            StateMod_ReservoirClimate anEvap     = null;
            StateMod_ReservoirClimate aPtpx      = null;
            int i = 0;

            if (Message.isDebugOn)
            {
                Message.printDebug(10, routine, "in SMParseResFile reading file: " + filename);
            }
            int line_count = 0;

            try
            {
                @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename));
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    ++line_count;
                    // check for comments
                    if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0)
                    {
                        continue;
                    }

                    // allocate new reservoir node
                    aReservoir = new StateMod_Reservoir();

                    // line 1
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 1: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_0, format_0w, v);
                    aReservoir.setID(((string)v[0]).Trim());
                    aReservoir.setName(((string)v[1]).Trim());
                    aReservoir.setCgoto(((string)v[2]).Trim());
                    aReservoir.setSwitch((int?)v[3]);
                    aReservoir.setRdate((double?)v[4]);
                    aReservoir.setCresdy(((string)v[5]).Trim());

                    // line 2
                    iline = @in.ReadLine();
                    ++line_count;
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 2: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_1, format_1w, v);
                    aReservoir.setVolmin(((double?)v[0]));
                    aReservoir.setVolmax(((double?)v[1]));
                    aReservoir.setFlomax(((double?)v[2]));
                    aReservoir.setDeadst(((double?)v[3]));
                    int nowner = ((int?)v[4]).Value;
                    int nevap  = ((int?)v[5]).Value;
                    int nptpx  = ((int?)v[6]).Value;
                    int nrange = ((int?)v[7]).Value;

                    // get the owner's information
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "Number of owners: " + nowner);
                    }
                    for (i = 0; i < nowner; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_2, format_2w, v);
                        anAccount = new StateMod_ReservoirAccount();
                        // Account ID is set to the numerical count (StateMod uses the number)
                        anAccount.setID("" + (i + 1));
                        anAccount.setName(((string)v[0]).Trim());
                        anAccount.setOwnmax(((double?)v[1]));
                        anAccount.setCurown(((double?)v[2]));
                        anAccount.setPcteva(((double?)v[3]));
                        anAccount.setN2own(((int?)v[4]));
                        aReservoir.addAccount(anAccount);
                    }

                    // get the evaporation information
                    for (i = 0; i < nevap; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_3, format_3w, v);
                        anEvap = new StateMod_ReservoirClimate();
                        anEvap.setID(((string)v[0]).Trim());
                        anEvap.setType(StateMod_ReservoirClimate.CLIMATE_EVAP);
                        anEvap.setWeight(((double?)v[1]));
                        aReservoir.addClimate(anEvap);
                    }

                    // get the precipitation information
                    for (i = 0; i < nptpx; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_3, format_3w, v);
                        aPtpx = new StateMod_ReservoirClimate();
                        aPtpx.setID(((string)v[0]).Trim());
                        aPtpx.setType(StateMod_ReservoirClimate.CLIMATE_PTPX);
                        aPtpx.setWeight(((double?)v[1]));
                        aReservoir.addClimate(aPtpx);
                    }

                    // get the area capacity information
                    for (i = 0; i < nrange; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_4, format_4w, v);
                        StateMod_ReservoirAreaCap anAreaCap = new StateMod_ReservoirAreaCap();
                        anAreaCap.setConten(((double?)v[0]));
                        anAreaCap.setSurarea(((double?)v[1]));
                        anAreaCap.setSeepage(((double?)v[2]));
                        aReservoir.addAreaCap(anAreaCap);
                    }

                    // add the reservoir to the vector of reservoirs
                    theReservoirs.Add(aReservoir);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, "Error reading reservoir stations in line " + line_count);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theReservoirs);
        }
        /// <summary>
        /// Sets the value at the specified position to the specified value. </summary>
        /// <param name="value"> the value to set the cell to. </param>
        /// <param name="row"> the row of the cell for which to set the value. </param>
        /// <param name="col"> the col of the cell for which to set the value. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;
            StateMod_ReservoirAccount rac = (StateMod_ReservoirAccount)_data.get(row);

            switch (col)
            {
            case COL_RESERVOIR_ID:
                rac.setCgoto((string)value);
                break;

            case COL_OWNER_ID:
                rac.setID((string)value);
                break;

            case COL_OWNER_ACCOUNT:
                rac.setName((string)value);
                break;

            case COL_MAX_STORAGE:
                dval = ((double?)value).Value;
                rac.setOwnmax(dval);
                break;

            case COL_INITIAL_STORAGE:
                dval = ((double?)value).Value;
                rac.setCurown(dval);
                break;

            case COL_PRORATE_EVAP:
                if (value is double?)
                {
                    dval = ((double?)value).Value;
                    rac.setPcteva(dval);
                }
                else if (value is string)
                {
                    int    index = ((string)value).IndexOf(" -", StringComparison.Ordinal);
                    string s     = ((string)value).Substring(0, index);
                    dval = (Convert.ToDouble(s));
                    rac.setPcteva(dval);
                }
                break;

            case COL_OWNERSHIP_TIE:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    rac.setN2own(ival);
                }
                else if (value is string)
                {
                    string n2owns = (string)value;
                    int    index  = n2owns.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(n2owns.Substring(0, index)));
                    rac.setN2own(ival);
                }
                break;
            }

            base.setValueAt(value, row, col);
        }