package com.eactive.eai.rms.common.util;

import java.util.StringTokenizer;

public class CamelCaseUtil {

	public static String converCamelCase(String strdata) {
		StringBuffer strbufCamelCase = new StringBuffer();
		StringTokenizer st = new StringTokenizer(strdata);
		if (null == strdata || strdata.length() == 0) {
			return "";
		}
		while (st.hasMoreTokens()) {
			String strWord = st.nextToken();
			strbufCamelCase.append(strWord.substring(0, 1).toUpperCase());
			if (strWord.length() > 1) {
				strbufCamelCase.append(strWord.substring(1).toLowerCase());
			}
			strbufCamelCase.append("");
		}
		return strbufCamelCase.toString();
	}
	public static String converCamelCase(String strdata, String token) {
		StringBuffer strbufCamelCase = new StringBuffer();
		StringTokenizer st = new StringTokenizer(strdata);
		if (null == strdata || strdata.length() == 0) {
			return "";
		}
		while (st.hasMoreTokens()) {
			String strWord = st.nextToken(token);
			strbufCamelCase.append(strWord.substring(0, 1).toUpperCase());
			if (strWord.length() > 1) {
				strbufCamelCase.append(strWord.substring(1).toLowerCase());
			}
			strbufCamelCase.append("");
		}
		return strbufCamelCase.toString();
	}
	public static String converCamelCaseWithoutFirst(String strdata, String token) {
		StringBuffer strbufCamelCase = new StringBuffer();
		StringTokenizer st = new StringTokenizer(strdata);
		if (null == strdata || strdata.length() == 0) {
			return "";
		}
		while (st.hasMoreTokens()) {
			String strWord = st.nextToken(token);
			strbufCamelCase.append(strWord.substring(0, 1).toUpperCase());
			if (strWord.length() > 1) {
				strbufCamelCase.append(strWord.substring(1).toLowerCase());
			}
			strbufCamelCase.append("");
		}
		String a = strbufCamelCase.substring(0, 1).toLowerCase();
		strbufCamelCase.replace(0, 1, a);
		return strbufCamelCase.toString();
	}
	public static String converCamelCaseWithBrace(String strdata, String token) {
		strdata = strdata.replaceAll("\\{", token);
		strdata = strdata.replaceAll("\\}", "");
		
		StringBuffer strbufCamelCase = new StringBuffer();
		StringTokenizer st = new StringTokenizer(strdata);
		if (null == strdata || strdata.length() == 0) {
			return "";
		}
		while (st.hasMoreTokens()) {
			String strWord = st.nextToken(token);
			strbufCamelCase.append(strWord.substring(0, 1).toUpperCase());
			if (strWord.length() > 1) {
				strbufCamelCase.append(strWord.substring(1).toLowerCase());
			}
			strbufCamelCase.append("");
		}
		return strbufCamelCase.toString();
	}

}
