01: package discRack;
02:
03: import java.util.*;
04: import java.awt.*;
05:
06: /**
07: * Contains a few static methods.
08: *
09: * @author Sasa Bojanic
10: * @version 1.0
11: */
12: public class Utils {
13:
14: /**
15: * Take the given string and chop it up into a series
16: * of strings on given boundries. This is useful
17: * for trying to get an array of strings out of the
18: * resource file.
19: */
20: public static String[] tokenize(String input, String boundary) {
21: if (input == null)
22: input = "";
23: Vector v = new Vector();
24: StringTokenizer t = new StringTokenizer(input, boundary);
25: String cmd[];
26:
27: while (t.hasMoreTokens())
28: v.addElement(t.nextToken());
29: cmd = new String[v.size()];
30: for (int i = 0; i < cmd.length; i++)
31: cmd[i] = (String) v.elementAt(i);
32:
33: return cmd;
34: }
35:
36: /** Returns the class name without package. */
37: public static String getUnqualifiedClassName(Class cls) {
38: String name = cls.getName();
39: int lastDot = name.lastIndexOf(".");
40: if (lastDot >= 0) {
41: name = name.substring(lastDot + 1, name.length());
42: }
43: return name;
44: }
45:
46: }
|