BEA Systems, Inc.

com.beasys.commerce.util
Class ArgsParser

java.lang.Object
  |
  +--com.beasys.commerce.util.ArgsParser

public abstract class ArgsParser
extends java.lang.Object

Parses the arguments passed to public static void main(String args[]) Subclasses specify their application's grammar in the constructor.


Inner Class Summary
static interface ArgsParser.HelpSpecifiedException
          The user specified -? or -h
static interface ArgsParser.UsageException
          The user entered unparseable data
 
Method Summary
 boolean getParameterSpecified(java.lang.String name)
           
 java.lang.String getParameterValue(java.lang.String name)
          Retreive the value of a parameter.
 boolean getQualifierSpecified(java.lang.String name)
           
 java.lang.String getQualifierValue(java.lang.String name)
          Retreive the value of a qualifier.
 void parse()
          Parse the command line
 void printUsage(java.io.PrintStream printStream)
          Print a usage message
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

printUsage

public void printUsage(java.io.PrintStream printStream)
Print a usage message
Parameters:
printStream - the target stream for the usage message

parse

public void parse()
           throws ArgsParser.UsageException,
                  ArgsParser.HelpSpecifiedException,
                  java.lang.Error
Parse the command line
Throws:
ArgsParser.UsageException - the user entered unparseable data. You should print this exceptions's getMessage(), followed by printUsage()
ArgsParser.HelpSpecifiedException - the user specified "-?" or "-h". You should call printUsage() for this exception.
java.lang.Error - a development bug. call getMessage() for the reason

getQualifierValue

public java.lang.String getQualifierValue(java.lang.String name)
                                   throws java.lang.Error
Retreive the value of a qualifier. If the qualifer was not specified on the command line, the default value is returned if it exists. Otherwise, null is returned. Use getQualifierSpecified() to determine if the qualifier was actually specified on the command line.
Parameters:
name - the name of a qualifier
Returns:
the value of a qualifier. Call this function AFTER calling parse().
Throws:
java.lang.Error - a development bug
See Also:
getQualifierSpecified(java.lang.String)

getQualifierSpecified

public boolean getQualifierSpecified(java.lang.String name)
                              throws java.lang.Error
Parameters:
the - name of a qualifier
Returns:
true if the qualifier was specified on the command line. false if the qualifier was not specified.
Throws:
java.lang.Error - a development bug. call getMessage() for the reason

getParameterValue

public java.lang.String getParameterValue(java.lang.String name)
                                   throws java.lang.Error
Retreive the value of a parameter. If the parameter was not specified on the command line, the default value is returned if it exists. Otherwise, null is returned. Use getParameterSpecified() to determine if the parameter was actually specified on the command line.
Parameters:
name - the name of a parameter
Returns:
the value of a parameter. Call this function AFTER calling parse().
Throws:
java.lang.Error - a development bug. call getMessage() for the reason
See Also:
getParameterSpecified(java.lang.String)

getParameterSpecified

public boolean getParameterSpecified(java.lang.String name)
                              throws java.lang.Error
Parameters:
the - name of a parameter
Returns:
true if the parameter was specified on the command line. false if the parameter was not specified.
Throws:
java.lang.Error - a development bug. call getMessage() for the reason

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved