package latte;

import latte.lattice.LatteException;
import java.util.HashSet;

public class Latte {

	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * * * * * * * * * *           ERROR         * * * * * * * * * * * * * * * * * * * * * * * 
	 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
	public static void logError(String errorMessage) {
		System.err.println(errorMessage);
		Latte.exit(-1);
	}

	public static void logError(LatteException error) {
		error.printStackTrace();
		System.err.println(error.getMessage());
	}

	public static void exit() {
		exit(-1);
	}
	public static void exit(int status) {
		System.exit(status);
	}

	public static void logError(Exception error) {
		error.printStackTrace();
		System.err.println(error.getMessage());
	}

	public static void logError(Error error) {
		error.printStackTrace();
		System.err.println(error.getMessage());
	}

	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * * * * * * * * * *           PRINT         * * * * * * * * * * * * * * * * * * * * * * * 
	 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

	public final static boolean DEBUG_MODE=true;

	public static HashSet<Integer> passcodes = new HashSet<Integer>();
	static {
		passcodes.add(1); // ClusterBuilder.processArAndEnPhrases()
	}

	public static void println(String string, int passcode){
		print(string+"\n", passcode);
	}

	public static void print(String string, int passcode){
		if (passcodes.contains(passcode)) {
			print(string+"\n");
		}
	}

	public static void println(String string){
		print(string+"\n");
	}

	public static void print(String string){
		if (DEBUG_MODE) {
			System.out.print(string);
		}
	}

	
	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * * * * * * * * * *         DATE/TIME         * * * * * * * * * * * * * * * * * * * * * * 
	 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

	public static String currentMinuteDifference(long startedAt) {
		long now = System.currentTimeMillis();
		long diff = (now - startedAt) / 1000; // difference in seconds
		return (""+(diff / 60)+":"+(diff % 60));
	}
}
