Exemple #1
0
        /// <summary>
        /// Returns the data that should be placed in the JTable at the given row and column. </summary>
        /// <param name="row"> the row for which to return data. </param>
        /// <param name="col"> the column for which to return data. </param>
        /// <returns> the data that should be placed in the JTable at the given row and col. </returns>
        public virtual object getValueAt(int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }

            StateMod_ReservoirRight rr = (StateMod_ReservoirRight)_data.get(row);

            // necessary for table models that display rights 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:
                return(rr.getCgoto());

            case COL_RIGHT_ID:
                return(rr.getID());

            case COL_RIGHT_NAME:
                return(rr.getName());

            case COL_STRUCT_ID:
                return(rr.getCgoto());

            case COL_ADMIN_NUM:
                return(rr.getRtem());

            case COL_DCR_AMT:
                return(new double?(rr.getDcrres()));

            case COL_ON_OFF:
                return(new int?(rr.getSwitch()));

            case COL_ACCOUNT_DIST:
                return(new int?(rr.getIresco()));

            case COL_RIGHT_TYPE:
                return(new int?(rr.getItyrstr()));

            case COL_FILL_TYPE:
                return(new int?(rr.getN2fill()));

            case COL_OOP_RIGHT:
                return(rr.getCopid());

            default:
                return("");
            }
        }
        /// <summary>
        /// Returns the data that should be placed in the JTable
        /// at the given row and column. </summary>
        /// <param name="row"> the row for which to return data. </param>
        /// <param name="col"> the column for which to return data. </param>
        /// <returns> the data that should be placed in the JTable at the given row and col. </returns>
        public virtual object getValueAt(int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }

            StateMod_ReservoirRight rr = (StateMod_ReservoirRight)_data.get(row);

            switch (col)
            {
            case COL_RIGHT_ID:
                return(rr.getID());

            case COL_RIGHT_NAME:
                return(rr.getName());

            case COL_STRUCT_ID:
                return(rr.getCgoto());

            case COL_ADMIN_NUM:
                return(rr.getRtem());

            case COL_DCR_AMT:
                return(new double?(rr.getDcrres()));

            case COL_ON_OFF:
                return(new int?(rr.getSwitch()));

            case COL_ACCOUNT_DIST:
                return(new int?(rr.getIresco()));

            case COL_RIGHT_TYPE:
                return(new int?(rr.getItyrstr()));

            case COL_FILL_TYPE:
                return(new int?(rr.getN2fill()));

            case COL_OOP_RIGHT:
                return(rr.getCopid());

            default:
                return("");
            }
        }
Exemple #3
0
        /// <summary>
        /// Write reservoir right information to output.  History header information
        /// is also maintained by calling this routine. </summary>
        /// <param name="infile"> input file from which previous history should be taken </param>
        /// <param name="outfile"> output file to which to write </param>
        /// <param name="theRights"> list of reservoir right to print </param>
        /// <param name="newComments"> addition comments which should be included in history </param>
        /// <param name="oldAdminNumFormat"> whether to use the old admin num format or not </param>
        /// <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 void writeStateModFile(String infile, String outfile, java.util.List<StateMod_ReservoirRight> theRights, java.util.List<String> newComments, boolean oldAdminNumFormat) throws Exception
        public static void writeStateModFile(string infile, string outfile, IList <StateMod_ReservoirRight> theRights, IList <string> newComments, bool oldAdminNumFormat)
        {
            IList <string> commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            string      routine = "StateMod_ReservoirRight.writeStateModFile";
            PrintWriter @out    = null;

            if (Message.isDebugOn)
            {
                Message.printDebug(2, routine, "Writing reservoir rights to file: " + outfile);
            }
            try
            {
                @out = IOUtil.processFileHeaders(IOUtil.getPathUsingWorkingDir(infile), IOUtil.getPathUsingWorkingDir(outfile), newComments, commentIndicators, ignoredCommentIndicators, 0);

                string iline = null;
                string cmnt  = "#>";
                StateMod_ReservoirRight right = null;
                IList <object>          v     = new List <object>(10);
                string format_0 = null;
                string format_1 = null;
                if (oldAdminNumFormat)
                {
                    // Left justify...
                    format_0 = "%-12.12s%-24.24s%-12.12s    %-12.12s%8.0f%8d%8d%8d%8d%-12.12s";
                    format_1 = "%-12.12s%-24.24s%-12.12s    %-12.12s%8.2f%8d%8d%8d%8d%-12.12s";
                }
                else
                {
                    // Right justify...
                    format_0 = "%-12.12s%-24.24s%-12.12s    %12.12s%8.0f%8d%8d%8d%8d%-12.12s";
                    format_1 = "%-12.12s%-24.24s%-12.12s    %12.12s%8.2f%8d%8d%8d%8d%-12.12s";
                }

                @out.println(cmnt);
                @out.println(cmnt + " *******************************************************");
                @out.println(cmnt + "  StateMod Reservoir Right File");
                @out.println(cmnt);
                @out.println(cmnt + "  format:  (a12, a24, a12, F16.5, f8.0, 4i8, a12)");
                @out.println(cmnt);
                @out.println(cmnt + "  ID       cirsid:  Reservoir right ID");
                @out.println(cmnt + "  Name      namer:  Reservoir name");
                @out.println(cmnt + "  Res ID    cgoto:  Reservoir ID tied to this right");
                @out.println(cmnt + "  Admin #    rtem:  Administration number");
                @out.println(cmnt + "                    (small is senior).");
                @out.println(cmnt + "  Decree   dcrres:  Decreed amount (af)");
                @out.println(cmnt + "  On/Off   irsrsw:  Switch 0 = off,1 = on");
                @out.println(cmnt + "                    YYYY = on for years >= YYYY");
                @out.println(cmnt + "                    -YYYY = off for years > YYYY");
                @out.println(cmnt + "  Owner    iresco:  Ownership code");
                @out.println(cmnt + "                      >0, account to be filled");
                @out.println(cmnt + "                      <0, ownership go to 1st (n) accounts");
                @out.println(cmnt + "  Type     ityrsr:  Reservoir type");
                @out.println(cmnt + "                      1=Standard");
                @out.println(cmnt + "                      2=Out of priority water right");
                @out.println(cmnt + "  Fill #   n2fill:  Right type 1=1st fill, 2=2nd fill");
                @out.println(cmnt + "  Out ID    copid:  Out of priority associated operational ");
                @out.println(cmnt + "                      right  (when ityrsr=-1)");
                @out.println(cmnt);
                @out.println(cmnt + "    ID     Name                    Res ID            Admin #   Decree  On/Off  Owner   Type    Fill #  Out ID     ");
                @out.println(cmnt + "---------eb----------------------eb----------eb--------------eb------eb------eb------eb------eb------eb----------e");
                @out.println(cmnt);
                @out.println(cmnt + "EndHeader");
                @out.println(cmnt);

                int num = 0;
                if (theRights != null)
                {
                    num = theRights.Count;
                }
                for (int i = 0; i < num; i++)
                {
                    right = (StateMod_ReservoirRight)theRights[i];
                    if (right == null)
                    {
                        continue;
                    }
                    v.Clear();
                    v.Add(right.getID());
                    v.Add(right.getName());
                    v.Add(right.getCgoto());
                    v.Add(right.getRtem());
                    v.Add(new double?(right.getDcrres()));
                    v.Add(new int?(right.getSwitch()));
                    v.Add(new int?(right.getIresco()));
                    v.Add(new int?(right.getItyrstr()));
                    v.Add(new int?(right.getN2fill()));
                    v.Add(right.getCopid());
                    if (right.getDcrres() < 1.0)
                    {
                        // Use the format for a small right(8.2)...
                        iline = StringUtil.formatString(v, format_1);
                    }
                    else
                    {
                        // Default format 8.0...
                        iline = StringUtil.formatString(v, format_0);
                    }
                    @out.println(iline);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Writes a list of StateMod_ReservoirRight objects to a list file.  A header is
        /// printed to the top of the file, containing the commands used to generate the
        /// file.  Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary>
        /// <param name="filename"> the name of the file to which the data will be written. </param>
        /// <param name="delimiter"> the delimiter to use for separating field values. </param>
        /// <param name="update"> whether to update an existing file, retaining the current
        /// header (true) or to create a new file with a new header. </param>
        /// <param name="data"> the list of objects to write. </param>
        /// <param name="newComments"> comments to write to the top of the file. </param>
        /// <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 void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_ReservoirRight> data, java.util.List<String> newComments) throws Exception
        public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_ReservoirRight> data, IList <string> newComments)
        {
            string routine = "StateMod_ReservoirRight.writeListFile";
            int    size    = 0;

            if (data != null)
            {
                size = data.Count;
            }

            IList <string> fields = new List <string>();

            fields.Add("ID");
            fields.Add("Name");
            fields.Add("StructureID");
            fields.Add("AdministrationNumber");
            fields.Add("DecreedAmount");
            fields.Add("OnOff");
            fields.Add("AccountDistribution");
            fields.Add("Type");
            fields.Add("FillType");
            fields.Add("OopRight");
            int fieldCount = fields.Count;

            string[] names   = new string[fieldCount];
            string[] formats = new string[fieldCount];
            int      comp    = StateMod_DataSet.COMP_RESERVOIR_RIGHTS;
            string   s       = null;

            for (int i = 0; i < fieldCount; i++)
            {
                s          = fields[i];
                names[i]   = StateMod_Util.lookupPropValue(comp, "FieldName", s);
                formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s);
            }

            string oldFile = null;

            if (update)
            {
                oldFile = IOUtil.getPathUsingWorkingDir(filename);
            }

            int j = 0;
            StateMod_ReservoirRight right             = null;
            IList <string>          commentIndicators = new List <string>(1);

            commentIndicators.Add("#");
            IList <string> ignoredCommentIndicators = new List <string>(1);

            ignoredCommentIndicators.Add("#>");
            string[]      line   = new string[fieldCount];
            StringBuilder buffer = new StringBuilder();
            PrintWriter   @out   = null;

            try
            {
                // Add some basic comments at the top of the file.  Do this to a copy of the
                // incoming comments so that they are not modified in the calling code.
                IList <string> newComments2 = null;
                if (newComments == null)
                {
                    newComments2 = new List <string>();
                }
                else
                {
                    newComments2 = new List <string>(newComments);
                }
                newComments2.Insert(0, "");
                newComments2.Insert(1, "StateMod reservoir rights as a delimited list file.");
                newComments2.Insert(2, "");
                @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0);

                for (int i = 0; i < fieldCount; i++)
                {
                    if (i > 0)
                    {
                        buffer.Append(delimiter);
                    }
                    buffer.Append("\"" + names[i] + "\"");
                }

                @out.println(buffer.ToString());

                for (int i = 0; i < size; i++)
                {
                    right = (StateMod_ReservoirRight)data[i];

                    line[0] = StringUtil.formatString(right.getID(), formats[0]).Trim();
                    line[1] = StringUtil.formatString(right.getName(), formats[1]).Trim();
                    line[2] = StringUtil.formatString(right.getCgoto(), formats[2]).Trim();
                    line[3] = StringUtil.formatString(right.getRtem(), formats[3]).Trim();
                    line[4] = StringUtil.formatString(right.getDcrres(), formats[4]).Trim();
                    line[5] = StringUtil.formatString(right.getSwitch(), formats[5]).Trim();
                    line[6] = StringUtil.formatString(right.getIresco(), formats[6]).Trim();
                    line[7] = StringUtil.formatString(right.getItyrstr(), formats[7]).Trim();
                    line[8] = StringUtil.formatString(right.getN2fill(), formats[8]).Trim();
                    line[9] = StringUtil.formatString(right.getCopid(), formats[9]).Trim();

                    buffer = new StringBuilder();
                    for (j = 0; j < fieldCount; j++)
                    {
                        if (j > 0)
                        {
                            buffer.Append(delimiter);
                        }
                        if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1)
                        {
                            line[j] = "\"" + line[j] + "\"";
                        }
                        buffer.Append(line[j]);
                    }

                    @out.println(buffer.ToString());
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, e);
                throw e;
            }
            finally
            {
                if (@out != null)
                {
                    @out.flush();
                    @out.close();
                }
            }
        }