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