Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.utilities.optionhandling
Class OptionUtil

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionUtil

public final class OptionUtil
extends Object

Utility functions related to Option handling.


Constructor Summary
OptionUtil()
           
 
Method Summary
static void addFlag(List<String> parameters, Flag flag)
          Adds the specified flag to the beginning of the given parameter list.
static void addFlag(List<String> parameters, OptionID optionID)
          Adds the specified optionID of a flag to the beginning of the given parameter list.
static void addParameter(List<String> parameters, OptionID optionID, String value)
          Adds the specified optionID and its value to the beginning of the given parameter list.
static void addParameter(List<String> parameters, Parameter<?,?> parameter, String value)
          Adds the specified parameter and the specified value to the beginning of the given parameter list.
static String[] addParameter(String[] parameters, OptionID optionID, String value)
          Adds the specified optionID and its value to the beginning of the given parameter array.
static void addParameters(List<String> parameters, Iterable<String> append)
          Appends the given options to the parameter list.
static void addParameters(List<String> parameters, String[] append)
          Appends the given options to the parameter list.
static String describeParameterizable(Parameterizable p)
          Produce a description of a Parameterizable instance (including recursive options).
static StringBuffer describeParameterizable(StringBuffer buf, Parameterizable p, int width, String indent)
          Format a description of a Parameterizable (including recursive options).
static void formatForConsole(StringBuffer buf, int width, String indent, List<Pair<Parameterizable,Option<?>>> options)
          Format a list of options (and associated owning objects) for console help output.
static
<O extends Option<?>>
String
optionsNamesToString(List<O> options)
          Returns a string representation of the specified list of options containing the names of the options.
static
<O extends Option<?>>
String
optionsNamesToString(O[] options)
          Returns a string representation of the specified list of options containing the names of the options.
static List<String> parameterDifference(List<String> complete, List<String> part)
          Returns an array that contains all elements of the first parameter array that are not contained by the second parameter array.
static
<N extends NumberParameter<?>>
String
parameterNamesAndValuesToString(List<N> parameters)
          Returns a string representation of the list of number parameters containing the names and the values of the parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionUtil

public OptionUtil()
Method Detail

addFlag

public static void addFlag(List<String> parameters,
                           Flag flag)
Adds the specified flag to the beginning of the given parameter list.

Parameters:
parameters - the list of parameters
flag - the flag to be added

addFlag

public static void addFlag(List<String> parameters,
                           OptionID optionID)
Adds the specified optionID of a flag to the beginning of the given parameter list.

Parameters:
parameters - the list of parameters
optionID - the optionID to be added

addParameter

public static void addParameter(List<String> parameters,
                                OptionID optionID,
                                String value)
Adds the specified optionID and its value to the beginning of the given parameter list.

Parameters:
parameters - the list of parameters
optionID - the optionID of the parameter to be added
value - the value of the parameter to be added

addParameter

public static void addParameter(List<String> parameters,
                                Parameter<?,?> parameter,
                                String value)
Adds the specified parameter and the specified value to the beginning of the given parameter list.

Parameters:
parameters - the list of parameters
parameter - the parameter to be added
value - the value of the parameter to be added

addParameter

public static String[] addParameter(String[] parameters,
                                    OptionID optionID,
                                    String value)
Adds the specified optionID and its value to the beginning of the given parameter array.

Parameters:
parameters - the array of parameters
optionID - the optionID to be added
value - the value of the optionID to be added
Returns:
a new parameter array containing the values of parameters and the specified optionID and its value.

addParameters

public static void addParameters(List<String> parameters,
                                 Iterable<String> append)
Appends the given options to the parameter list.

Parameters:
parameters - the list of parameters
append - Parameters to append.

addParameters

public static void addParameters(List<String> parameters,
                                 String[] append)
Appends the given options to the parameter list.

Parameters:
parameters - the list of parameters
append - Parameters to append.

optionsNamesToString

public static <O extends Option<?>> String optionsNamesToString(List<O> options)
Returns a string representation of the specified list of options containing the names of the options.

Type Parameters:
O - Option type
Parameters:
options - the list of options
Returns:
the names of the options

optionsNamesToString

public static <O extends Option<?>> String optionsNamesToString(O[] options)
Returns a string representation of the specified list of options containing the names of the options.

Type Parameters:
O - Option type
Parameters:
options - the list of options
Returns:
the names of the options

parameterDifference

public static List<String> parameterDifference(List<String> complete,
                                               List<String> part)
                                        throws IllegalArgumentException
Returns an array that contains all elements of the first parameter array that are not contained by the second parameter array. The first parameter array must at least be as long as the second. The second must not contain entries that are not contained by the first.

Parameters:
complete - the complete array
part - an array that contains only elements of the first parameter array
Returns:
an array that contains all elements of the first parameter array that are not contained by the second parameter array
Throws:
IllegalArgumentException - if the first array, complete is not as long as the second array, part or the second, part, contains entries that are not contained by the first, complete

parameterNamesAndValuesToString

public static <N extends NumberParameter<?>> String parameterNamesAndValuesToString(List<N> parameters)
Returns a string representation of the list of number parameters containing the names and the values of the parameters.

Type Parameters:
N - Parameter type
Parameters:
parameters - the list of number parameters
Returns:
the names and the values of the parameters

formatForConsole

public static void formatForConsole(StringBuffer buf,
                                    int width,
                                    String indent,
                                    List<Pair<Parameterizable,Option<?>>> options)
Format a list of options (and associated owning objects) for console help output.

Parameters:
buf - Serialization buffer
width - Screen width
indent - Indentation string
options - List of options

describeParameterizable

public static String describeParameterizable(Parameterizable p)
Produce a description of a Parameterizable instance (including recursive options).

Parameters:
p - Parameterizable to describe
Returns:
Formatted description

describeParameterizable

public static StringBuffer describeParameterizable(StringBuffer buf,
                                                   Parameterizable p,
                                                   int width,
                                                   String indent)
Format a description of a Parameterizable (including recursive options).

Parameters:
buf - Buffer to append to.
p - Parameterizable to describe
width - Width
indent - Text indent
Returns:
Formatted description

Release 0.2.1 (2009-07-13_1605)