📄 bizcomponent.java
字号:
/*****************************************************************************
* (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 + -