igpp.util
Class Argument

java.lang.Object
  extended by igpp.util.Argument

public class Argument
extends Object

Argument is a class that contains methods for parsing options and finding values within those options. It includes support for parsing strings into binary values.

Since:
1.0
Version:
1.0, 04/21/03
Author:
Todd King, Planetary Data System

Constructor Summary
Argument()
          Creates an instance.
 
Method Summary
 int add(String name)
          Adds an option definition to the list of known options.
 int add(String name, int id)
          Adds an option definition to the list of known options.
static String find(String[] options, String name)
          Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword.
static String find(String[] options, String name, String defaultValue)
          Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword.
static String find(String[] options, String name, String defaultValue, int start)
          Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword.
 int token(String name)
          Searches the list of options and returns the ID of the first match found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Argument

public Argument()
Creates an instance.

Since:
1.0
Method Detail

add

public int add(String name,
               int id)
Adds an option definition to the list of known options.

Parameters:
name - the name of the option.
id - the integer ID of the option.
Returns:
the count of the number of items in the list;
Since:
1.0

add

public int add(String name)
Adds an option definition to the list of known options. Automatcially assigns a unique ID number to the added option and returns the selected ID.

Parameters:
name - the name of the option.
Returns:
the ID assigned to the added option.
Since:
1.0

token

public int token(String name)
Searches the list of options and returns the ID of the first match found. The search ignores case.

Parameters:
name - the name of the option.
Returns:
the ID of the first match found. If no match is found -1 is returned.
Since:
1.0

find

public static String find(String[] options,
                          String name)
Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword. If the keyword is found the value is returned. If the keyword in not found a null value is returned.

Parameters:
options - the array of options. Each options must be specified in the form KEYWORD=VALUE. If an option is specified as just KEYWORD, then a value of 1 is assumed.
name - the keyword to locate within the list of options. Partial matches are permitted.
Returns:
the value of the options that matches the given keyword. otherwise the default value which is passed.
Since:
1.0

find

public static String find(String[] options,
                          String name,
                          String defaultValue)
Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword. If the keyword is found the value is returned. If the keyword in not found the value passed as the default is returned.

Parameters:
options - the array of options. Each options must be specified in the form KEYWORD=VALUE. If an option is specified as just KEYWORD, then a value of 1 is assumed.
name - the keyword to locate within the list of options. Partial matches are permitted.
defaultValue - the default value to return if an options with the the given keyword is not found.
Returns:
the value of the options that matches the given keyword. otherwise the default value which is passed.
Since:
1.0

find

public static String find(String[] options,
                          String name,
                          String defaultValue,
                          int start)
Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword. If the keyword is found the value is returned. If the keyword in not found the value passed as the default is returned.

Parameters:
options - the array of options. Each options must be specified in the form KEYWORD=VALUE. If an option is specified as just KEYWORD, then a value of 1 is assumed.
name - the keyword to locate within the list of options. Partial matches are permitted.
defaultValue - the default value to return if an options with the the given keyword is not found.
start - the index of the element within options to begin the search.
Returns:
the value of the options that matches the given keyword. otherwise the default value which is passed.
Since:
1.0


Copyright © 2008-2009 Regents University of California. All Rights Reserved.