01: package com.sun.portal.app.blog;
02:
03: import java.util.Map;
04: import java.util.HashMap;
05:
06: public class CommandLineOptions {
07: Map options = null;
08:
09: public CommandLineOptions(String[] args) {
10:
11: options = new HashMap();
12: parseArgs(args);
13: }
14:
15: private void parseArgs(String[] args) {
16: int i = 0;
17: while (i < args.length) {
18: if (args[i].startsWith("-")) {
19: options.put(args[i++].substring(1), null);
20: } else {
21: options.put(args[i - 1].substring(1), args[i++]);
22: }
23: }
24: }
25:
26: public String get(String key) {
27: return (String) options.get(key);
28: }
29:
30: public boolean exists(String key) {
31: return options.containsKey(key);
32: }
33:
34: public String toString() {
35: return options.toString();
36: }
37: }
|