DBReader/Classes/ResultSet

/**
*
* DBReader 1.0, Access to SAP tables using SAP's .Net Connector.
*
* Author: hardteck
* Email: hardteck@web.de
*
* Last modified: Fr, 17. Okt 2003, 11:31:25
*/
namespace SAPReader {
using System;
using System.Collections;
using SAPReader.SAPKernel;

///
/// A ResultSet gathers a set of ResultLines.
/// It is used by SAPReader.TableReader to store the
/// rows returned by RFC_READ_TABLE.
///
///
public class ResultSet {
///
/// Set of ResultColumns.
///
protected System.Collections.Hashtable cols = null;
///
/// The constructor.
///
public ResultSet(){
this.cols = new Hashtable();
}
///
/// Adds an entry to the resultset. Note that the order of
/// insertion should follow one of the main two natural
/// traversals of the table: row-by-row, or column-by-column.
/// Additionally, the caller is responsible for making all columns
/// the same size to prevent access violations at a later
/// traversal.
///
/// Fieldname of the column the entry is designated for.
/// The entry to add.
public void addEntry(RFC_DB_FLD field, string entry){
ResultColumn col = null;
if(this.cols.Contains(field.Fieldname)){
col = (ResultColumn)this.cols[field.Fieldname];
}
if(col == null){
col = new ResultColumn(field);
this.cols.Add(field.Fieldname, col);
}
col.addEntry(entry);
}
///
/// The number of ResultLines in the set.
///
public int RowCount {
get{return this.cols.Count;}
}
///
/// Returns the number of rows of the set.
/// If the number of rows for all the columns
/// is not equal, an exception is thrown.
///
public int LineCount {
get{
int maxLineCount = this.MinLineCount;
int minLineCount = this.MinLineCount;
if(maxLineCount != minLineCount){
throw new System.Exception(
"The ResultSet contains unequal rows."
);
}
return minLineCount;
}
}
///
/// Returns the number of rows the longest
/// column in the set contains.
///
public int MaxLineCount {
get{
int maxLineCount = 0;
foreach(string field in this.cols.Keys){
ResultColumn col = (ResultColumn)this.cols[field];
if(col.Count > maxLineCount){
maxLineCount = col.Count;
}
}
return maxLineCount;
}
}
///
/// Returns the number of rows the shortest
/// column in the set contains.
///
public int MinLineCount {
get{
int minLineCount = int.MaxValue;
foreach(string field in this.cols.Keys){
ResultColumn col = (ResultColumn)this.cols[field];
if(col.Count < minLineCount){
minLineCount = col.Count;
}
}
return minLineCount;
}
}
///
/// Clear the set.
///
public void Clear(){
this.cols.Clear();
}
///
/// Access to the i-th ResultColumn.
/// This method returns a complete column. For direct access
/// to a certain field of the column use
/// instead.
///
public SAPReader.ResultColumn this[string fieldName]{
get{return (ResultColumn)this.cols[fieldName];}
}//indexer
///
/// Returns an entry at the specified row of the column
/// determined by the given fieldname. Note that counting
/// rows starts at 0.
///
/// Fieldname of the column.
/// Number of the row starting at 0.
///
public string getEntryAt(string fieldName, int row){
if(this.cols.Contains(fieldName)){
ResultColumn col = (ResultColumn)this.cols[fieldName];
return col.getEntryAt(row);
}
return null;
}
}//ResultSet
}

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/232040/viewspace-969002/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/232040/viewspace-969002/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值