01: package org.incava.jagol;
02:
03: import java.io.*;
04: import java.util.*;
05:
06: /**
07: * Base class of all options.
08: */
09: public abstract class Option {
10: protected String longName;
11:
12: protected char shortName;
13:
14: private String description;
15:
16: public Option(String longName, String description) {
17: this .longName = longName;
18: this .description = description;
19: }
20:
21: public void setShortName(char shortName) {
22: this .shortName = shortName;
23: }
24:
25: public void setLongName(String longName) {
26: this .longName = longName;
27: }
28:
29: /**
30: * Returns the long option name.
31: */
32: public String getLongName() {
33: return longName;
34: }
35:
36: /**
37: * Returns the short option name.
38: */
39: public char getShortName() {
40: return shortName;
41: }
42:
43: /**
44: * Returns the description.
45: */
46: public String getDescription() {
47: return description;
48: }
49:
50: /**
51: * Sets from a list of command-line arguments. Returns whether this option
52: * could be set from the current head of the list.
53: */
54: public abstract boolean set(String arg, List args)
55: throws OptionException;
56:
57: /**
58: * Sets the value from the string, for this option type.
59: */
60: public abstract void setValue(String value)
61: throws InvalidTypeException;
62:
63: }
|