Exemplo n.º 1
0
        /// <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];
            }
            StateMod_InstreamFlow isf = (StateMod_InstreamFlow)_data.get(row);

            switch (col)
            {
            case COL_ID:
                isf.setID((string)value);
                break;

            case COL_NAME:
                isf.setName((string)value);
                break;

            case COL_DAILY_ID:
                isf.setCifridy((string)value);
                break;

            case COL_DOWN_NODE:
                isf.setIfrrdn((string)value);
                break;

            case COL_DEMAND_TYPE:
                isf.setIifcom(((int?)value).Value);
                break;
            }
            base.setValueAt(value, row, col);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read instream flow information in and store in a list.  The new instream
        /// flows are added to the end of the previously stored instream flows. </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_InstreamFlow> readStateModFile(String filename) throws Exception
        public static IList <StateMod_InstreamFlow> readStateModFile(string filename)
        {
            string routine = "StateMod_InstreamFlow.readStateModFile";
            string iline, s;
            IList <StateMod_InstreamFlow> theIns = new List <StateMod_InstreamFlow>();
            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_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING };
            int[] format_0w = new int[] { 12, 24, 12, 8, 1, 12, 1, 12, 8 };

            if (Message.isDebugOn)
            {
                Message.printDebug(10, routine, "Reading file: " + filename);
            }
            StreamReader @in = null;

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

                    // allocate new instream flow node
                    anIns = new StateMod_InstreamFlow();

                    // line 1
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 1: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_0, format_0w, v);
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "Fixed read returned " + v.Count + " elements");
                    }
                    s = StringUtil.unpad((string)v[0], " ", StringUtil.PAD_FRONT_BACK);
                    anIns.setID(s);
                    s = StringUtil.unpad((string)v[1], " ", StringUtil.PAD_FRONT_BACK);
                    anIns.setName(s);
                    s = StringUtil.unpad((string)v[2], " ", StringUtil.PAD_FRONT_BACK);
                    anIns.setCgoto(s);
                    anIns.setSwitch((int?)v[3]);
                    s = StringUtil.unpad((string)v[5], " ", StringUtil.PAD_FRONT_BACK);
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "Ifrrdn: " + s);
                    }
                    anIns.setIfrrdn(s);
                    // daily id
                    s = StringUtil.unpad((string)v[7], " ", StringUtil.PAD_FRONT_BACK);
                    anIns.setCifridy(s);
                    // Data type(read as string and convert to integer)...
                    s = StringUtil.unpad((string)v[8], " ", StringUtil.PAD_FRONT_BACK);
                    anIns.setIifcom(s);

                    // add the instream flow to the vector of instream flows
                    theIns.Add(anIns);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theIns);
        }