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

com.mycomm.dao.dao4comm.util.Utils Maven / Gradle / Ivy

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycomm.dao.dao4comm.util;

import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author jw362j
 */
public class Utils {

    private static final Logger log = LoggerFactory.getLogger(Utils.class);

    public static String buildProjection(String[] ts) {
        if (ts == null || ts.length == 0) {
            return "";
        }
        String result = "";
        for (String s : ts) {
            result = result + " " + s + " ,";
        }
        result = result.substring(0, result.length() - 1);
        log.info("the buildProjection:" + result);
        return result;
    }

    public static String buildProjectionWithTableName(String tableName, String[] ts) {
        if (ts == null || ts.length == 0) {
            return "";
        }
        String result = "";
        for (String s : ts) {
            result = result + " " + tableName + "." + s + " ,";
        }
        result = result.substring(0, result.length() - 1);
        log.info("the buildProjection:" + result);
        return result;
    }

    public static String buildOrderby(Map orderby) {
        StringBuilder orderbyql = new StringBuilder("");
        if (orderby != null && orderby.size() > 0) {
            orderbyql.append(" ORDER BY ");
            for (String key : orderby.keySet()) {
                orderbyql.append(key).append(" ").append(orderby.get(key)).append(",");
            }
            orderbyql.deleteCharAt(orderbyql.length() - 1);
        }
        return orderbyql.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy