| java.lang.Object joptsimple.OptionSpec joptsimple.ArgumentAcceptingOptionSpec
All known Subclasses: joptsimple.OptionalArgumentOptionSpec, joptsimple.AlternativeLongOptionSpec, joptsimple.RequiredArgumentOptionSpec,
ArgumentAcceptingOptionSpec | abstract public class ArgumentAcceptingOptionSpec extends OptionSpec (Code) | | Specification of an option that accepts an argument.
Instances are returned from
OptionSpecBuilder methods to allow the formation
of parser directives as sentences in a domain-specific language. For example:
OptionParser parser = new OptionParser();
parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );
If no methods are invoked on an instance of this class, then that instance's option
will treat its argument as a
String .
since: 1.0 author: Paul Holser version: $Id: ArgumentAcceptingOptionSpec.java,v 1.31 2007/04/10 20:06:25 pholser Exp $ |
ArgumentAcceptingOptionSpec | protected ArgumentAcceptingOptionSpec(String option, boolean argumentRequired)(Code) | | |
ArgumentAcceptingOptionSpec | protected ArgumentAcceptingOptionSpec(String option, boolean argumentRequired, String description)(Code) | | |
acceptsArguments | boolean acceptsArguments()(Code) | | |
canConvertArgument | protected boolean canConvertArgument(String argument)(Code) | | Tells whether the given argument can be successfully converted to the type
specified in this spec, if one was given.
Parameters: argument - the argument to convert true if conversion would be successful |
convert | final protected Object convert(String argument)(Code) | | Converts the given argument to the type specified in this spec, if one was given.
Parameters: argument - the argument to convert the converted argument, or itself if no conversion was specified |
describedAs | final public ArgumentAcceptingOptionSpec describedAs(String description)(Code) | | Specifies a description for the argument of the option that this spec represents.
This description is used when generating help information about the parser.
Parameters: description - describes the nature of the argument of this spec'soption self, so that the caller can add clauses to the domain-specific sentence |
handleOptionFurther | abstract protected void handleOptionFurther(OptionParser parser, ArgumentList arguments, OptionSet detectedOptions)(Code) | | Provides additional handling of this option when detected.
TODO: need a better name here.
Parameters: parser - an option parser Parameters: arguments - an argument list Parameters: detectedOptions - set of options detected in the argument list so far |
hashCode | public int hashCode()(Code) | | |
isArgumentOfNumberType | protected boolean isArgumentOfNumberType()(Code) | | Tells whether this option spec converts its arguments to a number type.
whether this option spec converts its arguments to a number type |
ofType | public void ofType(Class argumentType)(Code) | | Specifies a type to which arguments of this spec's option are to be converted.
JOpt Simple accepts types that have either:
- a public static method called
valueOf which accepts a single
argument of type
String and whose return type is the same as the class
on which the method is declared. The java.lang primitive wrapper
classes have such methods.
- a constructor which accepts a single argument of type
String .
This class converts arguments using those methods in that order; that is,
valueOf would be invoked before a one-
String -arg constructor
would.
Parameters: argumentType - desired type of arguments to this spec's option throws: NullPointerException - if the type is null throws: IllegalArgumentException - if the type does not have the standard conversionmethods |
requiresArgument | boolean requiresArgument()(Code) | | |
|
|