gcspy.utils
Class Arguments

java.lang.Object
  extended by gcspy.utils.Arguments

public class Arguments
extends java.lang.Object

Manages the shell arguments passed to the main method

Author:
Tony Printezis, Richard Jones

Field Summary
static int INT_TYPE
          Type for interger-valued arguments
static int POS_INT_TYPE
          Type for positive integer-valued arguments
static int STRING_TYPE
          Type for string-valued arguments
 
Constructor Summary
Arguments()
          Create new arguments
 
Method Summary
 void add(java.lang.String name)
          Add a compulsory argument
 void add(java.lang.String name, boolean compulsory, int[] types)
          Add an argument (no values, requirements nor exclusions)
 void add(java.lang.String name, boolean compulsory, int[] types, java.lang.Object[] values)
          Add an argument (no requirements or exclusions)
 void add(java.lang.String name, boolean compulsory, int[] types, java.lang.Object[] values, java.lang.String[] requires, java.lang.String[] excluded)
          Add an argument
 void add(java.lang.String name, boolean compulsory, int[] types, java.lang.String[] requires, java.lang.String[] excluded)
          Add an argument (no values set)
 void add(java.lang.String name, java.lang.String[] requires, java.lang.String[] excluded)
          Add a compulsory argument (no values)
 java.lang.String getError()
          Get the argument error message
 java.lang.Object[] getValues(java.lang.String name)
          Get an argument's parameter values
 boolean isSet(java.lang.String name)
          Is an argument set?
 boolean parse(java.lang.String[] args)
          Parse arguments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_TYPE

public static final int STRING_TYPE
Type for string-valued arguments

See Also:
Constant Field Values

INT_TYPE

public static final int INT_TYPE
Type for interger-valued arguments

See Also:
Constant Field Values

POS_INT_TYPE

public static final int POS_INT_TYPE
Type for positive integer-valued arguments

See Also:
Constant Field Values
Constructor Detail

Arguments

public Arguments()
Create new arguments

Method Detail

add

public void add(java.lang.String name,
                boolean compulsory,
                int[] types,
                java.lang.Object[] values,
                java.lang.String[] requires,
                java.lang.String[] excluded)
Add an argument

Parameters:
name - The name of the argument
compulsory - Whether it is compulsory
types - The types of the argument's parameters (INT, STRING, POS)
values - The values of the argument's parameters
requires -
excluded -

add

public void add(java.lang.String name,
                boolean compulsory,
                int[] types,
                java.lang.String[] requires,
                java.lang.String[] excluded)
Add an argument (no values set)

Parameters:
name - The name of the argument
compulsory - Whether it is compulsory
types - The types of the argument's parameters (INT, STRING, POS)
requires -
excluded -

add

public void add(java.lang.String name,
                boolean compulsory,
                int[] types,
                java.lang.Object[] values)
Add an argument (no requirements or exclusions)

Parameters:
name - The name of the argument
compulsory - Whether it is compulsory
types - The types of the argument's parameters (INT, STRING, POS)
values - The values of the argument's parameters

add

public void add(java.lang.String name,
                boolean compulsory,
                int[] types)
Add an argument (no values, requirements nor exclusions)

Parameters:
name - The name of the argument
compulsory - Whether it is compulsory
types - The types of the argument's parameters (INT, STRING, POS)

add

public void add(java.lang.String name,
                java.lang.String[] requires,
                java.lang.String[] excluded)
Add a compulsory argument (no values)

Parameters:
name - The name of the argument
requires -
excluded -

add

public void add(java.lang.String name)
Add a compulsory argument

Parameters:
name -

getError

public java.lang.String getError()
Get the argument error message

Returns:
the parsing errors

parse

public boolean parse(java.lang.String[] args)
Parse arguments

Parameters:
args - The strings to parse
Returns:
true if parsed successfully

getValues

public java.lang.Object[] getValues(java.lang.String name)
Get an argument's parameter values

Parameters:
name - The name of the argument
Returns:
Its parameter values

isSet

public boolean isSet(java.lang.String name)
Is an argument set?

Parameters:
name - The argument's name
Returns:
true if it is set