/// <summary> /// Get Column Class /// </summary> /// <param name="col">index</param> /// <returns>ColumnName</returns> public Type GetColumnClass(int col)//public Class<?> getColumnClass (int col) { if (col < 0 || col > _data.cols.Count) { throw new java.lang.IllegalArgumentException("Column invalid"); } RColumn rc = (RColumn)_data.cols[col]; if (rc != null) { return(rc.GetColClass()); } return(null); }
/// <summary> /// Get Column Display Name /// </summary> /// <param name="col">index</param> /// <returns>ColumnName</returns> public String GetColumnName(int col) { if (col < 0 || col > _data.cols.Count) { throw new java.lang.IllegalArgumentException("Column invalid"); } RColumn rc = (RColumn)_data.cols[col]; if (rc != null) { return(rc.GetColHeader()); } return(null); }
/// <summary> /// Find index for ColumnName /// </summary> /// <param name="columnName"></param> /// <returns>index or -1 if not found</returns> public int GetColumnIndex(String columnName) { if (columnName == null || columnName.Length == 0) { return(-1); } // for (int i = 0; i < _data.cols.Count; i++) { RColumn rc = (RColumn)_data.cols[i]; // log.fine( "Column " + i + " " + rc.getColSQL() + " ? " + columnName); if (rc.GetColSQL().StartsWith(columnName)) { log.Fine("Column " + i + " " + rc.GetColSQL() + " = " + columnName); return(i); } } return(-1); }
/// <summary> /// Query /// </summary> /// <param name="ctx"></param> /// <param name="whereClause">the SQL where clause (w/o the WHERE)</param> /// <param name="orderClause"></param> public void Query(Ctx ctx, String whereClause, String orderClause) { RColumn rc = null; // Create SQL StringBuilder sql = new StringBuilder("SELECT "); int size = cols.Count; for (int i = 0; i < size; i++) { rc = (RColumn)cols[i];//.get(i); if (i > 0) { sql.Append(","); } sql.Append(rc.GetColSQL()); } sql.Append(" FROM ").Append(_TableName).Append(" ").Append(RModel.TABLE_ALIAS); if (whereClause != null && whereClause.Length > 0) { sql.Append(" WHERE ").Append(whereClause); } String finalSQL = MRole.GetDefault(ctx, false).AddAccessSQL( sql.ToString(), RModel.TABLE_ALIAS, MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); if (orderClause != null && orderClause.Length > 0) { finalSQL += " ORDER BY " + orderClause; } log.Fine(finalSQL); // FillData int index = 0; // rowset index _rows.Clear(); IDataReader idr = null; try { //Statement stmt = DataBase.createStatement(); //ResultSet rs = stmt.executeQuery(finalSQL); idr = DataBase.DB.ExecuteReader(finalSQL, null, null); DataSet ds = DataBase.DB.ExecuteDataset(finalSQL, null, null); while (idr.Read()) { List <Object> row = new List <Object>(size); //index = 1; index = 0; // Columns for (int i = 0; i < size; i++) { rc = (RColumn)cols[i]; // Get ID if (rc.IsIDcol()) { //row.add(new KeyNamePair(rs.getInt(index++), rs.getString(index++))); row.Add(new KeyNamePair(Utility.Util.GetValueOfInt(idr[index++]), Utility.Util.GetValueOfString(idr[index++]))); } // Null check else if (idr[index] == null) { index++; row.Add(null); } else if (rc.GetColClass() == typeof(String)) { row.Add(Utility.Util.GetValueOfString(idr[index++])); } else if (rc.GetColClass() == typeof(Decimal)) { row.Add(Utility.Util.GetValueOfDecimal(idr[index++])); } else if (rc.GetColClass() == typeof(Double)) { row.Add(Utility.Util.GetValueOfDouble(idr[index++])); } else if (rc.GetColClass() == typeof(int)) { row.Add(Utility.Util.GetValueOfInt(idr[index++])); } else if (rc.GetColClass() == typeof(DateTime)) { row.Add(Utility.Util.GetValueOfDateTime(idr[index++])); } else if (rc.GetColClass() == typeof(Boolean)) { row.Add(Utility.Util.GetValueOfBool("Y".Equals(idr[index++]))); } else // should not happen { row.Add(Utility.Util.GetValueOfString(idr[index++])); } } _rows.Add(row); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); idr = null; } if (index == 0) { log.Log(Level.SEVERE, finalSQL, e); } else { log.Log(Level.SEVERE, "Index=" + index + "," + rc, e); } //e.printStackTrace(); } Process(); }
/// <summary> /// Add Column at Index /// </summary> /// <param name="rc">rc</param> /// <param name="index">index</param> public void AddColumn(RColumn rc, int index) { //_data.cols.Add(index, rc); _data.cols.Insert(index, rc); }
/// <summary> /// Add Column /// </summary> /// <param name="rc">rc</param> public void AddColumn(RColumn rc) { _data.cols.Add(rc); }