01: /*
02: Copyright 2004-2007 Paul R. Holser, Jr. All rights reserved.
03: Licensed under the Academic Free License version 3.0
04: */
05:
06: package joptsimple;
07:
08: /**
09: * Specification of an option that accepts a required argument.
10: *
11: * @since 1.0
12: * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
13: * @version $Id: RequiredArgumentOptionSpec.java,v 1.13 2007/04/10 20:06:25 pholser Exp $
14: */
15: class RequiredArgumentOptionSpec extends ArgumentAcceptingOptionSpec {
16: RequiredArgumentOptionSpec(String option) {
17: super (option, true);
18: }
19:
20: RequiredArgumentOptionSpec(String option, String description) {
21: super (option, true, description);
22: }
23:
24: protected void handleOptionFurther(OptionParser parser,
25: ArgumentList arguments, OptionSet detectedOptions) {
26:
27: if (!arguments.hasMore())
28: throw new OptionMissingRequiredArgumentException(option());
29:
30: detectedOptions.addWithArgument(option(), convert(arguments
31: .next()));
32: }
33:
34: void accept(OptionSpecVisitor visitor) {
35: visitor.visit(this);
36: }
37: }
|