?? bizcomponent.java~1~
字號:
/*****************************************************************************
* (C) Copyright 2004 。
* 保留對所有使用、復制、修改和發布整個軟件和相關文檔的權利。
* 本計算機程序受著作權法和國際公約的保護,未經授權擅自復制或
* 傳播本程序的全部或部分,可能受到嚴厲的民事和刑事制裁,并
* 在法律允許的范圍內受到最大可能的起訴。
*/
/*****************************************************************************
* @作者:Golden Peng
* @版本: 1.0
* @時間: 2002-10-08
*/
/*****************************************************************************
* 修改記錄清單
* 修改人 :
* 修改記錄:
* 修改時間:
* 修改描述:
*
*/
package com.corp.bisc.ebiz.base;
import java.util.*;
import java.io.*;
import java.sql.*;
import com.corp.bisc.ebiz.exception.*;
import com.corp.bisc.ebiz.util.*;
/**
* Insert the type's description here.
* Creation date: (2002-5-13 12:54:57)
* @author: Administrator
*/
public class BizComponent extends ObjectBase implements Serializable {
private Vector values = new Vector();
private int position = 0;
private String name;
private String info;
//final static long serialVersionUID = -3620860894732882054L;
public BizComponent(String aName)
{
name = aName;
}
public void dump(PrintStream os)
{
dump(os, 0);
}
/**
* 將BizComponent中的數據打印出來
**/
public void dump(PrintStream os, int offset)
{
String offsetString = (new StringBuffer(offset)).toString();
os.println(offsetString + "Component:->" + name);
for(int i=0; i<values.size(); i++)
{
Hashtable aHash = (Hashtable)values.elementAt(i);
Enumeration keys = aHash.keys();
while(keys.hasMoreElements())
{
String key = (String)keys.nextElement();
if(aHash.get(key) instanceof BizComponent)
{
((BizComponent)aHash.get(key)).dump(os, offset + 12);
}
else
{
os.println(offsetString + key + ":->" + aHash.get(key));
}
}
}
}
/**
* 此處插入方法描述。
* 創建日期:(2002-5-24 16:58:02)
* @param resultSet java.sql.ResultSet
*/
public void fromResultSet(ResultSet rs) {
position = 0;
values = null;
values = new Vector();
try{
ResultSetMetaData rsmd = rs.getMetaData();
int columncount = rsmd.getColumnCount();
Vector colNameVector = new Vector();
for(int i=1;i<=columncount;i++){
colNameVector.add(rsmd.getColumnName(i));
}
while (rs.next()) {
this.newRecord();
for(int i=0;i<columncount;i++){
String colname = (String)colNameVector.elementAt(i);
Object value = rs.getObject(colname);
String val = "";
if(value != null){
val = SSEDataConverter.toString(value,2);
}
this.setFieldValue(colname,val);
}
}
rs.close();
}catch(Exception e){
System.out.println(e);
System.out.println("error when bizcomponent getting data from resultset");
}
finally{
}
}
/**
* 此處插入方法描述。
* 創建日期:(2002-5-24 16:58:02)
* @param resultSet java.sql.ResultSet
*/
public void fromResultSet(ResultSet rs,int length) {
position = 0;
values = null;
values = new Vector();
try{
ResultSetMetaData rsmd = rs.getMetaData();
int columncount = rsmd.getColumnCount();
Vector colNameVector = new Vector();
for(int i=1;i<=columncount;i++){
colNameVector.add(rsmd.getColumnName(i));
}
while (rs.next()) {
this.newRecord();
for(int i=0;i<columncount;i++){
String colname = (String)colNameVector.elementAt(i);
Object value = rs.getObject(colname);
String val = "";
if(value != null){
val = SSEDataConverter.toString(value,length);
}
this.setFieldValue(colname,val);
}
}
rs.close();
}catch(Exception e){
System.out.println(e);
System.out.println("error when bizcomponent getting data from resultset");
}
finally{
}
}
public BizComponent getBizComponent(String fieldName)
{
if(position > values.size())
throw new TraceException();
Object obj = ((Hashtable)values.elementAt(position)).get(fieldName);
if(obj instanceof BizComponent)
return (BizComponent)obj;
else
return null;
}
public Object getFieldValue(String fieldName)
{
if(position > values.size())
throw new TraceException();
if(values.size() == 0)
return null;
Object obj = ((Hashtable)values.elementAt(position)).get(fieldName);
if(obj instanceof BizComponent)
return null;
else
return obj;
}
public String getInfo()
{
return info;
}
public String getName()
{
return name;
}
public Vector getValues()
{
return values;
}
public int getValueSize()
{
if(values != null)
return values.size();
return 0;
}
public boolean moveFirst()
{
position = 0;
return (values.size() > 0);
}
public boolean moveLast()
{
position = values.size()-1;
return position>=0;
}
public boolean moveNext()
{
position ++;
if(position >= values.size())
position = values.size();
return values.size() > position;
}
public void newRecord()
{
Hashtable aHash = new Hashtable();
values.addElement(aHash);
position = getValueSize() -1;
}
public void setBizComp(String aName, BizComponent bizComp)
{
((Hashtable)(values.elementAt(position))).put(aName, bizComp);
}
public void setFieldValue(String fieldName, Object value)
{
if(value == null)
return;
((Hashtable)(values.elementAt(position))).put(fieldName, value);
}
public void setFieldValue(String fieldName, String value)
{
if(value == null)
value = "";
((Hashtable)(values.elementAt(position))).put(fieldName, value);
}
public void setInfo(String resinfo)
{
info = resinfo;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -