/// <summary>
        /// Parses the diversion rights file and returns a Vector of StateMod_DiversionRight objects. </summary>
        /// <param name="filename"> the diversion rights file to parse. </param>
        /// <returns> a Vector of StateMod_DiversionRight objects. </returns>
        /// <exception cref="Exception"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static java.util.List<StateMod_DiversionRight> readStateModFile(String filename) throws Exception
        public static IList <StateMod_DiversionRight> readStateModFile(string filename)
        {
            string routine = "StateMod_DiversionRight.readStateModFile";
            IList <StateMod_DiversionRight> theDivRights = new List <StateMod_DiversionRight> ();

            int[]                   format_0  = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER };
            int[]                   format_0w = new int[] { 12, 24, 12, 16, 8, 8 };
            string                  iline     = null;
            IList <object>          v         = new List <object>(6);
            StreamReader            @in       = null;
            StateMod_DiversionRight aRight    = null;

            Message.printStatus(2, routine, "Reading diversion rights file: " + filename);

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

                    aRight = new StateMod_DiversionRight();

                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "iline: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_0, format_0w, v);
                    aRight.setID(((string)v[0]).Trim());
                    aRight.setName(((string)v[1]).Trim());
                    aRight.setCgoto(((string)v[2]).Trim());
                    aRight.setIrtem(((string)v[3]).Trim());
                    aRight.setDcrdiv((double?)v[4]);
                    aRight.setSwitch((int?)v[5]);
                    // Mark as clean because set methods may have marked dirty...
                    aRight.setDirty(false);
                    theDivRights.Add(aRight);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theDivRights);
        }
Exemple #2
0
        /// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;
            int    index;

            StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row);

            switch (col)
            {
            case COL_RIGHT_ID:
                dr.setID((string)value);
                break;

            case COL_RIGHT_NAME:
                dr.setName((string)value);
                break;

            case COL_STRUCT_ID:
                dr.setCgoto((string)value);
                break;

            case COL_ADMIN_NUM:
                dr.setIrtem((string)value);
                break;

            case COL_DCR_AMT:
                dval = ((double?)value).Value;
                dr.setDcrdiv(dval);
                break;

            case COL_ON_OFF:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    dr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival  = (Convert.ToInt32(onOff.Substring(0, index)));
                    dr.setSwitch(ival);
                }
                break;
            }

            base.setValueAt(value, row, col);
        }
        /// <summary>
        /// Inserts the specified value into the table at the given position. </summary>
        /// <param name="value"> the object to store in the table cell. </param>
        /// <param name="row"> the row of the cell in which to place the object. </param>
        /// <param name="col"> the column of the cell in which to place the object. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            double dval;
            int    ival;
            int    index;

            // necessary for table models that display rights for 1+ diversions,
            // 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 (!__singleDiversion)
            {
                col--;
            }

            StateMod_DiversionRight dr = (StateMod_DiversionRight)_data.get(row);

            switch (col)
            {
            case COL_DIVERSION_ID:
                dr.setCgoto((string)value);
                break;

            case COL_RIGHT_ID:
                dr.setID((string)value);
                break;

            case COL_RIGHT_NAME:
                dr.setName((string)value);
                break;

            case COL_STRUCT_ID:
                dr.setCgoto((string)value);
                break;

            case COL_ADMIN_NUM:
                dr.setIrtem((string)value);
                break;

            case COL_DCR_AMT:
                dval = ((double?)value).Value;
                dr.setDcrdiv(dval);
                break;

            case COL_ON_OFF:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    dr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival  = (Convert.ToInt32(onOff.Substring(0, index)));
                    dr.setSwitch(ival);
                }
                break;
            }

            if (!__singleDiversion)
            {
                col++;
            }

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