nc 系统 发送 XML

这是一个Java类,实现了CommDeal抽象类,提供了处理SCP系统中XML数据的相关方法,包括初始化系统参数、获取SCP中间库DAO对象、处理异常时的错误信息等。类中涉及到数据库连接、系统参数获取以及错误信息VO的创建。
摘要由CSDN通过智能技术生成
package nc.impl.scp.com;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.jdbc.framework.SQLParameter;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.pub.scp.com.IComConst;
import nc.pub.scp.com.IDataOperateConst;
import nc.pub.scp.com.IDataTypeConst;
import nc.pub.uapbd.FormulaTool;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.scp.basicdata.BasicDataOperate;
import nc.vo.scp.err.ErrVO;


/**
 * 下载服务实现类通用方法提供者
 * 
 * @author:Rain
 * @time:2015-3-28 下午11:14:50
 */
public abstract class DownLoadCommDeal extends CommDeal {


protected String OPERATE_SQL = "select * from scp_basicdata_operate where isnull(dr,0) = 0 and isnull(bsucceed,'N') = 'N' and data_type = ? order by operate_time asc";
protected nc.itf.scp.pub.IBasicDataOperate operateService = null;


public DownLoadCommDeal() throws BusinessException {
operateService = NCLocator.getInstance().lookup(
nc.itf.scp.pub.IBasicDataOperate.class);
}


private DataSend dataSendHandler = DataSend.getInstances();


protected abstract String getHeaderVOClass();


protected String getBodyVOClass() {
return null;
}


protected boolean bHaveBodyDom() {
return false; // 默认只处理表头List数据到XML
}


/**
* 将特殊符号转意成XML语言中字符

* @param strString
* @return
*/
public static String turnSpecialString(String strString) {
if (null == strString || "".equals(strString))
return strString;


return strString.replaceAll("<", "&lt;").replaceAll(">", "&gt;")
.replaceAll("&", "&amp;").replaceAll("'", "&apos;")
.replaceAll("\"", "&quot;");
}


/*
* 初始化表头fields
*/
protected String[] initHeadFields() throws BusinessException {
String headerClass = getHeaderVOClass();
if (null == headerClass)
throw new BusinessException("但没有设置表头VO类型!");


SuperVO obj = null;
try {
obj = (SuperVO) Class.forName(headerClass).newInstance(); // 利用反射实例化对象
} catch (Exception e) {
throw new BusinessException("实例化类" + headerClass + "的对象时失败,具体原因:"
+ e.getMessage());
}
return obj.getAttributeNames();
}


/*
* 初始化表体fields
*/
protected String[] initBodyFields() throws BusinessException {
if (!bHaveBodyDom())
return null;
String bodyClass = getBodyVOClass();


if (null == bodyClass)
throw new BusinessException("需要加载表体VO,但没有设置表体VO类型!");


SuperVO obj = null;
try {
obj = (SuperVO) Class.forName(bodyClass).newInstance();
} catch (Exception e) {
throw new BusinessException("实例化类" + bodyClass + "的对象时失败,具体原因:"
+ e.getMessage());
}
return obj.getAttributeNames();
}


@Override
public String sendDatas(SuperVO[] arrayVO) throws BusinessException {
return sendDataArray(arrayVO);
}

/**
* 将查询结果格式化成xml

* @param list
* @return
* @throws BusinessException
*/
protected String sendDataArray(SuperVO[] arrayVO) throws BusinessException {
if (null == arrayVO || 0 == arrayVO.length)
return null;


List<SuperVO> list = new ArrayList<SuperVO>();
list = Arrays.asList(arrayVO); // 数组转集合


return sendDataList(list);
}


protected String sendDataList(List<SuperVO> headVOList)
throws BusinessException {
return sendDataList(headVOList, IDataOperateConst.OPERATETYPE_A
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值