net.sf.xenqtt
Class ApplicationArguments

java.lang.Object
  extended by net.sf.xenqtt.ApplicationArguments

public final class ApplicationArguments
extends Object

Supplies arguments and flags for the disparate modes available in Xenqtt.


Constructor Summary
ApplicationArguments()
          Create a new instance of this class.
ApplicationArguments(List<String> flags, Map<String,String> arguments)
          Create a new instance of this class.
 
Method Summary
 boolean getArgAsBoolean(String argument)
          Get an argument value interpreted as a boolean.
 boolean getArgAsBoolean(String argument, boolean defaultValue)
          Get an argument value interpreted as a boolean.
 double getArgAsDouble(String argument)
          Get an argument value interpreted as a double.
 double getArgAsDouble(String argument, double defaultValue)
          Get an argument value interpreted as a double.
 int getArgAsInt(String argument)
          Get an argument value interpreted as an int.
 int getArgAsInt(String argument, int defaultValue)
          Get an argument value interpreted as an int.
 long getArgAsLong(String argument)
          Get an argument value interpreted as a long.
 long getArgAsLong(String argument, long defaultValue)
          Get an argument value interpreted as a long.
 String getArgAsString(String argument)
          Get an argument value interpreted as a string.
 String getArgAsString(String argument, String defaultValue)
          Get an argument value interpreted as a string.
 boolean isEmpty()
           
 boolean isFlagSpecified(String flag)
          Determine if a particular flag was specified.
 boolean wereAllFlagsInterrogated()
          Determine if each of the flags that was specified by the user was interrogated by the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationArguments

public ApplicationArguments()
Create a new instance of this class.


ApplicationArguments

public ApplicationArguments(List<String> flags,
                            Map<String,String> arguments)
Create a new instance of this class.

Parameters:
flags - The flags that were specified for the application
arguments - The arguments that were specified for the application
Method Detail

isFlagSpecified

public boolean isFlagSpecified(String flag)
Determine if a particular flag was specified.

Parameters:
flag - The flag to check for
Returns:
true if the specified flag was found in the flags that were given by the user, false if it was not

wereAllFlagsInterrogated

public boolean wereAllFlagsInterrogated()
Determine if each of the flags that was specified by the user was interrogated by the application.

Returns:
true if each user-specified flag was interrogated, false if at least one was not

getArgAsInt

public int getArgAsInt(String argument)
Get an argument value interpreted as an int.

Parameters:
argument - The name of the argument
Returns:
The value associated with the argument interpreted as an int
Throws:
IllegalStateException - If the argument is not found
NumberFormatException - If the argument is found but cannot be interpreted as an int

getArgAsInt

public int getArgAsInt(String argument,
                       int defaultValue)
Get an argument value interpreted as an int.

Parameters:
argument - The name of the argument
defaultValue - The default value to use if the argument is not found
Returns:
The value associated with the argument interpreted as an int
Throws:
NumberFormatException - If the argument is found but cannot be interpreted as an int

getArgAsLong

public long getArgAsLong(String argument)
Get an argument value interpreted as a long.

Parameters:
argument - The name of the argument
Returns:
The value associated with the argument interpreted as a long
Throws:
IllegalStateException - If the argument is not found
NumberFormatException - If the argument is found but cannot be interpreted as a long

getArgAsLong

public long getArgAsLong(String argument,
                         long defaultValue)
Get an argument value interpreted as a long.

Parameters:
argument - The name of the argument
defaultValue - The default value to use if the argument is not found
Returns:
The value associated with the argument interpreted as a long
Throws:
NumberFormatException - If the argument is found but cannot be interpreted as a long

getArgAsDouble

public double getArgAsDouble(String argument)
Get an argument value interpreted as a double.

Parameters:
argument - The name of the argument
Returns:
The value associated with the argument interpreted as a double
Throws:
IllegalStateException - If the argument is not found
NumberFormatException - If the argument is found but cannot be interpreted as a double

getArgAsDouble

public double getArgAsDouble(String argument,
                             double defaultValue)
Get an argument value interpreted as a double.

Parameters:
argument - The name of the argument
defaultValue - The default value to use if the argument is not found
Returns:
The value associated with the argument interpreted as a double
Throws:
NumberFormatException - If the argument is found but cannot be interpreted as a double

getArgAsBoolean

public boolean getArgAsBoolean(String argument)
Get an argument value interpreted as a boolean.

Parameters:
argument - The name of the argument
Returns:
The value associated with the argument interpreted as a boolean
Throws:
IllegalStateException - If the argument is not found
NumberFormatException - If the argument is found but cannot be interpreted as a boolean

getArgAsBoolean

public boolean getArgAsBoolean(String argument,
                               boolean defaultValue)
Get an argument value interpreted as a boolean.

Parameters:
argument - The name of the argument
defaultValue - The default value to use if the argument is not found
Returns:
The value associated with the argument interpreted as a boolean
Throws:
NumberFormatException - If the argument is found but cannot be interpreted as a boolean

getArgAsString

public String getArgAsString(String argument)
Get an argument value interpreted as a string.

Parameters:
argument - The name of the argument
Returns:
The value associated with the argument interpreted as a string
Throws:
IllegalStateException - If the argument is not found

getArgAsString

public String getArgAsString(String argument,
                             String defaultValue)
Get an argument value interpreted as a string.

Parameters:
argument - The name of the argument
defaultValue - The default value to use if the argument is not found
Returns:
The value associated with the argument interpreted as a string

isEmpty

public boolean isEmpty()
Returns:
true if there are no flags or arguments, false if there is at least one flag or argument


Copyright © 2013. All Rights Reserved.