package Globals;

import java.lang.*;
import java.util.StringTokenizer;
//import java.text.DecimalFormat;


/** Collection of static methods and fields.
    Be aware, con() methods can be slow.
*/

public class GS {


static public void c(String s) {
        String s1 = "      " + System.currentTimeMillis();
        int wLen = s1.length();
        s1 = s1.substring( wLen - 7, wLen-1 );
        String s2 =Thread.currentThread().getName() + "            ";
        s2 = s1 + " " + s2.substring ( 0, 12 ) + " " + s;
        //logToMain(s2);
        System.out.println(s2);
}

//con is depricated: name is too long:
static public void con(String s) {
        String s1 = "      " + System.currentTimeMillis();
        int wLen = s1.length();
        s1 = s1.substring( wLen - 7, wLen-1 );
        String s2 =Thread.currentThread().getName() + "            ";
        s2 = s1 + " " + s2.substring ( 0, 12 ) + " " + s;
        //logToMain(s2);
        System.out.println(s2);
}


/** Wrapper to system console 
    The same as con but input is string's array 
*/
static public void con(String[] s) {
       con(s, s.length);
}

/** Wrapper to system console 
    The same as con but input is string's array and
    resticted by lastIndexToPrint.
*/
static public void con(String[] s, int lastIndexToPrint) {
    for(int i=0; i<s.length; i++) {  
        if(i > lastIndexToPrint) return;   
        String s1 = "      " + System.currentTimeMillis();
        int wLen = s1.length();
        s1 = s1.substring( wLen - 7, wLen-1 );
        String s2 =Thread.currentThread().getName() + "            ";
        s2 = s1 + " " + s2.substring ( 0, 12 ) + " " + s[i];
        //logToMain(s2);
        System.out.println(s2);
    }
}


/** Console multistring.
    String s can have \n inside. It will be tokenized by \n and printed
    line by line.
*/
static public void com(String s) {
     
    //Will be code faster if to declare st at class level:
    //StringTokenizer st;
    //?
    StringTokenizer st = new StringTokenizer(s,"\n");

    while(st.hasMoreTokens()) {
        String s0 = st.nextToken();
        String s1 = "      " + System.currentTimeMillis();
        int wLen = s1.length();
        s1 = s1.substring( wLen - 7, wLen-1 );
        String s2 =Thread.currentThread().getName() + "            ";
        s2 = s2.substring ( 0, 12 );
        s2 = s1 + " " + s2 + " " + s0; 
        System.out.println(s2);
   }
}


//"Console string beginning". No LF printed at the end.
static public void b(String s) {
        String s1 = "      " + System.currentTimeMillis();
        int wLen = s1.length();
        s1 = s1.substring( wLen - 7, wLen-1 );
        String s2 =Thread.currentThread().getName() + "            ";
        s2 = s1 + " " + s2.substring ( 0, 12 ) + " " + s;
        //logToMain(s2);
        System.out.print(s2);
}

//"Console line end". Print string and add LF.
static public void e(String s) {
       System.out.println(s); 
}

//"Console line middle". Print string and add LF.
static public void m(String s) {
       System.out.print(s); 
}


} //Applet End