autoweka

## Class Util

- java.lang.Object
- - autoweka.Util

-     public class Util
      extends java.lang.Object

  Bunches of random stuff that seems to be handy in all sorts of places

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Util.NullPrintStream` Utility to class to make a void print stream.
    `static class` | `Util.ProcessKillerShutdownHook`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Util()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `argMapToString(java.util.Map<java.lang.String,java.lang.String> argMap)` Returns a string containing the arguments sorted by their name and joined together.
    `static java.util.List<java.util.List<java.lang.String>>` | `cartesianProduct(java.util.List<java.util.List<java.lang.String>> sets)` Have a list of list of strings and need the Cartesian product? Look no further!
    `static void` | `copyFile(java.io.File sourceFile, java.io.File destFile)`
    `static weka.core.Instances` | `createDummyInstances(int numInstances, int numClasses, int numUsefulNumeric, int numUsefulCategorical, int numRandomNumeric, int numRandomCategorical, int randomCategoricalSize, int seed)` Makes a simple real valued dataset of a given size, with the class determined by index
    `static java.lang.String` | `expandEnvironmentVariable(java.lang.String var)` Tries to evaluate the environment variable into something useful.
    `static java.lang.String` | `expandPath(java.lang.String path)` Tries to resolve any relative paths/symlinks on a given path.
    `static java.io.File` | `findExecutableOnPath(java.lang.String executableName)` Tries to find the given executable on the path.
    `static java.lang.String` | `getAbsoluteClasspath()`
    `static java.lang.String` | `getAutoWekaDistributionPath()`
    `static java.lang.String` | `getJavaExecutable()` Tries to get the full path to the Java Executable that we're running.
    `static void` | `initializeFile(java.lang.String aLogPath)` Initializes an empty file at the given path if it doesn't already exist.
    `static java.lang.String` | `joinStrings(java.lang.String delim, java.util.Collection<java.lang.String> strs)` Joins a collection of strings together separated by a delim in the middle.
    `static java.lang.String` | `joinStrings(java.lang.String delim, java.lang.String... strs)` Joins a list of strings together separated by a delim in the middle.
    `static weka.core.Instances` | `loadDataSource(java.io.InputStream stream)`
    `static void` | `makePath(java.lang.String basePath)` Makes folders along the specified path.
    `static void` | `parseCommandLineProperties(java.util.Properties props, java.util.List<java.lang.String> cmdLineArgs)` Looks for command line arguments of the form -prop PROPERTYSTRING and adds them to the given properties object
    `static void` | `parseCommandLineProperties(java.util.Properties props, java.lang.String[] cmdLineArgs)` Looks for command line arguments of the form -prop PROPERTYSTRING and adds them to the given properties object
    `static void` | `parsePropertyString(java.util.Properties props, java.lang.String propStr)` Given a property string (var1=val1:var2=val2:....) convert it to a property object.
    `static java.util.Properties` | `parsePropertyString(java.lang.String propStr)` Given a property string (var1=val1:var2=val2:....) convert it to a property object.
    `static java.lang.String` | `propertiesToString(java.util.Properties props)` Converts a Properties object to a property string, escaping ':' as needed
    `static java.util.List<java.lang.String>` | `quoteStrings(java.util.Collection<java.lang.String> oldStrs)` Looks for any strings that have spaces in them, and surrounds them with quotes.
    `static java.lang.String` | `removeExtension(java.lang.String s)` Removes the extension from a file name string.
    `static java.util.Map<java.lang.String,java.lang.String>` | `removeHidden(java.util.Map<java.lang.String,java.lang.String> inputMap)` Removes any arguments in the inputMap that happen to have a HIDDEN in their name.
    `static java.util.List<java.lang.String>` | `splitNestedString(java.lang.String params, java.lang.String delimStr, int numLeft, int numRight)` Splits a string, returning the string separated by the delimiter, with only the numLeft and numRight taken from the appropriate sides.
    `static java.util.List<java.lang.String>` | `splitQuotedString(java.lang.String str)` Splits a string based on spaces, grouping atoms if they are inside non escaped double quotes.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Util

          public Util()

  - ### Method Detail

    - #### parsePropertyString

          public static java.util.Properties parsePropertyString(java.lang.String propStr)

      Given a property string (var1=val1:var2=val2:....) convert it to a property object. Note that this honours escaped colons
      Parameters:
        `propStr` - The property string.
      Returns:
        The properties object.

    - #### parsePropertyString

          public static void parsePropertyString(java.util.Properties props,
                                                 java.lang.String propStr)

      Given a property string (var1=val1:var2=val2:....) convert it to a property object. Note that this honours escaped colons
      Parameters:
        `props` - The properties object.
        `propStr` - The property string.

    - #### propertiesToString

          public static java.lang.String propertiesToString(java.util.Properties props)

      Converts a Properties object to a property string, escaping ':' as needed
      Parameters:
        `props` - The properties object.
      Returns:
        The property string.

    - #### parseCommandLineProperties

          public static void parseCommandLineProperties(java.util.Properties props,
                                                        java.lang.String[] cmdLineArgs)

      Looks for command line arguments of the form -prop PROPERTYSTRING and adds them to the given properties object
      Parameters:
        `props` - The properties object.
        `cmdLineArgs` - The arguments.

    - #### parseCommandLineProperties

          public static void parseCommandLineProperties(java.util.Properties props,
                                                        java.util.List<java.lang.String> cmdLineArgs)

      Looks for command line arguments of the form -prop PROPERTYSTRING and adds them to the given properties object
      Parameters:
        `props` - The properties object.
        `cmdLineArgs` - The arguments.

    - #### initializeFile

          public static void initializeFile(java.lang.String aLogPath)

      Initializes an empty file at the given path if it doesn't already exist.
      Parameters:
        `aLogPath` - The path to the file.

    - #### makePath

          public static void makePath(java.lang.String basePath)

      Makes folders along the specified path.
      Parameters:
        `basePath` - The path.

    - #### getAbsoluteClasspath

          public static java.lang.String getAbsoluteClasspath()

    - #### getJavaExecutable

          public static java.lang.String getJavaExecutable()

      Tries to get the full path to the Java Executable that we're running.
      Returns:
        The string describing the path to the executable.

    - #### findExecutableOnPath

          public static java.io.File findExecutableOnPath(java.lang.String executableName)

      Tries to find the given executable on the path.
      Parameters:
        `executableName` - The executable to look for.
      Returns:
        The executable file.

    - #### expandEnvironmentVariable

          public static java.lang.String expandEnvironmentVariable(java.lang.String var)

      Tries to evaluate the environment variable into something useful. Note, this probably only works on posix systems now...
      Parameters:
        `var` - The environment variable to expand.
      Returns:
        The expanded environment variable.

    - #### expandPath

          public static java.lang.String expandPath(java.lang.String path)

      Tries to resolve any relative paths/symlinks on a given path.
      Parameters:
        `path` - Th path to expand.
      Returns:
        The expanded path.

    - #### cartesianProduct

          public static java.util.List<java.util.List<java.lang.String>> cartesianProduct(java.util.List<java.util.List<java.lang.String>> sets)

      Have a list of list of strings and need the Cartesian product? Look no further!
      Parameters:
        `sets` - The list of list of strings to compute the Cartesian product for.
      Returns:
        The Cartesian product.

    - #### argMapToString

          public static java.lang.String argMapToString(java.util.Map<java.lang.String,java.lang.String> argMap)

      Returns a string containing the arguments sorted by their name and joined together.
      Parameters:
        `argMap` - The map of arguments.
      Returns:
        The string representation of the arguments.

    - #### removeHidden

          public static java.util.Map<java.lang.String,java.lang.String> removeHidden(java.util.Map<java.lang.String,java.lang.String> inputMap)

      Removes any arguments in the inputMap that happen to have a HIDDEN in their name.
      Parameters:
        `inputMap` - The input map of arguments.
      Returns:
        The output map of arguments with hidden arguments removed.

    - #### removeExtension

          public static java.lang.String removeExtension(java.lang.String s)

      Removes the extension from a file name string.
      Parameters:
        `s` - The file name string.
      Returns:
        The file name string without extension.

    - #### joinStrings

          public static java.lang.String joinStrings(java.lang.String delim,
                                                     java.lang.String... strs)

      Joins a list of strings together separated by a delim in the middle.
      Parameters:
        `delim` - The delimiter used to join the strings.
        `strs` - The strings to join.
      Returns:
        The joined string.

    - #### joinStrings

          public static java.lang.String joinStrings(java.lang.String delim,
                                                     java.util.Collection<java.lang.String> strs)

      Joins a collection of strings together separated by a delim in the middle.
      Parameters:
        `delim` - The delimiter used to join the strings.
        `strs` - The strings to join.
      Returns:
        The joined string.

    - #### quoteStrings

          public static java.util.List<java.lang.String> quoteStrings(java.util.Collection<java.lang.String> oldStrs)

      Looks for any strings that have spaces in them, and surrounds them with quotes.
      Parameters:
        `oldStrs` - The strings with spaces to escape.
      Returns:
        The escaped strings.

    - #### splitNestedString

          public static java.util.List<java.lang.String> splitNestedString(java.lang.String params,
                                                                           java.lang.String delimStr,
                                                                           int numLeft,
                                                                           int numRight)

      Splits a string, returning the string separated by the delimiter, with only the numLeft and numRight taken from the appropriate sides.
      Parameters:
        `params` - The string to split.
        `delimStr` - The delimiter to split at.
        `numLeft` - Characters to the left to take.
        `numRight` - Characters to the right to take.
      Returns:
        The list of split strings.

    - #### createDummyInstances

          public static weka.core.Instances createDummyInstances(int numInstances,
                                                                 int numClasses,
                                                                 int numUsefulNumeric,
                                                                 int numUsefulCategorical,
                                                                 int numRandomNumeric,
                                                                 int numRandomCategorical,
                                                                 int randomCategoricalSize,
                                                                 int seed)

      Makes a simple real valued dataset of a given size, with the class determined by index
      Parameters:
        `numInstances` - The number of instances.
        `numClasses` - The number of classes.
        `numUsefulNumeric` - The number of correlated numeric attributes.
        `numUsefulCategorical` - The number of correlated categoric attributes.
        `numRandomNumeric` - The number of uncorrelated numeric attributes.
        `numRandomCategorical` - The number of uncorrelated categoric attributes.
        `randomCategoricalSize` - The number of categories in the uncorrelated categoric attributes.
        `seed` - The random seed.
      Returns:
        The instances.

    - #### getAutoWekaDistributionPath

          public static java.lang.String getAutoWekaDistributionPath()

    - #### splitQuotedString

          public static java.util.List<java.lang.String> splitQuotedString(java.lang.String str)

      Splits a string based on spaces, grouping atoms if they are inside non escaped double quotes.
      Parameters:
        `str` - The string to split.
      Returns:
        The list of split strings.

    - #### loadDataSource

          public static weka.core.Instances loadDataSource(java.io.InputStream stream)
                                                    throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### copyFile

          public static void copyFile(java.io.File sourceFile,
                                      java.io.File destFile)