forked from joeytwiddle/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualJavaStatics.java
More file actions
70 lines (62 loc) · 1.75 KB
/
VisualJavaStatics.java
File metadata and controls
70 lines (62 loc) · 1.75 KB
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
package visualjava;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.jar.JarInputStream;
/** joey Nov 2, 2004 3:15:05 PM */
public class VisualJavaStatics {
public static String listParams(Class[] parameterTypes) {
String s = "";
for (int i=0;i<parameterTypes.length;i++) {
s += getSimpleClassName(parameterTypes[i]);
if (i < parameterTypes.length - 1) {
s += ", ";
}
}
return s;
}
public static String getSimpleClassName(Class c) {
if (c.isArray()) {
return getSimpleClassName(c.getComponentType()) + "[]";
} else {
String full = c.getName();
int i = full.lastIndexOf('.');
if (i>=0) {
full = full.substring(i+1);
}
return full;
}
}
public static String niceString(Object o) {
final int maxLength = 50;
String s = ""+o;
if (s.length() > maxLength) {
return '"' + s.substring(0,maxLength - 3) + '"' + "...";
} else {
return '"' + s + '"';
}
}
/*
public static String getShortClassName(Object _obj) {
return JavaStackUtils.getShortClassName(_obj);
}
*/
public static String getShortClassName(Object obj) {
if (obj == null)
return null;
try {
Class theClass = obj.getClass();
String name = theClass.getName();
int i = name.lastIndexOf(".");
if (i>=0) {
name = name.substring(i+1);
}
return name;
} catch (Exception e3) { }
return ""+obj;
}
}