01: package org.objectweb.celtix.configuration;
02:
03: import java.util.ArrayList;
04: import java.util.Collection;
05:
06: public abstract class AbstractCommandLineConfiguration implements
07: CommandlineConfiguration {
08:
09: Collection<CommandLineOption> options;
10:
11: // Configuration interface
12:
13: // methods available to concrete implementations
14:
15: protected AbstractCommandLineConfiguration() {
16: options = new ArrayList<CommandLineOption>();
17: }
18:
19: /* (non-Javadoc)
20: * @see org.objectweb.celtix.configuration.Configuration#getObject(java.lang.String)
21: */
22: public Object getObject(String name) {
23: return getOption(name).getValue();
24: }
25:
26: /**
27: * Parses the arguments and initialises the options.
28: *
29: * @param args the command line arguments
30: * @param consume specifies whether the command line options and their
31: * arguments should be removed from the command line after processing.
32: */
33: protected void parseCommandLine(String[] args, boolean consume) {
34: }
35:
36: /**
37: * Adds an option to the command line configuration.
38: * Typically invoked in static initializers.
39: *
40: * @param option the <code>CommandLineOption</code> to add.
41: */
42: protected void addOption(CommandLineOption option) {
43: options.add(option);
44: }
45:
46: // private methods from here on
47:
48: /**
49: * Returns the <code>CommandLineOption</code> identified by the name or
50: * null of no such option exists.
51: *
52: * @param name identifies the option (shortcuts may be used)
53: */
54: private CommandLineOption getOption(String name) {
55: /*
56: for (CommandLineOption o : options) {
57: }
58: */
59: return null;
60: }
61:
62: }
|