y.util
Class CommandLineArguments

java.lang.Object
  |
  +--y.util.CommandLineArguments

public class CommandLineArguments
extends Object

Helper class for parsing command line arguments. It allows for the parsing of attributes, that are preceded by a '-' and the main argument, that is not preceded by an identifier.


Constructor Summary
CommandLineArguments()
          Creates a new instance of CommandLineArguments
 
Method Summary
 void addArgument(String name, String defaultValue)
          tell the parser to treat '-name xxxx' as a key value pair
 void addOption(String name)
          tell the parser to treat the '-name' option as a boolean option
 String getArgument(String name)
          returns the string value of the option named 'name'
 String getMainArgument()
          Getter for property mainArgument.
 Map getOptionMap()
          Getter for property optionMap.
 boolean hasMainArgument()
          Returns whether or not the main argument is set.
 void initFromArguments(String[] args)
          parses the command line arguments and fills the internal map using the given values
 boolean isArgumentSet(String name)
          whether or not the argument 'name' is available
 boolean isOptionSet(String name)
          queries the value of the switch named 'name'
 void setMainArgument(String mainArgument)
          Setter for property mainArgument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineArguments

public CommandLineArguments()
Creates a new instance of CommandLineArguments

Method Detail

initFromArguments

public void initFromArguments(String[] args)
parses the command line arguments and fills the internal map using the given values

Parameters:
args - command line arguments

getOptionMap

public Map getOptionMap()
Getter for property optionMap.

Returns:
Value of property optionMap.

addOption

public void addOption(String name)
tell the parser to treat the '-name' option as a boolean option

Parameters:
name - the name of the boolean option

getMainArgument

public String getMainArgument()
Getter for property mainArgument.

Returns:
Value of property mainArgument.

setMainArgument

public void setMainArgument(String mainArgument)
Setter for property mainArgument.

Parameters:
mainArgument - New value of property mainArgument.

hasMainArgument

public boolean hasMainArgument()
Returns whether or not the main argument is set.


addArgument

public void addArgument(String name,
                        String defaultValue)
tell the parser to treat '-name xxxx' as a key value pair

Parameters:
name - the key
defaultValue - the default value

isOptionSet

public boolean isOptionSet(String name)
queries the value of the switch named 'name'

Parameters:
name - the name
Returns:
true if this option was present in the command line

getArgument

public String getArgument(String name)
returns the string value of the option named 'name'

Parameters:
name - the name of the option
Returns:
the string value or "" if not set

isArgumentSet

public boolean isArgumentSet(String name)
whether or not the argument 'name' is available

Parameters:
name - the name of the argument

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003