pds.util
Class PPIOption

java.lang.Object
  |
  +--pds.util.PPIOption

public class PPIOption
extends java.lang.Object

PPIOption 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

Nested Class Summary
(package private) static class PPIOption.Item
           
 
Field Summary
(package private)  java.util.ArrayList mItemList
          List of option names and id
 
Constructor Summary
PPIOption()
          Creates an instance.
 
Method Summary
 int add(java.lang.String name, int id)
          Adds an option definition to the list of known options.
static java.lang.String find(java.lang.String[] options, java.lang.String name, java.lang.String defaultValue, int start)
          Searches a list contain options specified in a KEYWORD=VALUE format and locates the option with a given keyword.
static double toDouble(java.lang.String value)
          Converts a string to a double.
static int toInt(java.lang.String value)
          Converts a string to a int.
 int token(java.lang.String name)
          Searches the list of options and returns the ID of the first match found.
static pds.util.PPITime toTime(java.lang.String pattern, java.lang.String value)
          Converts a string to a PPITime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mItemList

java.util.ArrayList mItemList
List of option names and id

Constructor Detail

PPIOption

public PPIOption()
Creates an instance.

Since:
1.0
Method Detail

add

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

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

token

public int token(java.lang.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

toInt

public static int toInt(java.lang.String value)
Converts a string to a int.

Parameters:
value - a string representation of a value.
Returns:
the converted value.
Since:
1.0

toDouble

public static double toDouble(java.lang.String value)
Converts a string to a double.

Parameters:
value - a string representation of a value.
Returns:
the converted value.
Since:
1.0

toTime

public static pds.util.PPITime toTime(java.lang.String pattern,
                                      java.lang.String value)
Converts a string to a PPITime.

Parameters:
pattern - a string representation the pattern the value is represented in.
value - a string representation of a value.
Returns:
the converted value, null if there was an error in parsing the value.
Since:
1.0

find

public static java.lang.String find(java.lang.String[] options,
                                    java.lang.String name,
                                    java.lang.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