1 package junit.quilt.ui;
2
3 /***
4 * ResourceAction
5 *
6 * This is basically an Action which
7 * is initialized by a ResourceBundle.
8 */
9
10 import javax.swing.*;
11 import java.util.Enumeration;
12 import java.util.ResourceBundle;
13
14 public abstract class ResourceAction
15 extends AbstractAction
16 {
17 public ResourceAction(String resource) {
18 ResourceBundle bundle =
19 ResourceBundle.getBundle( resource );
20
21 Enumeration keys = bundle.getKeys();
22 while (keys.hasMoreElements()) {
23 String key = (String) keys.nextElement();
24
25 putValue( key, bundle.getObject( key ));
26 }
27 }
28
29 /***
30 * getArgs
31 *
32 * This returns an array of strings which
33 * represent args.1, args.2, ...
34 */
35 public String [] getArgs() {
36 String RC[] = null;
37
38 String countStr = (String) getValue( "args.count" );
39
40 try {
41 int count = Integer.parseInt( countStr );
42 RC = new String[count];
43
44 for (int i = 0; i < count; i++) {
45 RC[i] = (String) getValue( "args." + i );
46 }
47 } catch (Exception e) {
48 // no need to print a stacktrace since we're using exceptions for flow control here
49 }
50 return RC;
51 }
52 }
This page was automatically generated by Maven