Process UI Toolkit API

filenet.vw.toolkit.utils
Class VWCommandLineArgs

java.lang.Object
  extended by filenet.vw.toolkit.utils.VWCommandLineArgs

public class VWCommandLineArgs
extends java.lang.Object

Utility class to parse command line arguments into name/value pairs

This class provides several command line argument parsing options, including the following:

Example

Consider inputting the following command line arguments to this class:

    /x=7 /y:8 -z 9 /detail /verbose 
The object created with the above arguments contains a parameter "x" with a value of 7, a parameter "y" with a value of 8, and a parameter "z" with a value of 9. The object also contains two flags: "detail" and "verbose".

Notes about command line flags:

Since:
eProcess 4.0

Constructor Summary
VWCommandLineArgs(java.util.Properties props)
          Constructor from Properties
VWCommandLineArgs(java.lang.String[] argv)
          Constructor for standard command-line parsing with defaults of case-sensitivity, parameter separators "/" or "-", and name-value separators of "=" or ":".
VWCommandLineArgs(java.lang.String[] argv, boolean ignoreCase)
          Constructor for standard command-line parsing with default parameter separators "/" or "-" and name-value separators of "=" or ":", including a case-sensitivity control parameter
VWCommandLineArgs(java.lang.String[] argv, boolean ignoreCase, char[] paramBeginChars)
          Constructor for command-line parsing with case-sensitivity control and a character array to specify parameter separators.
VWCommandLineArgs(java.lang.String[] argv, java.lang.String[] argNames, boolean ignoreCase)
          Constructor to input one parameter that is a list containing only argv values, and another parameter that contains a list of parameter names.
VWCommandLineArgs(java.lang.String fileName, boolean ignoreCase)
          Constructor to load the arguments from a "properties" file and allow case-sensitivity control.
 
Method Summary
 int getIntParameter(java.lang.String paramName, int defaultValue)
          Returns the parameter value for the name specified by the input parameter and assigns an integer representation of the default value if the parameter value cannot be determined.
 java.lang.String getParameter(java.lang.String paramName)
          Returns the parameter value for the name specified by the input parameter name.
 java.lang.String getParameter(java.lang.String paramName, java.lang.String defaultValue)
          Returns the parameter value for the name specified by the input parameter and assigns a string representation of the default value if the parameter value cannot be determined.
 boolean help()
           
 boolean isPresent(java.lang.String flag)
          Returns true if the flag is present in the command line.
 void list(java.io.PrintStream out)
          Prints a list of properties to a printstream.
 void list(java.io.PrintWriter out)
          Prints a list of properties to a device.
 void load(java.io.InputStream inStream)
          Loads parameter properties from an input stream.
static void main(java.lang.String[] argv)
          Test method--do not use.
 java.util.Enumeration parameterNames()
          Returns an enumeration of property names.
 void setIgnoreCase(boolean ignoreCase)
          Controls case-sensitivity when interpreting input values.
 void setParamBeginChars(char[] s)
          Sets the delimiters that separate parameters.
 void setParamValueDelimiters(char[] s)
          Sets the delimiters that separate names from their values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VWCommandLineArgs

public VWCommandLineArgs(java.util.Properties props)
Constructor from Properties

Parameters:
props -
Since:
eProcess 4.0

VWCommandLineArgs

public VWCommandLineArgs(java.lang.String[] argv)
Constructor for standard command-line parsing with defaults of case-sensitivity, parameter separators "/" or "-", and name-value separators of "=" or ":".

Parameters:
argv - command-line argument list.
Since:
eProcess 4.0

VWCommandLineArgs

public VWCommandLineArgs(java.lang.String[] argv,
                         boolean ignoreCase)
Constructor for standard command-line parsing with default parameter separators "/" or "-" and name-value separators of "=" or ":", including a case-sensitivity control parameter. . *

Parameters:
argv - command-line argument list.
ignoreCase - boolean flag: true means no case sensitivity.
Since:
eProcess 4.0

VWCommandLineArgs

public VWCommandLineArgs(java.lang.String[] argv,
                         boolean ignoreCase,
                         char[] paramBeginChars)
Constructor for command-line parsing with case-sensitivity control and a character array to specify parameter separators.

Parameters:
argv - list of command-line values of parameters
ignoreCase - boolean flag: true means no case sensitivity.
paramBeginChars - character array to specify parameter separators
Since:
eProcess 4.0

VWCommandLineArgs

public VWCommandLineArgs(java.lang.String fileName,
                         boolean ignoreCase)
                  throws java.lang.Exception
Constructor to load the arguments from a "properties" file and allow case-sensitivity control.

Parameters:
fileName - name of a file containing the contents of an argv command-line string. Note that newline counts as whitespace.
ignoreCase - boolean flag: true means no case sensitivity.
Throws:
java.lang.Exception
Since:
eProcess 4.0

VWCommandLineArgs

public VWCommandLineArgs(java.lang.String[] argv,
                         java.lang.String[] argNames,
                         boolean ignoreCase)
Constructor to input one parameter that is a list containing only argv values, and another parameter that contains a list of parameter names. A third parameter allows case-sensitivity control.

With the name-value pairs created with this constructor, a string representation of any parameter value can be obtained in a standardized way with the #getParameter(paramName) method.

Note This constructor can be used to accommodate order-dependent command line parameter lists.

Parameters:
argv - list of command-line values of parameters
argNames - list of parameter names
ignoreCase - boolean flag: true means no case sensitivity.
Since:
eProcess 4.0
Method Detail

setParamValueDelimiters

public void setParamValueDelimiters(char[] s)
Sets the delimiters that separate names from their values.

Parameters:
s - a character array of name-from-value delimiters
Since:
eProcess 4.0

setParamBeginChars

public void setParamBeginChars(char[] s)
Sets the delimiters that separate parameters.

Parameters:
s - a character array of parameter delimiters
Since:
eProcess 4.0

setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)
Controls case-sensitivity when interpreting input values.

Parameters:
ignoreCase - true means case will be ignored.
Since:
eProcess 4.0

getParameter

public java.lang.String getParameter(java.lang.String paramName)
Returns the parameter value for the name specified by the input parameter name.

Parameters:
paramName - name of the parameter
Returns:
the parameter value
Since:
eProcess 4.0

getParameter

public java.lang.String getParameter(java.lang.String paramName,
                                     java.lang.String defaultValue)
Returns the parameter value for the name specified by the input parameter and assigns a string representation of the default value if the parameter value cannot be determined.

Parameters:
paramName - name of the parameter
defaultValue - the default value to assign if the parameter value cannot be determined.
Returns:
the parameter value in String format
Since:
eProcess 4.0

getIntParameter

public int getIntParameter(java.lang.String paramName,
                           int defaultValue)
Returns the parameter value for the name specified by the input parameter and assigns an integer representation of the default value if the parameter value cannot be determined.

Parameters:
paramName - name of the parameter
defaultValue - default value for the parameter
Returns:
the parameter value in int format
Since:
eProcess 4.0

isPresent

public boolean isPresent(java.lang.String flag)
Returns true if the flag is present in the command line.

Parameters:
flag - the name of the potential flag.
Returns:
true if the flag is present in the command line.
Since:
eProcess 4.0

list

public void list(java.io.PrintStream out)
Prints a list of properties to a printstream.

Parameters:
out - the stream ouput
Since:
eProcess 4.0

list

public void list(java.io.PrintWriter out)
Prints a list of properties to a device.

Parameters:
out - the print output device
Since:
eProcess 4.0

load

public void load(java.io.InputStream inStream)
          throws java.io.IOException
Loads parameter properties from an input stream.

Parameters:
inStream - an input stream
Throws:
java.io.IOException
Since:
eProcess 4.0

parameterNames

public java.util.Enumeration parameterNames()
Returns an enumeration of property names.

Returns:
an enumeration of property names
Since:
eProcess 4.0

main

public static void main(java.lang.String[] argv)
Test method--do not use.

Parameters:
argv - a list of command-line arguments
Since:
eProcess 4.0

help

public boolean help()

Process UI Toolkit API

© Copyright IBM Corporation 2002, 2008. All rights reserved.