|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hyphenType.optionsextractor.OptionsExtractor<T>
T
- The options interface type.public class OptionsExtractor<T extends Options<?>>
A factory for option objects, and the easiest way to get started with this
tool. This class provides the easiest (although not the most flexible, nor
the most automated) way to obtain an instance of an option object
programmatically. For a non-programmatical and automated method to obtain an
option object (i.e. if you do not want to call any API), please utilize the
StandAloneAppWrapper
class instead.
Here is (possibly the simplest and least invasive) example on how to use this
class:
In the source code above, the OptionsExtractor constructor will
perform a deep analysis on the options interface
public static void main(String[] arguments) {
OptionsExtractor
MyOptionInterface
All arguments received by the
main
method will be parsed according to the rules declared in
the options interface MyOptionInterface
.
Constructor Summary | |
---|---|
OptionsExtractor(Class<T> optionInterfaceClass)
Creates an OptionsExtractor object based on an options interface
class. |
Method Summary | |
---|---|
protected InvocationHandler |
buildInvocationHandler(OptionValues<T> values,
Class<? extends Options<?>> optionsInterface,
Class<? extends StatusCode> exitCodeEnumClass,
String[] rawArguments)
Prepared to be replaced by a subclass. |
T |
options(String... arguments)
|
T |
options(UserInput userInput,
String... arguments)
Factory method that creates an instance of the options interface specified in the constructor OptionsExtractor(Class) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OptionsExtractor(Class<T> optionInterfaceClass) throws InvalidOptionsInterfaceException
OptionsExtractor
object based on an options interface
class. Exceptions thrown by this constructor means that there is a
problem with the structure of the options interface. If you are sure your
options interface does not have any inconsistency (which can be tested
simply by calling this method before wrapping your application), you do
not have any reason to expect any exception being thrown from this
method.OptionsExtractor(Class)
constructor
instead.
optionInterfaceClass
- userInput
- The user input to utilize.
InvalidOptionsInterfaceException
InvalidOptionException
Method Detail |
---|
public T options(String... arguments) throws StringParsingErrorException, MandatoryValueNotFoundException, RegexMismatchException, StringParseException, MandatoryMapValueNotFoundException, MandatorySimpleArgumentNotFoundException, OptionsExtractorException
StringParsingErrorException
MandatoryValueNotFoundException
RegexMismatchException
StringParseException
MandatoryMapValueNotFoundException
MandatorySimpleArgumentNotFoundException
OptionsExtractorException
public T options(UserInput userInput, String... arguments) throws OptionsExtractorException, StringParsingErrorException, MandatoryValueNotFoundException, RegexMismatchException, StringParseException, MandatoryMapValueNotFoundException, MandatorySimpleArgumentNotFoundException
OptionsExtractor(Class)
.
userInput
- The input from the user.arguments
- The arguments to be parsed.
OptionsExtractorException
MandatorySimpleArgumentNotFoundException
MandatoryMapValueNotFoundException
StringParseException
RegexMismatchException
MandatoryValueNotFoundException
StringParsingErrorException
InvalidOptionException
protected InvocationHandler buildInvocationHandler(OptionValues<T> values, Class<? extends Options<?>> optionsInterface, Class<? extends StatusCode> exitCodeEnumClass, String[] rawArguments)
OptionsExtractor
is useful to replace the composition of objects that will process the
arguments.
values
- formatter
- exitCodeEnumClass
- rawArguments
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |