AdmitBl

来源:互联网 发布:windows 7 usb 编辑:程序博客网 时间:2024/05/06 03:38

/*
 * Created on 2005/07/07.
 * Copyright by 北京五岳.
 * All right reserved.
 */
package admit.bl;

import admit.action.AdmitActionContext;

import java.util.ArrayList;
import java.util.Hashtable;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * <p>Title: AdmitBl.java</p>
 * <p>Description: bl的抽象类,用于处理业务逻辑</p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: 五岳</p>
 *
 * @author gongjian
 * @version 1.0
 */
public abstract class AdmitBl {

    /**
   * Action环境实例
   */
 protected AdmitActionContext blCtx = null;

 /**
  * log的实例,子类中使用
  */
 protected Log log = LogFactory.getLog(this.getClass());

 /**
  * 不带参数的构造器

  */
 public AdmitBl() {
  this.blCtx = null;
 }

 /**
  * 带参数的构造器

  *
  * @param blContext Action环境设置
  *              
  */
 public AdmitBl(AdmitActionContext blContext) {
  this.blCtx = blContext;
 }

 /**
  * 得到Action的环境实例
  *
  * @return AdmitActionContext
  */
 public AdmitActionContext getBlCtx() {
  return blCtx;
 }

 /**
  * 设置bl中的Action环境
  *
  * @param blCtx The blCtx to set.
  */
 public void setBlCtx(AdmitActionContext blCtx) {
  this.blCtx = blCtx;
 }

 /**
  * 在页面上设定表示条件
  *
  * @param name
  * @param value
  * @param list
  */
 public void setDisplayCond(String name, String value, ArrayList list) {
  if (value != null && !"".equals(value)) {
   Hashtable table = new Hashtable();
   table.put("condName", name);
   table.put("condValue", value);
   list.add(table);
  }
 }

 /**
  * 将得到的变量和key值放在HashTable中,然后加到传入的ArrayList中
  *
  * @param name key
  * @param value1 值1
  * @param value2 值2
  * @param list  要存放值的ArrayList
  */
 public void setDisplayCond(
  String name,
  String value1,
  String value2,
  ArrayList list) {

  String tempValue =
   nullToZeroString(value1)
    + "--"
    + nullToZeroString(value2);
  if (!"--".equals(tempValue)) {
   Hashtable table =  new Hashtable();
   table.put("condName", name);
   if (tempValue.endsWith("--")) {
    table.put("condValue", tempValue.substring(0, tempValue.length() - 2));
   } else if (tempValue.startsWith("--")) {
    table.put("condValue", tempValue.substring(2));
   } else {
    table.put("condValue", tempValue);
   }
   list.add(table);
  }
 }

 /**
  * trim字符串,如果是NULL则变成""
  *
  * @param str 要转换的字符串对象

  * @return String 转换成的字符对象

  */
 public String nullToZeroString(String str) {
  if (str == null)
   return "";
  return str.trim();
 }
}

原创粉丝点击