public class ResourceUtils
extends java.lang.Object
Constructor and Description |
---|
ResourceUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
forName(java.lang.Class<?> classType,
java.lang.String className,
java.lang.String[] options)
Creates a new instance of an object given it's class name and (optional)
arguments to pass to it's setOptions method.
|
static java.io.File |
getWekaHome()
Returns the Weka home directory.
|
static java.util.Properties |
readProperties(java.lang.String resourceName)
Reads properties that inherit from three locations.
|
static java.util.Properties |
readProperties(java.lang.String resourceName,
java.lang.ClassLoader loader)
Reads properties that inherit from three locations.
|
public static java.lang.Object forName(java.lang.Class<?> classType, java.lang.String className, java.lang.String[] options) throws java.lang.Exception
String classifierName = Utils.getOption('W', options);
Classifier c = (Classifier)Utils.forName(Classifier.class,
classifierName,
options);
setClassifier(c);
classType
- the class that the instantiated object should be
assignable to -- an exception is thrown if this is not the caseclassName
- the fully qualified class name of the objectoptions
- an array of options suitable for passing to setOptions. May
be null. Any options accepted by the object will be removed from
the array.java.lang.Exception
- if the class name is invalid, or if the class is not
assignable to the desired class type, or the options supplied
are not acceptable to the objectpublic static java.util.Properties readProperties(java.lang.String resourceName) throws java.lang.Exception
resourceName
- the location of the resource that should be loaded.
e.g.: "weka/core/Utils.props". (The use of hardcoded forward
slashes here is OK - see jdk1.1/docs/guide/misc/resources.html)
This routine will also look for the file (in this case)
"Utils.props" in the users home directory and the current
directory.java.lang.Exception
- if no default properties are defined, or if an error
occurs reading the properties files.public static java.util.Properties readProperties(java.lang.String resourceName, java.lang.ClassLoader loader) throws java.lang.Exception
resourceName
- the location of the resource that should be loaded.
e.g.: "weka/core/Utils.props". (The use of hardcoded forward
slashes here is OK - see jdk1.1/docs/guide/misc/resources.html)
This routine will also look for the file (in this case)
"Utils.props" in the users home directory and the current
directory.loader
- the class loader to use when loading propertiesjava.lang.Exception
- if no default properties are defined, or if an error
occurs reading the properties files.public static java.io.File getWekaHome()