HOME

com.ireasoning.util
Class ParseArguments

java.lang.Object
  extended bycom.ireasoning.util.ParseArguments

public class ParseArguments
extends Object

This class is used to parse the command line arguments.

Concepts in this class
switches: without value, such as -g in javac
options: with value, such as -d in javac
Example:

 ParseArguments p = new ParseArguments(args, "gO", "d");
 boolean g = p.isSwitchPresent('g');
 String dir = p.getOptionValue('d');
 


Constructor Summary
ParseArguments(String[] args, String options)
           
ParseArguments(String[] args, String switches, String options)
           
 
Method Summary
 String[] getArguments()
          Returns an array of 'real' arguememnts, without switches and options.
 String getOptionValue(char option)
          Returns the value of an option
 String getOptionValue(char option, String defaultVal)
          Returns the value of an option
 boolean isSwitchPresent(char switchChar)
          Returns true if the passed switch is present
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseArguments

public ParseArguments(String[] args,
                      String switches,
                      String options)
Parameters:
switches - a string of switches
options - a string of options

ParseArguments

public ParseArguments(String[] args,
                      String options)
Parameters:
options - a string of options
Method Detail

isSwitchPresent

public boolean isSwitchPresent(char switchChar)
Returns true if the passed switch is present


getOptionValue

public String getOptionValue(char option)
Returns the value of an option

Parameters:
option - the option

getOptionValue

public String getOptionValue(char option,
                             String defaultVal)
Returns the value of an option

Parameters:
option - the option
defaultVal - the default value of the option

getArguments

public String[] getArguments()
Returns an array of 'real' arguememnts, without switches and options.


HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.