Package com.javaeye.jert.domain.query

Source Code of com.javaeye.jert.domain.query.QueryBuilder

package com.javaeye.jert.domain.query;

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

import com.javaeye.jert.domain.query.impl.DynamicParameterQuery;
import com.javaeye.jert.domain.query.impl.SimpleParameterQuery;
import com.javaeye.jert.domain.query.impl.StaticQuery;

/**
* @author   Quake Wang
* @since    2004-12-26
* @version $Revision: 1.3 $
*/
public class QueryBuilder {
    public static final String QUERY_TYPE_STATIC = "STATIC_QUERY";
    public static final String QUERY_TYPE_SIMPLE_PARAMETER = "SIMPLE_PARAMETER_QUERY";
    public static final String QUERY_TYPE_DYNAMIC_PARAMETER = "DYNAMIC_PARAMETER_QUERY";
   
    public static final List QUERY_TYPES = new ArrayList();
   
    static {
        QUERY_TYPES.add(QUERY_TYPE_STATIC);
        QUERY_TYPES.add(QUERY_TYPE_SIMPLE_PARAMETER);
        QUERY_TYPES.add(QUERY_TYPE_DYNAMIC_PARAMETER);
    }
   
    public static Query getQuery(String sql, String queryType){
        if(QUERY_TYPE_STATIC.equals(queryType)){
            return new StaticQuery(sql);
        }else if(QUERY_TYPE_SIMPLE_PARAMETER.equals(queryType)){
            return new SimpleParameterQuery(sql);
        }else if(QUERY_TYPE_DYNAMIC_PARAMETER.equals(queryType)){
            return new DynamicParameterQuery(sql);
        }else{
            throw new IllegalArgumentException(queryType + " is not supported");
        }
    }
}
TOP

Related Classes of com.javaeye.jert.domain.query.QueryBuilder

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.