net.sourceforge.jsrvany.util
Class CommandLineParser

java.lang.Object
  |
  +--net.sourceforge.jsrvany.util.CommandLineParser

public class CommandLineParser
extends java.lang.Object

This accepts command line arguments in the form "-option parameter" or just "parameter" and provides a number of methods to retrive them for use

Copyright (c) 1998 Damian Fauth

 usage       : java CommandLineParser [options]
 example     : java CommandLineParser -filename "wooz.txt" -message "Hello"
 Note that this class is really to be used by other applications. As a standalone application it will simply
 echo the options it is provided with

 note: '-' is used to distinguish an option on the command line
       e.g. -user username

 


Constructor Summary
CommandLineParser(java.lang.String[] args)
          constructor - accepts String[] from main
 
Method Summary
 int count(java.lang.String option)
          count the number of parameters submitted with this option
 java.util.Enumeration enumerate()
          Enumerate all options and parameters
 java.util.Enumeration enumerateKeys()
          Enumerate all options
 java.lang.String get(java.lang.String option)
          Gets the first parameter for a particular option
 java.util.Enumeration getEnumeration(java.lang.String option)
          Gets enumeration of all parameters associated with a particular option
 java.lang.String[] getStringArray(java.lang.String option)
          Gets enumeration of all parameters associated with a particular option
static void main(java.lang.String[] args)
          main entry point - mainly for development and testing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineParser

public CommandLineParser(java.lang.String[] args)
constructor - accepts String[] from main
Method Detail

main

public static void main(java.lang.String[] args)
main entry point - mainly for development and testing

count

public int count(java.lang.String option)
count the number of parameters submitted with this option
Parameters:
option - the option name
Returns:
returns the number of parameters for this option

enumerate

public java.util.Enumeration enumerate()
Enumerate all options and parameters
Returns:
returns all options and parameters as an Enumeration of Vector objects

enumerateKeys

public java.util.Enumeration enumerateKeys()
Enumerate all options
Returns:
returns all options as an Enumeration

get

public java.lang.String get(java.lang.String option)
                     throws java.util.NoSuchElementException
Gets the first parameter for a particular option
Parameters:
option - the option
Returns:
returns the parameter as a String

getEnumeration

public java.util.Enumeration getEnumeration(java.lang.String option)
                                     throws java.util.NoSuchElementException
Gets enumeration of all parameters associated with a particular option
Parameters:
option - the option
Returns:
returns the parameters as an Enumeration

getStringArray

public java.lang.String[] getStringArray(java.lang.String option)
                                  throws java.util.NoSuchElementException
Gets enumeration of all parameters associated with a particular option
Parameters:
option - the option
Returns:
returns the parameters as a String Array