Parses a set of command line arguments according to the given definitions. Can parse simple switches, numerical arguments, string arguments from a list of options and lists. Will generate help text automatically. @author Andrew Rambaut @version $Id$ $HeadURL$ $LastChangedBy$ $LastChangedDate$ $L
| 39 | * $LastChangedRevision$ |
| 40 | */ |
| 41 | public class Arguments { |
| 42 | |
| 43 | public static final String ARGUMENT_CHARACTER = "-"; |
| 44 | |
| 45 | public static class ArgumentException extends Exception { |
| 46 | public ArgumentException() { super(); } |
| 47 | public ArgumentException(String message) { super(message); } |
| 48 | }; |
| 49 | |
| 50 | public static class Option { |
| 51 | |
| 52 | public Option(String label, String description) { |
| 53 | this.label = label; |
| 54 | this.description = description; |
| 55 | } |
| 56 | |
| 57 | String label; |
| 58 | String description; |
| 59 | boolean isAvailable = false; |
| 60 | }; |
| 61 | |
| 62 | public static class StringOption extends Option { |
| 63 | |
| 64 | public StringOption(String label, String tag, String description) { |
| 65 | super(label, description); |
| 66 | this.tag = tag; |
| 67 | } |
| 68 | |
| 69 | public StringOption(String label, String[] options, boolean caseSensitive, String description) { |
| 70 | super(label, description); |
| 71 | this.options = options; |
| 72 | this.caseSensitive = caseSensitive; |
| 73 | } |
| 74 | String[] options = null; |
| 75 | String tag = null; |
| 76 | boolean caseSensitive = false; |
| 77 | |
| 78 | String value = null; |
| 79 | }; |
| 80 | |
| 81 | public static class IntegerOption extends Option { |
| 82 | |
| 83 | public IntegerOption(String label, String description) { |
| 84 | super(label, description); |
| 85 | } |
| 86 | |
| 87 | public IntegerOption(String label, int minValue, int maxValue, String description) { |
| 88 | super(label, description); |
| 89 | this.minValue = minValue; |
| 90 | this.maxValue = maxValue; |
| 91 | } |
| 92 | |
| 93 | int minValue = Integer.MIN_VALUE; |
| 94 | int maxValue = Integer.MAX_VALUE; |
| 95 | |
| 96 | int value = 0; |
| 97 | }; |
| 98 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…