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: * A specification for an option that does not accept arguments.
10: *
11: * @since 1.0
12: * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
13: * @version $Id: NoArgumentOptionSpec.java,v 1.12 2007/04/10 20:06:25 pholser Exp $
14: */
15: class NoArgumentOptionSpec extends OptionSpec {
16: NoArgumentOptionSpec(String option) {
17: this (option, "");
18: }
19:
20: NoArgumentOptionSpec(String option, String description) {
21: super (option, description);
22: }
23:
24: void handleOption(OptionParser parser, ArgumentList arguments,
25: OptionSet detectedOptions, String detectedArgument) {
26:
27: detectedOptions.add(option());
28: }
29:
30: boolean acceptsArguments() {
31: return false;
32: }
33:
34: boolean requiresArgument() {
35: return false;
36: }
37:
38: /**
39: * {@inheritDoc}
40: */
41: public String toString() {
42: return super .toString() + ", accepts no arg";
43: }
44:
45: void accept(OptionSpecVisitor visitor) {
46: visitor.visit(this);
47: }
48: }
|