All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.sylinx.hbatis.ext.parse.SqlTokenHandler Maven / Gradle / Ivy

There is a newer version: 2.0.0.RELEASE
Show newest version
package cn.sylinx.hbatis.ext.parse;

import java.util.Map;

import cn.sylinx.hbatis.kit.StrKit;
import ognl.Ognl;
import ognl.OgnlException;

/**
 * sql 占位符解析处理器
 * 
 * @author han
 *
 */
public class SqlTokenHandler implements TokenHandler {

	private Map params;

	public SqlTokenHandler(Map params) {
		this.params = params;
	}

	@Override
	public Object hand(String content) {

		return StrKit.isNotBlank(content) ? (params == null ? null : params.get(content)) : null;
	}

	@Override
	public boolean condition(String condition) {

		try {
			Object ret = Ognl.getValue(condition, params);
			if (ret instanceof Boolean) {
				return (Boolean) ret;
			}
		} catch (OgnlException e) {
			return false;
		}

		return false;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy