autoweka
Class Util

java.lang.Object
  extended by 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
static class Util.NullPrintStream
          Utility to class to make a void print stream
static class Util.ProcessKillerShutdownHook
           
 
Constructor Summary
Util()
           
 
Method Summary
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 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()
          Tries to get the current classpath of the running JVM and build a classpath that removes all relative paths
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 java.lang.String joinStrings(java.lang.String delim, java.util.Collection<java.lang.String> strs)
          Joins a collection of strings together sepeated 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 sepeated by a delim in the middle
static 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)
          Gets the basename of a file
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


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


propertiesToString

public static java.lang.String propertiesToString(java.util.Properties props)
Converts a Properties object to a property string, escaping ':' as needed


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


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


makePath

public static void makePath(java.lang.String basePath)
Makes folders along the specified path


getAbsoluteClasspath

public static java.lang.String getAbsoluteClasspath()
Tries to get the current classpath of the running JVM and build a classpath that removes all relative paths


getJavaExecutable

public static java.lang.String getJavaExecutable()
Tries to get the full path to the Java Executable that we're running


findExecutableOnPath

public static java.io.File findExecutableOnPath(java.lang.String executableName)
Tries to find the given executable on the path


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...


expandPath

public static java.lang.String expandPath(java.lang.String path)
Tries to resolve any relative paths/symlinks on a given 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!


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


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


removeExtension

public static java.lang.String removeExtension(java.lang.String s)
Gets the basename of a file


joinStrings

public static java.lang.String joinStrings(java.lang.String delim,
                                           java.lang.String... strs)
Joins a list of strings together sepeated by a delim in the middle


joinStrings

public static java.lang.String joinStrings(java.lang.String delim,
                                           java.util.Collection<java.lang.String> strs)
Joins a collection of strings together sepeated by a delim in the middle


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


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


createDummyInstances

public static 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


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.


loadDataSource

public static 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)