org.eodisp.util.configuration
Class ManualCommandlineMapper

java.lang.Object
  extended by org.eodisp.util.configuration.ManualCommandlineMapper
All Implemented Interfaces:
CommandlineMapper

public class ManualCommandlineMapper
extends java.lang.Object
implements CommandlineMapper

This class allows a manual mapping mapping of the shortFlag, longFlag and help of a parameter.

Usage:

 Map<String, CommandlineOption> commandlineMapping = new HashMap<String, CommandlineOption>();
 commandlineMapping.put("s", new CommandlineOption('s', "long-flag", "help message"));
 ManualCommandlineMapper manualCommandlineMapper = new ManualCommandlineMapper(commandlineMapping, true);
 

Version:
$Id: ManualCommandlineMapper.java 3151 2006-08-23 13:16:01Z ibirrer $
Author:
ibirrer

Nested Class Summary
static class ManualCommandlineMapper.CommandlineOption
          Helper class to define a command line option's: short flag long flag help text
 
Field Summary
 
Fields inherited from interface org.eodisp.util.configuration.CommandlineMapper
BASIC_COMMAND_LINE_MAPPER, NULL_COMMAND_LINE_MAPPER
 
Constructor Summary
ManualCommandlineMapper(java.util.Map<java.lang.String,ManualCommandlineMapper.CommandlineOption> mappings)
          Creates a new manual command line mapper.
ManualCommandlineMapper(java.util.Map<java.lang.String,ManualCommandlineMapper.CommandlineOption> mappings, boolean useBasicMapperAsDefault)
          Creates a new manual command line mapper.
 
Method Summary
 com.martiansoftware.jsap.Parameter mapEntry(Configuration.Entry entry)
          Returns the JSAP parameter (command line option) that is mapped to the given entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManualCommandlineMapper

public ManualCommandlineMapper(java.util.Map<java.lang.String,ManualCommandlineMapper.CommandlineOption> mappings)
Creates a new manual command line mapper. The mapping is defined by the mappings parameter. Parameters with no manual mapping are not mapped.

Parameters:
mappings - A map with its keys set to the id of a configuration entry and the value set to the mapped ManualCommandlineMapper.CommandlineOption.
See Also:
ManualCommandlineMapper(Map, boolean)

ManualCommandlineMapper

public ManualCommandlineMapper(java.util.Map<java.lang.String,ManualCommandlineMapper.CommandlineOption> mappings,
                               boolean useBasicMapperAsDefault)
Creates a new manual command line mapper. The mapping is defined by the mappings parameter.

Parameters:
mappings - A map with its keys set to the id of a configuration entry and the value set to the mapped ManualCommandlineMapper.CommandlineOption.
useBasicMapperAsDefault - if set to true, each configuration entry with no manual mapping is mapped with the BasicCommandlineMapper. If set to false, no mapping for the configuration entry is done, that is, the #mapEntry(Entry) returns null for configuration entries not defined in the mappings parameter.
Method Detail

mapEntry

public com.martiansoftware.jsap.Parameter mapEntry(Configuration.Entry entry)
Returns the JSAP parameter (command line option) that is mapped to the given entry. A return value of null means that no command line option shall be created for the given entry.

Specified by:
mapEntry in interface CommandlineMapper
Parameters:
entry - the entry that shall be mapped to a parameter
Returns:
the parameter mapped to the given configuration entry or null if the given configuration entry shall not be mapped to a command line option.