/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.ibatis.sqlmap.client.event.RowHandler
 *  org.springframework.dao.DataAccessException
 *  org.springframework.orm.ibatis.SqlMapClientCallback
 *  org.springframework.orm.ibatis.SqlMapClientTemplate
 */
package com.hst.framework.common;

import com.hst.framework.common.HstSqlMapClientOperations;
import com.hst.framework.constants.WebConstants;
import com.hst.framework.orm.ibatis.spring.HstSqlMapClientFactoryBean;
import com.hst.framework.util.HstEncodeUtil;
import com.ibatis.sqlmap.client.event.RowHandler;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.SqlMapClientCallback;
import org.springframework.orm.ibatis.SqlMapClientTemplate;

public class HstSqlMapClientTemplate
extends SqlMapClientTemplate
implements HstSqlMapClientOperations {
    public void delete(String arg0, Object arg1, int arg2) throws DataAccessException {
        super.delete(arg0, arg1, arg2);
    }

    public int delete(String arg0, Object arg1) throws DataAccessException {
        return super.delete(arg0, arg1);
    }

    public int delete(String arg0) throws DataAccessException {
        return super.delete(arg0);
    }

    public <T> T execute(SqlMapClientCallback<T> arg0) throws DataAccessException {
        return (T)super.execute(arg0);
    }

    public Object insert(String arg0, Object arg1) throws DataAccessException {
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conUTF82ISO(arg1);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        if ("GBK".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conUTF2GBK(arg1);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return super.insert(arg0, arg1);
    }

    public Object insert(String arg0) throws DataAccessException {
        return this.insert(arg0, null);
    }

    public List queryForList(String arg0, int arg1, int arg2) throws DataAccessException {
        return this.queryForList(arg0, null, arg1, arg2);
    }

    public List queryForList(String arg0, Object arg1, int arg2, int arg3) throws DataAccessException {
        List dataList = super.queryForList(arg0, arg1, arg2, arg3);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conISO2GBK(dataList);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return dataList;
    }

    public List queryForList(String arg0, Object arg1) throws DataAccessException {
        List dataList = super.queryForList(arg0, arg1);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conISO2GBK(dataList);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return dataList;
    }

    public List queryForList(String arg0) throws DataAccessException {
        return this.queryForList(arg0, null);
    }

    public Map queryForMap(String arg0, Object arg1, String arg2, String arg3) throws DataAccessException {
        Map result = super.queryForMap(arg0, arg1, arg2, arg3);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conMapISO2GBK(result);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    public Map queryForMap(String arg0, Object arg1, String arg2) throws DataAccessException {
        Map result = super.queryForMap(arg0, arg1, arg2);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conMapISO2GBK(result);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    public Object queryForObject(String arg0, Object arg1, Object arg2) throws DataAccessException {
        Object result = super.queryForObject(arg0, arg1, arg2);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conISO2GBK(result);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    public Object queryForObject(String arg0, Object arg1) throws DataAccessException {
        Object result = super.queryForObject(arg0, arg1);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conISO2GBK(result);
                HstSqlMapClientFactoryBean fac = new HstSqlMapClientFactoryBean();
                fac.getSqlExecutor();
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    public Object queryForObject(String arg0) throws DataAccessException {
        return this.queryForObject(arg0, null);
    }

    @Override
    public Object queryForObjectByCurr(String arg0, String currName, Object arg1) throws DataAccessException {
        Object result = super.queryForObject(arg0, arg1);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conISO2GBK(result);
                Map map = (Map)arg1;
                if (!map.containsKey(currName)) {
                    return result;
                }
                HstEncodeUtil.conISO2GBK((List)map.get(currName));
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    public Object queryForObjectByCurr(String arg0, Object arg1, String ... currNames) throws DataAccessException {
        Object result = super.queryForObject(arg0, arg1);
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conISO2GBK(result);
                Map map = (Map)arg1;
                String[] stringArray = currNames;
                int n = currNames.length;
                int n2 = 0;
                while (n2 < n) {
                    String currName = stringArray[n2];
                    if (map.containsKey(currName)) {
                        HstEncodeUtil.conISO2GBK((List)map.get(currName));
                    }
                    ++n2;
                }
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }

    public void queryWithRowHandler(String arg0, Object arg1, RowHandler arg2) throws DataAccessException {
        super.queryWithRowHandler(arg0, arg1, arg2);
    }

    public void queryWithRowHandler(String arg0, RowHandler arg1) throws DataAccessException {
        super.queryWithRowHandler(arg0, arg1);
    }

    public void update(String arg0, Object arg1, int arg2) throws DataAccessException {
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conUTF82ISO(arg1);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        if ("GBK".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conUTF2GBK(arg1);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        super.update(arg0, arg1, arg2);
    }

    public int update(String arg0, Object arg1) throws DataAccessException {
        if ("ISO".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conUTF82ISO(arg1);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        if ("GBK".equalsIgnoreCase(WebConstants.DATABASE_ENCODE)) {
            try {
                HstEncodeUtil.conUTF2GBK(arg1);
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return super.update(arg0, arg1);
    }

    public int update(String arg0) throws DataAccessException {
        return this.update(arg0, null);
    }
}
