/// <summary> /// Read reservoir right information in and store in a list. </summary> /// <param name="filename"> Name of file to read. </param> /// <returns> list of reservoir right data </returns> /// <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_ReservoirRight> readStateModFile(String filename) throws Exception public static IList <StateMod_ReservoirRight> readStateModFile(string filename) { string routine = "StateMod_ReservoirRight.readStateModFile"; IList <StateMod_ReservoirRight> theRights = new List <StateMod_ReservoirRight>(); int[] format_0 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_STRING }; int[] format_0w = new int[] { 12, 24, 12, 16, 8, 8, 8, 8, 8, 12 }; string iline = null; IList <object> v = new List <object>(10); StreamReader @in = null; StateMod_ReservoirRight aRight = null; Message.printStatus(2, routine, "Reading reservoir rights file: " + filename); try { @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename)); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } aRight = new StateMod_ReservoirRight(); StringUtil.fixedRead(iline, format_0, format_0w, v); if (Message.isDebugOn) { Message.printDebug(50, routine, "iline: " + iline); } aRight.setID(((string)v[0]).Trim()); aRight.setName(((string)v[1]).Trim()); aRight.setCgoto(((string)v[2]).Trim()); aRight.setRtem(((string)v[3]).Trim()); aRight.setDcrres((double?)v[4]); aRight.setSwitch((int?)v[5]); aRight.setIresco((int?)v[6]); aRight.setItyrstr((int?)v[7]); aRight.setN2fill((int?)v[8]); aRight.setCopid(((string)v[9]).Trim()); theRights.Add(aRight); } } catch (Exception e) { Message.printWarning(3, routine, e); throw e; } finally { if (@in != null) { @in.Close(); } } return(theRights); }
/// <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_ReservoirRight rr = (StateMod_ReservoirRight)_data.get(row); switch (col) { case COL_RIGHT_ID: rr.setID((string)value); break; case COL_RIGHT_NAME: rr.setName((string)value); break; case COL_STRUCT_ID: rr.setCgoto((string)value); break; case COL_ADMIN_NUM: rr.setRtem((string)value); break; case COL_DCR_AMT: dval = ((double?)value).Value; rr.setDcrres(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; rr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; int index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); rr.setSwitch(ival); } break; case COL_ACCOUNT_DIST: if (value is int?) { ival = ((int?)value).Value; rr.setIresco(ival); } else if (value is string) { string acct = (string)value; int index = acct.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(acct.Substring(0, index))); rr.setIresco(ival); } break; case COL_RIGHT_TYPE: if (value is int?) { ival = ((int?)value).Value; rr.setItyrstr(ival); } else if (value is string) { string right = (string)value; int index = right.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(right.Substring(0, index))); rr.setItyrstr(ival); } break; case COL_FILL_TYPE: if (value is int?) { ival = ((int?)value).Value; rr.setN2fill(ival); } else if (value is string) { string fill = (string)value; int index = fill.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(fill.Substring(0, index))); rr.setN2fill(ival); } break; case COL_OOP_RIGHT: rr.setCopid((string)value); break; } base.setValueAt(value, row, col); }
/// <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_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: rr.setCgoto((string)value); break; case COL_RIGHT_ID: rr.setID((string)value); break; case COL_RIGHT_NAME: rr.setName((string)value); break; case COL_STRUCT_ID: rr.setCgoto((string)value); break; case COL_ADMIN_NUM: rr.setRtem((string)value); break; case COL_DCR_AMT: dval = ((double?)value).Value; rr.setDcrres(dval); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; rr.setSwitch(ival); } else if (value is string) { string onOff = (string)value; int index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); rr.setSwitch(ival); } break; case COL_ACCOUNT_DIST: if (value is int?) { ival = ((int?)value).Value; rr.setIresco(ival); } else if (value is string) { string acct = (string)value; int index = acct.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(acct.Substring(0, index))); rr.setIresco(ival); } break; case COL_RIGHT_TYPE: if (value is int?) { ival = ((int?)value).Value; rr.setItyrstr(ival); } else if (value is string) { string right = (string)value; int index = right.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(right.Substring(0, index))); rr.setItyrstr(ival); } break; case COL_FILL_TYPE: if (value is int?) { ival = ((int?)value).Value; rr.setN2fill(ival); } else if (value is string) { string fill = (string)value; int index = fill.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(fill.Substring(0, index))); rr.setN2fill(ival); } break; case COL_OOP_RIGHT: rr.setCopid((string)value); break; } if (!__singleReservoir) { col++; } base.setValueAt(value, row, col); }