1 32 33 package com.jeantessier.commandline; 34 35 39 public class SingleValueSwitch extends CommandLineSwitchBase { 40 public SingleValueSwitch() { 41 this("", false); 42 } 43 44 public SingleValueSwitch(String defaultValue) { 45 this(defaultValue, false); 46 } 47 48 public SingleValueSwitch(boolean mandatory) { 49 this("", mandatory); 50 } 51 52 public SingleValueSwitch(String defaultValue, boolean mandatory) { 53 super(defaultValue, mandatory); 54 } 55 56 public int parse(String name, String value) throws CommandLineException { 57 if (value == null) { 58 throw new CommandLineException("Missing mandatory value for switch \"" + name + "\""); 59 } 60 61 setValue(value); 62 63 return 2; 64 } 65 66 public void accept(Visitor visitor) { 67 visitor.visitSingleValueSwitch(this); 68 } 69 } 70 | Popular Tags |