HOME

com.ireasoning.util
Class ParseArguments

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

public class ParseArguments
extends java.lang.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(java.lang.String[] args, java.lang.String options)
           
ParseArguments(java.lang.String[] args, java.lang.String switches, java.lang.String options)
           
 
Method Summary
 java.lang.String[] getArguments()
          Returns an array of 'real' arguememnts, without switches and options.
 java.lang.String getOptionValue(char option)
          Returns the value of an option
 java.lang.String getOptionValue(char option, java.lang.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(java.lang.String[] args,
                      java.lang.String switches,
                      java.lang.String options)
Parameters:
switches - a string of switches
options - a string of options

ParseArguments

public ParseArguments(java.lang.String[] args,
                      java.lang.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 java.lang.String getOptionValue(char option)
Returns the value of an option

Parameters:
option - the option

getOptionValue

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

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

getArguments

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


HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.