package com.style24.admin.support.util;

public class TsitUtil {
	public String replaceMultiSelectParams(String param) {
		String[] multiParams = param.replaceAll("\r", "").split("\n");
		StringBuilder multiParam = new StringBuilder();
		multiParam.append("(");
		for (int i = 0; i < multiParams.length; i++) {
			if (!multiParams[i].trim().equals("")) {
				if (i > 0) {
					multiParam.append("|");
				}
				multiParam.append(multiParams[i]);
			}
		}
		multiParam.append(")");

		return multiParam.toString();
	}

	public String replaceMultiSelectParamsArr(String param) {
		String[] multiParams = param.replaceAll("\r", "").split("\n");
		StringBuilder multiParam = new StringBuilder();
		for (int i = 0; i < multiParams.length; i++) {
			if (!multiParams[i].trim().equals("")) {
				if (i > 0) {
					if (i % 20 == 0) {
						multiParam.append(",");
					} else {
						multiParam.append("|");
					}
				}
				multiParam.append(multiParams[i]);
			}
		}

		return multiParam.toString();
	}

	public String replaceMultiSelectCommaParamsArr(String param) {
		String[] multiParams = param.replaceAll("\r", "").split(",");
		StringBuilder multiParam = new StringBuilder();
		for (int i = 0; i < multiParams.length; i++) {
			if (!multiParams[i].trim().equals("")) {
				if (i > 0) {
					if (i % 20 == 0) {
						multiParam.append(",");
					} else {
						multiParam.append("|");
					}
				}
				multiParam.append(multiParams[i]);
			}
		}

		return multiParam.toString();
	}
}
