PrintWriter out=response.getWriter();
String name=request.getParameter("name");
out.print(PageList.getFilter(name));
/**
* 得到过滤类型
* @param name 过滤选择名称(包括表名和字段名)
* @param isAdd 是否添加ClassID,BindField等信息
* @return
*/
public static String getFilterType(String name,boolean isAdd){
if(name!=null){
int index=name.indexOf("_");
if(index>=0){
String[] str=new String[2];
str[0]=name.substring(0,index);
str[1]=name.substring(index 1);
ResultSet rs=DBAccess.getInstance().OpenCommand(Common.Format(SQL,str));
try{
if(rs.next()){//时间
if(Common.in(TIME,rs.getString("FieldType"))){
return "1";
}else if(!isDBNull(rs.getString("ClassID"))){//固定代码
if(isAdd)
return "2_" rs.getString("ClassID");
else
return "2";
}else if(!isDBNull(rs.getString("BindTable"))){//外键关联
if(isAdd)
return "3_" rs.getString("BindTable")
"_" rs.getString("BindField")
"_" rs.getString("BindShowField");
else
return "3";
}else if(Common.in(NUM,rs.getString("FieldType"))){//数值
return "4";
}
}
}catch(Exception e){}
}
}
return "0";//普通字符串
}
/**
* 获取过滤字符串
* @param name 过滤类型名称
* @param value 第一个过滤值
* @param value1 第二个过滤值(主要针对时间)
* @return
*/
public static String getFilter(String name,String value,String value1){
String type=getFilterType(name,true);
int flag=0,pos=type.indexOf("_");
String[] other=type.split("_");
if(pos>=0){
flag=Integer.parseInt(type.substring(0,pos));
}else{
flag=Integer.parseInt(type);
}
return getFilter(flag,other,value,value1);
}
/**
* 获取过滤字符串
* @param type 过滤类型
* @param other 固定代码编号等
* @param value 第一个过滤值
* @param value1 第二个过滤值(主要针对时间)
* @return
*/
public static String getFilter(int type,String[] other,String value,String value1){
if(value==null) value="";
if(value1==null) value1="";
switch(type){
case 0:return DEFAULT.replaceAll("@value",value);//字符串
case 1:return ("从:" DATE.replaceAll("@name","FromDate").replaceAll("@value",value)
" 到:" DATE.replaceAll("@name","ToDate").replaceAll("@value",value1));//时间
case 2:if(other.length==2)
return Html.getInstance().GetList("Exec P_GetBaseCode '"
other[1] "'",true,true,"FilterValue","100%",value);//固定代码
case 3:if(other.length==4)
return Html.getInstance().GetList("select distinct " other[2] "," other[3]
" from " other[1],true,true,"FilterValue","100%",value);//外键关联
case 4:return DEFAULT.replaceAll("@value",value);//数值
}
return "";
}
/**
* 得到过滤字符串
* @param name 过滤名称
* @return
*/
public static String getFilter(String name){
return getFilter(name,"","");
}
/**
* 检查是否为空
* @param obj 要检查的对象
* @return
*/
public static boolean isNull(Object obj){
if(obj==null || obj.toString().equals(""))
return true;
else
return false;
}
/**
* 判断是否为空,包括空字段
* @param obj 要判断的对象
* @return
*/
public static boolean isDBNull(Object obj){
if(isNull(obj) || obj.toString().trim().toLowerCase().equals("null"))
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


