/*
 * Created on 24/08/2003
 *
 */
package com.quantum.util;

import java.util.StringTokenizer;

/**
 * @author panic
 *
 */
public class QuantumUtil {
	/**
	 * Gets the first string in a string with the structure XXXX.XXXX
	 * @param qualifiedName
	 * @return The schema name if present, else an empty string ("")
	 */
	public static String getSchemaName(String qualifiedName) {
		StringTokenizer st = new StringTokenizer(qualifiedName, "."); //$NON-NLS-1$
		if (st.countTokens() > 1) {
			return st.nextToken();
		} else 
			return "";
	}

	/**
	 * Gets the second string in a string with the structure XXXX.XXXX
	 * @param qualifiedName
	 * @return The table name if present, else the received parameter
	 */
	public static String getTableName(String qualifiedName) {
		StringTokenizer st = new StringTokenizer(qualifiedName, "."); //$NON-NLS-1$
		if (st.countTokens() > 1) {
			st.nextToken();
			return st.nextToken();
		} else 
			return qualifiedName;
	}

	public static String trasposeEscape(String untrans){
		String trasposed = StringUtil.substituteString(untrans, "\\n", "\n");
		trasposed = StringUtil.substituteString(trasposed, "\\t", "\t");
		
		return trasposed;
	}
}