/** * Creates a new instance of a kernel given it's class name and (optional) * arguments to pass to it's setOptions method. * * @param kernelName the fully qualified class name of the classifier * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created classifier, ready for use. * @throws Exception if the classifier name is invalid, or the options * supplied are not acceptable to the classifier */ public static Kernel forName(String kernelName, String[] options) throws Exception { return (Kernel) Utils.forName(Kernel.class, kernelName, options); } }
/** * Creates a new instance of a clusterer given it's class name and (optional) * arguments to pass to it's setOptions method. If the clusterer implements * OptionHandler and the options parameter is non-null, the clusterer will * have it's options set. * * @param clustererName the fully qualified class name of the clusterer * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created search object, ready for use. * @exception Exception if the clusterer class name is invalid, or the options * supplied are not acceptable to the clusterer. */ public static Clusterer forName(String clustererName, String[] options) throws Exception { return (Clusterer) Utils.forName(Clusterer.class, clustererName, options); }
/** * Creates a new instance of a kernel given it's class name and (optional) * arguments to pass to it's setOptions method. * * @param kernelName the fully qualified class name of the classifier * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created classifier, ready for use. * @throws Exception if the classifier name is invalid, or the options * supplied are not acceptable to the classifier */ public static Kernel forName(String kernelName, String[] options) throws Exception { return (Kernel) Utils.forName(Kernel.class, kernelName, options); } }
/** * Creates a new instance of a associator given it's class name and (optional) * arguments to pass to it's setOptions method. If the associator implements * OptionHandler and the options parameter is non-null, the associator will * have it's options set. * * @param associatorName the fully qualified class name of the associator * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created associator, ready for use. * @exception Exception if the associator name is invalid, or the options * supplied are not acceptable to the associator */ public static Associator forName(String associatorName, String[] options) throws Exception { return (Associator) Utils.forName(Associator.class, associatorName, options); }
/** * Creates a new instance of a estimatorr given it's class name and (optional) * arguments to pass to it's setOptions method. If the estimator implements * OptionHandler and the options parameter is non-null, the estimator will * have it's options set. * * @param name the fully qualified class name of the estimatorr * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created estimator, ready for use. * @exception Exception if the estimator name is invalid, or the options * supplied are not acceptable to the estimator */ public static Estimator forName(String name, String[] options) throws Exception { return (Estimator) Utils.forName(Estimator.class, name, options); }
/** * Creates a new instance of a clusterer given it's class name and (optional) * arguments to pass to it's setOptions method. If the clusterer implements * OptionHandler and the options parameter is non-null, the clusterer will * have it's options set. * * @param clustererName the fully qualified class name of the clusterer * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created search object, ready for use. * @exception Exception if the clusterer class name is invalid, or the options * supplied are not acceptable to the clusterer. */ public static Clusterer forName(String clustererName, String[] options) throws Exception { return (Clusterer) Utils.forName(Clusterer.class, clustererName, options); }
/** * Creates a new instance of a classifier given it's class name and (optional) * arguments to pass to it's setOptions method. If the classifier implements * OptionHandler and the options parameter is non-null, the classifier will * have it's options set. * * @param classifierName the fully qualified class name of the classifier * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created classifier, ready for use. * @exception Exception if the classifier name is invalid, or the options * supplied are not acceptable to the classifier */ public static Classifier forName(String classifierName, String[] options) throws Exception { return ((AbstractClassifier) Utils.forName(Classifier.class, classifierName, options)); }
/** * Creates a new instance of an attribute/subset evaluator given it's class * name and (optional) arguments to pass to it's setOptions method. If the * evaluator implements OptionHandler and the options parameter is non-null, * the evaluator will have it's options set. * * @param evaluatorName the fully qualified class name of the evaluator * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created evaluator, ready for use. * @exception Exception if the evaluator name is invalid, or the options * supplied are not acceptable to the evaluator */ public static ASEvaluation forName(String evaluatorName, String[] options) throws Exception { return (ASEvaluation) Utils.forName(ASEvaluation.class, evaluatorName, options); }
/** * Creates a new instance of an attribute/subset evaluator given it's class * name and (optional) arguments to pass to it's setOptions method. If the * evaluator implements OptionHandler and the options parameter is non-null, * the evaluator will have it's options set. * * @param evaluatorName the fully qualified class name of the evaluator * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created evaluator, ready for use. * @exception Exception if the evaluator name is invalid, or the options * supplied are not acceptable to the evaluator */ public static ASEvaluation forName(String evaluatorName, String[] options) throws Exception { return (ASEvaluation) Utils.forName(ASEvaluation.class, evaluatorName, options); }
/** * Creates a new instance of a classifier given it's class name and (optional) * arguments to pass to it's setOptions method. If the classifier implements * OptionHandler and the options parameter is non-null, the classifier will * have it's options set. * * @param classifierName the fully qualified class name of the classifier * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created classifier, ready for use. * @exception Exception if the classifier name is invalid, or the options * supplied are not acceptable to the classifier */ public static Classifier forName(String classifierName, String[] options) throws Exception { return ((AbstractClassifier) Utils.forName(Classifier.class, classifierName, options)); }
/** * Creates a new instance of a estimatorr given it's class name and (optional) * arguments to pass to it's setOptions method. If the estimator implements * OptionHandler and the options parameter is non-null, the estimator will * have it's options set. * * @param name the fully qualified class name of the estimatorr * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created estimator, ready for use. * @exception Exception if the estimator name is invalid, or the options * supplied are not acceptable to the estimator */ public static Estimator forName(String name, String[] options) throws Exception { return (Estimator) Utils.forName(Estimator.class, name, options); }
/** * Creates a new instance of a associator given it's class name and (optional) * arguments to pass to it's setOptions method. If the associator implements * OptionHandler and the options parameter is non-null, the associator will * have it's options set. * * @param associatorName the fully qualified class name of the associator * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created associator, ready for use. * @exception Exception if the associator name is invalid, or the options * supplied are not acceptable to the associator */ public static Associator forName(String associatorName, String[] options) throws Exception { return (Associator) Utils.forName(Associator.class, associatorName, options); }
/** * Creates a new instance of a search class given it's class name and * (optional) arguments to pass to it's setOptions method. If the * search method implements OptionHandler and the options parameter is * non-null, the search method will have it's options set. * * @param searchName the fully qualified class name of the search class * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created search object, ready for use. * @throws Exception if the search class name is invalid, or the options * supplied are not acceptable to the search class. */ public static ASSearch forName(String searchName, String [] options) throws Exception { return (ASSearch)Utils.forName(ASSearch.class, searchName, options); }
/** * Creates a new instance of a search class given it's class name and * (optional) arguments to pass to it's setOptions method. If the * search method implements OptionHandler and the options parameter is * non-null, the search method will have it's options set. * * @param searchName the fully qualified class name of the search class * @param options an array of options suitable for passing to setOptions. May * be null. * @return the newly created search object, ready for use. * @throws Exception if the search class name is invalid, or the options * supplied are not acceptable to the search class. */ public static ASSearch forName(String searchName, String [] options) throws Exception { return (ASSearch)Utils.forName(ASSearch.class, searchName, options); }
public void initialiseClassifier(String classifierName, String parameters[]) { this.parameters = parameters; // create classifier try { this.classifier = (Classifier) Utils.forName(Classifier.class, classifierName, parameters); } catch (Exception e) { e.printStackTrace(); } }
/** * Turns a commandline into an object. * * @param cls the class that the commandline is expected to be * @param cmdline the commandline to parse * @return the object, null if failed to instantiate * @throws Exception if parsing fails */ public static <T> T fromCommandLine(Class<T> cls, String cmdline) throws Exception { String[] options; String classname; options = Utils.splitOptions(cmdline); classname = options[0]; options[0] = ""; return (T) Utils.forName(cls, classname, options); }
/** * Turns a commandline into an object. * * @param cls the class that the commandline is expected to be * @param cmdline the commandline to parse * @return the object, null if failed to instantiate * @throws Exception if parsing fails */ public static <T> T fromCommandLine(Class<T> cls, String cmdline) throws Exception { String[] options; String classname; options = Utils.splitOptions(cmdline); classname = options[0]; options[0] = ""; return (T) Utils.forName(cls, classname, options); }
/** * Construct an instance of an option handler from a String specifying its * class name and option values * * @param optionValue a String containing the class of the option handler * followed by its options * @return an instantiated option handling object * @throws Exception if a problem occurs */ protected static Object constructOptionHandlerValue(String optionValue) throws Exception { String[] optHandlerSpec = Utils.splitOptions(optionValue); if (optHandlerSpec.length == 0) { throw new Exception("Invalid option handler specification " + "string '" + optionValue); } String optionHandler = optHandlerSpec[0]; optHandlerSpec[0] = ""; Object handler = Utils.forName(null, optionHandler, optHandlerSpec); return handler; }
/** * generates the options string. * * @return the options string * @throws Exception in case the generation fails */ public String generate() throws Exception { StringBuffer result; OptionHandler handler; Enumeration<Option> enm; Option option; result = new StringBuffer(); handler = (OptionHandler) Utils.forName(null, getClassname(), new String[0]); enm = handler.listOptions(); while (enm.hasMoreElements()) { option = enm.nextElement(); result.append(option.synopsis() + '\n'); result.append(option.description() + "\n"); } return result.toString(); }
/** * Performs the actual initialization of the filters. */ @Override protected void doInitializeFilters() { List<String> filters = PluginManager.getPluginNamesOfTypeList(FileBasedEvaluationStatisticsExporter.class .getName()); m_FileFilters = new ArrayList<>(); for (String filter: filters) { try { FileBasedEvaluationStatisticsExporter handler = (FileBasedEvaluationStatisticsExporter) Utils.forName( FileBasedEvaluationStatisticsExporter.class, filter, new String[0]); m_FileFilters.add(new ExtensionFileFilterWithClass( handler.getFormatExtensions(), handler.getFormatDescription() + " (" + ObjectUtils.flatten(handler.getFormatExtensions(), ", ") + ")", filter)); } catch (Exception e) { System.err.println("Failed to instantiate file filter: " + filter); e.printStackTrace(); } } }