home *** CD-ROM | disk | FTP | other *** search
- package jargs.gnu;
-
- import java.util.Locale;
-
- public abstract class CmdLineParser$Option {
- private String shortForm;
- private String longForm;
- private boolean wantsValue;
-
- protected CmdLineParser$Option(String longForm, boolean wantsValue) {
- this((String)null, longForm, wantsValue);
- }
-
- protected CmdLineParser$Option(char shortForm, String longForm, boolean wantsValue) {
- this(new String(new char[]{shortForm}), longForm, wantsValue);
- }
-
- private CmdLineParser$Option(String shortForm, String longForm, boolean wantsValue) {
- this.shortForm = null;
- this.longForm = null;
- this.wantsValue = false;
- if (longForm == null) {
- throw new IllegalArgumentException("Null longForm not allowed");
- } else {
- this.shortForm = shortForm;
- this.longForm = longForm;
- this.wantsValue = wantsValue;
- }
- }
-
- public String shortForm() {
- return this.shortForm;
- }
-
- public String longForm() {
- return this.longForm;
- }
-
- public boolean wantsValue() {
- return this.wantsValue;
- }
-
- public final Object getValue(String arg, Locale locale) throws CmdLineParser.IllegalOptionValueException {
- if (this.wantsValue) {
- if (arg == null) {
- throw new CmdLineParser.IllegalOptionValueException(this, "");
- } else {
- return this.parseValue(arg, locale);
- }
- } else {
- return Boolean.TRUE;
- }
- }
-
- protected Object parseValue(String arg, Locale locale) throws CmdLineParser.IllegalOptionValueException {
- return null;
- }
- }
-