01: /**
02: * (c) 2006 forcare BV
03: * All rights reserved.
04: */package org.kohsuke.args4j;
05:
06: import org.kohsuke.args4j.spi.OptionHandler;
07:
08: /**
09: * Run-time copy of the Option or Argument annotation. By definition, unnamed options
10: * are arguments (and instances of this class). Named options are actually a subclass.
11: *
12: * @author Mark Sinke
13: */
14: public class OptionDef {
15: private final String usage;
16: private final String metaVar;
17: private final boolean required;
18: private final boolean multiValued;
19: private final Class<? extends OptionHandler> handler;
20:
21: public OptionDef(Argument a, boolean forceMultiValued) {
22: this (a.usage(), a.metaVar(), a.required(), a.handler(), a
23: .multiValued()
24: || forceMultiValued);
25: }
26:
27: protected OptionDef(String usage, String metaVar, boolean required,
28: Class<? extends OptionHandler> handler, boolean multiValued) {
29: this .usage = usage;
30: this .metaVar = metaVar;
31: this .required = required;
32: this .handler = handler;
33: this .multiValued = multiValued;
34: }
35:
36: public String usage() {
37: return usage;
38: }
39:
40: public String metaVar() {
41: return metaVar;
42: }
43:
44: public boolean required() {
45: return required;
46: }
47:
48: public Class<? extends OptionHandler> handler() {
49: return handler;
50: }
51:
52: public boolean isMultiValued() {
53: return multiValued;
54: }
55:
56: public boolean isArgument() {
57: return true;
58: }
59:
60: @Override
61: public String toString() {
62: return metaVar() != null ? metaVar() : "ARG";
63: }
64: }
|