visad.util
Class CmdlineParser

java.lang.Object
  extended by visad.util.CmdlineParser

public class CmdlineParser
extends Object

Parse command-line arguments passed to the initial main() method of an application.

To use this, a class would implement CmdlineConsumer, then add the following code snippet to the constructor (assuming the constructor is supplied a list of arguments named 'args'):

 
    CmdlineParser cmdline = new CmdlineParser(this);
    if (!cmdline.processArgs(args)) {
 
 
      complain about errors, exit, etc.
 
 
    }
 


Constructor Summary
CmdlineParser(Object mainClass)
          Create a command-line parser.
 
Method Summary
 void addConsumer(CmdlineConsumer consumer)
          Add a command-line argument/keyword consumer.
 String getMainClassName()
          Get the name of the main class.
 boolean processArgs(String[] args)
          Pass all options/keywords on to all CmdlineConsumers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmdlineParser

public CmdlineParser(Object mainClass)
Create a command-line parser.

Parameters:
mainClass - The class in which the main() method lives.
Method Detail

addConsumer

public void addConsumer(CmdlineConsumer consumer)
Add a command-line argument/keyword consumer. consumer Class which implements CmdlineConsumer.


getMainClassName

public String getMainClassName()
Get the name of the main class.

Returns:
main class name

processArgs

public boolean processArgs(String[] args)
Pass all options/keywords on to all CmdlineConsumers.

Parameters:
args - Array of command-line arguments passed to main() method.