/// <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_InstreamFlowRight infr = (StateMod_InstreamFlowRight)_data.get(row); switch (col) { case COL_RIGHT_ID: return(infr.getID()); case COL_RIGHT_NAME: return(infr.getName()); case COL_STRUCT_ID: return(infr.getCgoto()); case COL_ADMIN_NUM: return(infr.getIrtem()); case COL_DCR_AMT: return(new double?(infr.getDcrifr())); case COL_ON_OFF: return(new int?(infr.getSwitch())); default: return(""); } }
/// <summary> /// Writes a list of StateMod_InstreamFlowRight 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 add to the the file header. </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_InstreamFlowRight> data, java.util.List<String> newComments) throws Exception public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_InstreamFlowRight> data, IList <string> newComments) { string routine = "StateMod_IntreamFlowRight.writeListFile"; int size = 0; if (data != null) { size = data.Count; } IList <string> fields = new List <string>(); fields.Add("ID"); fields.Add("Name"); fields.Add("StationID"); fields.Add("AdministrationNumber"); fields.Add("Decree"); fields.Add("OnOff"); int fieldCount = fields.Count; string[] names = new string[fieldCount]; string[] formats = new string[fieldCount]; int comp = StateMod_DataSet.COMP_INSTREAM_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; PrintWriter @out = null; StateMod_InstreamFlowRight 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(); 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 instream flow 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 = 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.getIrtem(), formats[3]).Trim(); line[4] = StringUtil.formatString(right.getDcrifr(), formats[4]).Trim(); line[5] = StringUtil.formatString(right.getSwitch(), formats[5]).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(); } } }