public class ParameterMapMapper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,org.apache.commons.cli.Option> |
liveOptions |
protected org.apache.commons.cli.Options |
options |
protected Set |
requiredOptions |
protected String[] |
singleString |
| Constructor and Description |
|---|
ParameterMapMapper(org.apache.commons.cli.Options options)
At current, any combination of an instance of this class and/or its Options instance
are only valid for one mapping execution (not reusable, and certainly not thread-safe).
|
| Modifier and Type | Method and Description |
|---|---|
Map<String,org.apache.commons.cli.Option> |
getLiveOptions()
Returns the same collection of mapped options as
getResults(), but without executing any validations
- and by returning the underlying map, allows specific options to be quickly referenced by their key
(Option.getOpt() or Option.getLongOpt()). |
org.apache.commons.cli.Options |
getOriginalOptions() |
Set |
getRequiredOptions() |
Collection<org.apache.commons.cli.Option> |
getResults()
Performs any final work required after one or more
mapArgument* calls,
while performing any validations. |
boolean |
mapArgument(String key,
String inValue,
boolean validateMatch) |
boolean |
mapArguments(Map<String,String[]> parameters,
boolean validateMatch)
This method is designed to be called with the result of a
(Http)ServletRequest.getParameterMap(). |
boolean |
mapArguments(String key,
String[] inValues,
boolean validateMatch) |
boolean |
mapArgumentsSingleValue(Map<String,String> parameters,
boolean validateMatch) |
protected final org.apache.commons.cli.Options options
protected final Set requiredOptions
protected final String[] singleString
public ParameterMapMapper(org.apache.commons.cli.Options options)
At current, any combination of an instance of this class and/or its Options instance
are only valid for one mapping execution (not reusable, and certainly not thread-safe).
A new (or somehow properly cloned) Options instance should be used here.
(https://issues.apache.org/jira/browse/CLI-183 was a particular concern here with
Apache CLI 1.2 - which was fixed in 1.3, but is still not thread-safe.)
public org.apache.commons.cli.Options getOriginalOptions()
public boolean mapArgumentsSingleValue(Map<String,String> parameters, boolean validateMatch) throws org.apache.commons.cli.ParseException
org.apache.commons.cli.ParseExceptionpublic boolean mapArgument(String key, String inValue, boolean validateMatch) throws org.apache.commons.cli.ParseException
org.apache.commons.cli.ParseExceptionpublic boolean mapArguments(Map<String,String[]> parameters, boolean validateMatch) throws org.apache.commons.cli.ParseException
(Http)ServletRequest.getParameterMap().org.apache.commons.cli.ParseExceptionpublic boolean mapArguments(String key, String[] inValues, boolean validateMatch) throws org.apache.commons.cli.ParseException
true is the argument was successfully mapped, false if otherwise.org.apache.commons.cli.ParseExceptionpublic Collection<org.apache.commons.cli.Option> getResults() throws org.apache.commons.cli.ParseException
Performs any final work required after one or more mapArgument* calls,
while performing any validations.
The returned value of this method is designed to be passed into
ClassOptions.autoMap(Object, ClassOptionsData, Iterable, com.ziesemer.utils.classParser.IClassParser).
This method does not perform any of its own caching - code requiring optimal performance should not call this method multiple times when expecting the same results, but instead maintain a reference to previously returned results for any required reuse. Furthermore - also for performance opportunities - a reference to the internal state is returned, with no efforts made to return copies or unmodifiable collections, etc.
org.apache.commons.cli.ParseExceptionpublic Set getRequiredOptions()
public Map<String,org.apache.commons.cli.Option> getLiveOptions()
getResults(), but without executing any validations
- and by returning the underlying map, allows specific options to be quickly referenced by their key
(Option.getOpt() or Option.getLongOpt()).Copyright © 2007–2017 Mark A. Ziesemer. All rights reserved.