-
Notifications
You must be signed in to change notification settings - Fork 0
/
E.java
executable file
·86 lines (83 loc) · 2.59 KB
/
E.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**************************************************************************
* @author Mahdi Eslamimehr
* @version 0.1
***************************************************************************/
package ContractGen;
import java.util.HashMap;
public final class E {
private static String appName;
private static String m;
private static HashMap h;
private static int tabStop = 0;
public static void push() {
E.tabStop++;
}
public static void pop() {
if (E.tabStop==0) return;
E.tabStop--;
}
private static String currentTab() {
String ret = "";
for (int i=0;i<(E.tabStop-1);i++) ret += (i+".");
ret += (E.tabStop-1);
return ret+" ";
}
public static void info(String s) {
m = getMethod();
System.out.println(currentTab()+"Info ["+m+"] : "+s);
}
public static void warn(String s) {
m = getMethod();
System.out.println("Warning ["+m+"] : "+s);
}
public static void error(String s) {
m = getMethod();
System.out.println("Error ["+m+"] : "+s);
}
public static void debug(String s) {
m = getMethod();
System.out.println(currentTab()+"Debug ["+m+"] : "+s);
}
public static void crit(String s) {
m = getMethod();
System.out.println(currentTab()+"Critical Error ["+m+"] : "+s);
System.exit(-1);
}
public static void usage(String s) {
System.out.println(currentTab()+"Usage: "+s);
System.exit(1);
}
public static void FileNotFound(String s) {
System.out.println(currentTab()+"File <"+s+"> not found. Enter java "+appName+" for usage.");
System.exit(1);
}
public static String getMethod() {
Throwable t = new Throwable();
t.fillInStackTrace();
StackTraceElement e = t.getStackTrace()[2];
String s = e.getClassName()+"."+e.getMethodName();
return s;
}
public static void p(String s) {
System.out.print(s);
}
public static void pn(String s) {
System.out.println(currentTab()+s);
}
public static void name(String s) { appName = new String(s); }
public static boolean isOpt(String k, String v) {
if (!h.containsKey(k)) return false;
if (((String) h.get(k)).equals(v)) return true;
return false;
}
public static void setOptions(HashMap o) {
h = new HashMap(o);
}
public static void pt() {
System.out.print(currentTab());
}
public static Object getOpt(String s) {
if (!h.containsKey(s)) return null;
return h.get(s);
}
}