util
Class PropertyParser

java.lang.Object
  extended by util.CommandLineParser
      extended by util.PropertyParser
Direct Known Subclasses:
Annulus.Series, DataFileReader, GenericSql.Extract, LightCurveSimulator.Series, ObserveSql.Extract, PointingModel.FileData, WcsMatch.Coarse

public class PropertyParser
extends CommandLineParser

A class that allows reading of command line switches and parsing them into Maps. This makes only sense for one-parameter switches. To avoid awkward-long command line switches, a mapping of short names to property keys can be provided on the retrieval methods.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.CommandLineParser
CommandLineParser.Test
 
Field Summary
private  Map<String,String> argprop
          Mapping from command line arguments to property keys.
 
Constructor Summary
PropertyParser(Map<String,String> tolong)
          Constructs a property parser where the argumental map links short names to property keys.
 
Method Summary
static Map<String,String> parseMap(String[] commandline, Map<String,String> tolong, Map<String,String> in)
          Retrieves a map consisting of the given parameter switches.
static Map<String,String> parseMap(String[] commandline, Map<String,String> tolong, Map<String,String> in, PrintWriter out)
          Retrieves a map consisting of the given parameter switches.
 Map<String,String> parseProperties(Map<String,String> in)
          Parses the command lines and additionally returns the properties parsed
 Map<String,String> parseProperties(PrintWriter out)
          Parses the command lines and additionally returns the properties parsed
 Map<String,String> parseProperties(PrintWriter out, Map<String,String> in)
          Parses the command lines and additionally returns the properties parsed
private static Map<String,String> parseToProperties(PropertyParser aux, PrintWriter out, Map<String,String> in)
          Retrieves a map consisting of the given parameter switches.
 
Methods inherited from class util.CommandLineParser
getArguments, getCommandLine, getCommands, getRegisteredSwitches, hasAnySwitch, hasSwitch, hasSwitch, haveAllSwitches, parse, printCommandLine, registerLine, registerSwitches, setCommands, staticUsage, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

argprop

private Map<String,String> argprop
Mapping from command line arguments to property keys.

Constructor Detail

PropertyParser

public PropertyParser(Map<String,String> tolong)
Constructs a property parser where the argumental map links short names to property keys. The short names are the command line switches, which are registered to the parser as one-parameter switches.

Method Detail

parseProperties

public Map<String,String> parseProperties(PrintWriter out)
Parses the command lines and additionally returns the properties parsed


parseProperties

public Map<String,String> parseProperties(PrintWriter out,
                                          Map<String,String> in)
Parses the command lines and additionally returns the properties parsed


parseProperties

public Map<String,String> parseProperties(Map<String,String> in)
Parses the command lines and additionally returns the properties parsed

Parameters:
in - Default properties or null. Overriden with actually parsed ones.

parseMap

public static Map<String,String> parseMap(String[] commandline,
                                          Map<String,String> tolong,
                                          Map<String,String> in)
                                   throws ParseException
Retrieves a map consisting of the given parameter switches. To allow for short command line switches, the argumental map should host the command line switches (including possible '-' chars) to full key names.

Parameters:
tolong - Keys are the command line switches, values the property key names.
in - Default properties or null. Overriden with actually parsed ones.
Throws:
ParseException

parseMap

public static Map<String,String> parseMap(String[] commandline,
                                          Map<String,String> tolong,
                                          Map<String,String> in,
                                          PrintWriter out)
                                   throws ParseException
Retrieves a map consisting of the given parameter switches. To allow for short command line switches, the argumental map should host the command line switches (including possible '-' chars) to full key names.

Parameters:
tolong - Keys are the command line switches, values the property key names.
in - Default properties or null. Overriden with actually parsed ones.
Throws:
ParseException

parseToProperties

private static Map<String,String> parseToProperties(PropertyParser aux,
                                                    PrintWriter out,
                                                    Map<String,String> in)
Retrieves a map consisting of the given parameter switches. To allow for short command line switches, the argumental map should host the command line switches (including possible '-' chars) to full key names.