Blame view

tools/mate-tools/src/is2/util/DB.java 1.75 KB
Jan Lupa authored
1
package is2.util; 
Jan Lupa authored
2
3
4
5

import java.util.Calendar;
import java.util.GregorianCalendar;
Jan Lupa authored
6
Jan Lupa authored
7
8
public class DB {
Jan Lupa authored
9
10
11
12

	private static final String ARROW     = " -> ";
	private static final String LEER = "                            " ;
	private static final String BIG = "                                                                                    " ;
Jan Lupa authored
13
14
15

	private static boolean debug = true;
Jan Lupa authored
16
	final static public void println (Object err) {
Jan Lupa authored
17
Jan Lupa authored
18
		if (!debug) return;
Jan Lupa authored
19
20
21
22

		StackTraceElement[] ste = new Exception().getStackTrace();

		StringBuffer msg = new StringBuffer();
Jan Lupa authored
23
		msg.append((getDate().append(LEER).substring(0,10)));
Jan Lupa authored
24
		msg.append(' ');
Jan Lupa authored
25
	 	msg.append(ste[1].getClassName()+" "+ste[1].getLineNumber());
Jan Lupa authored
26
27
28
29
		msg.append(':');
		msg.append(ste[1].getMethodName());
		msg.append(ARROW);
Jan Lupa authored
30
31
		int l = 55-msg.length();
		if (l < 0) l =0;
Jan Lupa authored
32
33
		msg.append(BIG.substring(0, l));
Jan Lupa authored
34
35
36
37

//		if ((m_depth >= 0) && (m_depth < (BIG.length()) )) {
//		vDebugMessage.append(BIG.substring(0, m_depth*2));
//		}
Jan Lupa authored
38
39
40
41
42
43

		msg.append(err);

		System.err.println(msg);
Jan Lupa authored
44
45
46
	}

	final static public void prints (Object err) {
Jan Lupa authored
47
Jan Lupa authored
48
		if (!debug) return;
Jan Lupa authored
49
50
51
52
		System.err.println(err);

	}
Jan Lupa authored
53
Jan Lupa authored
54
	final private static StringBuffer getDate() {
Jan Lupa authored
55
//		if (Preferences.s_debug <= BDebug.FAIL) return s_sb;
Jan Lupa authored
56
Jan Lupa authored
57
		GregorianCalendar s_cal =  new GregorianCalendar();   
Jan Lupa authored
58
		StringBuffer sb = new StringBuffer();
Jan Lupa authored
59
60
//		sb.append(s_cal.get(Calendar.HOUR_OF_DAY));
//		sb.append('_');
Jan Lupa authored
61
62
63
64
65
66
67
68
69
70
		sb.append(s_cal.get(Calendar.MINUTE));
		sb.append('.');
		sb.append(s_cal.get(Calendar.SECOND));
		sb.append('.');
		sb.append(s_cal.get(Calendar.MILLISECOND));

		return sb;
	}

	public static void setDebug(boolean b) {
Jan Lupa authored
71
72
		debug=b;
Jan Lupa authored
73
74
75
	}

	public static boolean getDebug() {
Jan Lupa authored
76
Jan Lupa authored
77
78
79
		return debug;
	}
Jan Lupa authored
80
Jan Lupa authored
81
}