home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / plugins / researchdriver / res / process.jar / jargs / gnu / CmdLineParser$Option.class (.txt) < prev    next >
Encoding:
Java Class File  |  2005-04-09  |  2.2 KB  |  59 lines

  1. package jargs.gnu;
  2.  
  3. import java.util.Locale;
  4.  
  5. public abstract class CmdLineParser$Option {
  6.    private String shortForm;
  7.    private String longForm;
  8.    private boolean wantsValue;
  9.  
  10.    protected CmdLineParser$Option(String longForm, boolean wantsValue) {
  11.       this((String)null, longForm, wantsValue);
  12.    }
  13.  
  14.    protected CmdLineParser$Option(char shortForm, String longForm, boolean wantsValue) {
  15.       this(new String(new char[]{shortForm}), longForm, wantsValue);
  16.    }
  17.  
  18.    private CmdLineParser$Option(String shortForm, String longForm, boolean wantsValue) {
  19.       this.shortForm = null;
  20.       this.longForm = null;
  21.       this.wantsValue = false;
  22.       if (longForm == null) {
  23.          throw new IllegalArgumentException("Null longForm not allowed");
  24.       } else {
  25.          this.shortForm = shortForm;
  26.          this.longForm = longForm;
  27.          this.wantsValue = wantsValue;
  28.       }
  29.    }
  30.  
  31.    public String shortForm() {
  32.       return this.shortForm;
  33.    }
  34.  
  35.    public String longForm() {
  36.       return this.longForm;
  37.    }
  38.  
  39.    public boolean wantsValue() {
  40.       return this.wantsValue;
  41.    }
  42.  
  43.    public final Object getValue(String arg, Locale locale) throws CmdLineParser.IllegalOptionValueException {
  44.       if (this.wantsValue) {
  45.          if (arg == null) {
  46.             throw new CmdLineParser.IllegalOptionValueException(this, "");
  47.          } else {
  48.             return this.parseValue(arg, locale);
  49.          }
  50.       } else {
  51.          return Boolean.TRUE;
  52.       }
  53.    }
  54.  
  55.    protected Object parseValue(String arg, Locale locale) throws CmdLineParser.IllegalOptionValueException {
  56.       return null;
  57.    }
  58. }
  59.