String tmpStr;
Class cls;
CapabilitiesHandler handler;
boolean initialized;
StringTokenizer tok;
GenericPropertiesCreator creator;
Properties props;
m_Capabilities = new Capabilities(this);
initialized = false;
tmpStr = Utils.getOption('W', options);
if (tmpStr.length() != 0) {
cls = Class.forName(tmpStr);
if (ClassDiscovery.hasInterface(CapabilitiesHandler.class, cls)) {
initialized = true;
handler = (CapabilitiesHandler) cls.newInstance();
if (handler instanceof OptionHandler)
((OptionHandler) handler).setOptions(Utils.partitionOptions(options));
setHandler(handler);
}
else {
throw new IllegalArgumentException("Class '" + tmpStr + "' is not a CapabilitiesHandler!");
}
}
else {
tmpStr = Utils.getOption('c', options);
if (tmpStr.length() != 0)
setClassIndex(tmpStr);
else
setClassIndex("last");
tmpStr = Utils.getOption('t', options);
setFilename(tmpStr);
}
tmpStr = Utils.getOption("num-instances", options);
if (tmpStr.length() != 0)
m_Capabilities.setMinimumNumberInstances(Integer.parseInt(tmpStr));
else if (!initialized)
m_Capabilities.setMinimumNumberInstances(1);
// allowed
if (Utils.getFlag("no-class", options))
enable(Capability.NO_CLASS);
// not allowed
if (Utils.getFlag("not-no-class", options))
enableNot(Capability.NO_CLASS);
if (!m_Capabilities.handles(Capability.NO_CLASS)) {
// allowed
if (Utils.getFlag("nominal-class", options)) {
enable(Capability.NOMINAL_CLASS);
disable(Capability.BINARY_CLASS);
}
if (Utils.getFlag("binary-class", options)) {
enable(Capability.BINARY_CLASS);
disable(Capability.UNARY_CLASS);
}
if (Utils.getFlag("unary-class", options))
enable(Capability.UNARY_CLASS);
if (Utils.getFlag("numeric-class", options))
enable(Capability.NUMERIC_CLASS);
if (Utils.getFlag("string-class", options))
enable(Capability.STRING_CLASS);
if (Utils.getFlag("date-class", options))
enable(Capability.DATE_CLASS);
if (Utils.getFlag("relational-class", options))
enable(Capability.RELATIONAL_CLASS);
if (Utils.getFlag("missing-class-values", options))
enable(Capability.MISSING_CLASS_VALUES);
}
// not allowed
if (Utils.getFlag("not-nominal-class", options)) {
enableNot(Capability.NOMINAL_CLASS);
disableNot(Capability.BINARY_CLASS);
}
if (Utils.getFlag("not-binary-class", options)) {
enableNot(Capability.BINARY_CLASS);
disableNot(Capability.UNARY_CLASS);
}
if (Utils.getFlag("not-unary-class", options))
enableNot(Capability.UNARY_CLASS);
if (Utils.getFlag("not-numeric-class", options))
enableNot(Capability.NUMERIC_CLASS);
if (Utils.getFlag("not-string-class", options))
enableNot(Capability.STRING_CLASS);
if (Utils.getFlag("not-date-class", options))
enableNot(Capability.DATE_CLASS);
if (Utils.getFlag("not-relational-class", options))
enableNot(Capability.RELATIONAL_CLASS);
if (Utils.getFlag("not-relational-class", options))
enableNot(Capability.RELATIONAL_CLASS);
if (Utils.getFlag("not-missing-class-values", options))
enableNot(Capability.MISSING_CLASS_VALUES);
// allowed
if (Utils.getFlag("nominal-atts", options)) {
enable(Capability.NOMINAL_ATTRIBUTES);
disable(Capability.BINARY_ATTRIBUTES);
}
if (Utils.getFlag("binary-atts", options)) {
enable(Capability.BINARY_ATTRIBUTES);
disable(Capability.UNARY_ATTRIBUTES);
}
if (Utils.getFlag("unary-atts", options))
enable(Capability.UNARY_ATTRIBUTES);
if (Utils.getFlag("numeric-atts", options))
enable(Capability.NUMERIC_ATTRIBUTES);
if (Utils.getFlag("string-atts", options))
enable(Capability.STRING_ATTRIBUTES);
if (Utils.getFlag("date-atts", options))
enable(Capability.DATE_ATTRIBUTES);
if (Utils.getFlag("relational-atts", options))
enable(Capability.RELATIONAL_ATTRIBUTES);
if (Utils.getFlag("missing-att-values", options))
enable(Capability.MISSING_VALUES);
// not allowed
if (Utils.getFlag("not-nominal-atts", options)) {
enableNot(Capability.NOMINAL_ATTRIBUTES);
disableNot(Capability.BINARY_ATTRIBUTES);
}
if (Utils.getFlag("not-binary-atts", options)) {
enableNot(Capability.BINARY_ATTRIBUTES);
disableNot(Capability.UNARY_ATTRIBUTES);
}
if (Utils.getFlag("not-unary-atts", options))
enableNot(Capability.UNARY_ATTRIBUTES);
if (Utils.getFlag("not-numeric-atts", options))
enableNot(Capability.NUMERIC_ATTRIBUTES);
if (Utils.getFlag("not-string-atts", options))
enableNot(Capability.STRING_ATTRIBUTES);
if (Utils.getFlag("not-date-atts", options))
enableNot(Capability.DATE_ATTRIBUTES);
if (Utils.getFlag("not-relational-atts", options))
enableNot(Capability.RELATIONAL_ATTRIBUTES);
if (Utils.getFlag("not-missing-att-values", options))
enableNot(Capability.MISSING_VALUES);
if (Utils.getFlag("only-multiinstance", options))
enable(Capability.ONLY_MULTIINSTANCE);
tmpStr = Utils.getOption("superclass", options);
if (tmpStr.length() != 0)
m_Superclass = tmpStr;
else
throw new IllegalArgumentException("A superclass has to be specified!");
tmpStr = Utils.getOption("packages", options);
if (tmpStr.length() != 0) {
tok = new StringTokenizer(tmpStr, ",");
m_Packages = new Vector<String>();
while (tok.hasMoreTokens())
m_Packages.add(tok.nextToken());
}
if (Utils.getFlag("generic", options)) {
creator = new GenericPropertiesCreator();
creator.execute(false);
props = creator.getInputProperties();
tok = new StringTokenizer(props.getProperty(m_Superclass), ",");
m_Packages = new Vector<String>();
while (tok.hasMoreTokens())
m_Packages.add(tok.nextToken());
}