Search this API

y.util
Class CommandLineArguments

java.lang.Object
  extended by y.util.CommandLineArguments

public class CommandLineArguments
extends java.lang.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(java.lang.String name, java.lang.String defaultValue)
          Tell the parser to treat '-name xxxx' as a key value pair.
 void addOption(java.lang.String name)
          tell the parser to treat the '-name' option as a boolean option
 java.lang.String getArgument(java.lang.String name)
          returns the string value of the option named 'name'
 java.lang.String getMainArgument()
          Getter for property mainArgument.
 java.util.Map getOptionMap()
          Getter for property optionMap.
 boolean hasMainArgument()
          Returns whether or not the main argument is set.
 void initFromArguments(java.lang.String[] args)
          parses the command line arguments and fills the internal map using the given values
 boolean isArgumentSet(java.lang.String name)
          whether or not the argument 'name' is available
 boolean isOptionSet(java.lang.String name)
          queries the value of the switch named 'name'
 void setMainArgument(java.lang.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(java.lang.String[] args)
parses the command line arguments and fills the internal map using the given values

Parameters:
args - command line arguments

getOptionMap

public java.util.Map getOptionMap()
Getter for property optionMap.

Returns:
Value of property optionMap.

addOption

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

Parameters:
name - the name of the boolean option

getMainArgument

public java.lang.String getMainArgument()
Getter for property mainArgument.

Returns:
Value of property mainArgument.

setMainArgument

public void setMainArgument(java.lang.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(java.lang.String name,
                        java.lang.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(java.lang.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 java.lang.String getArgument(java.lang.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(java.lang.String name)
whether or not the argument 'name' is available

Parameters:
name - the name of the argument

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