我正在使用OWL-S API(源代码和javadoc:http://on.cs.unibas.ch/owls-api/apidocs/)
如果我这样做,我会得到正确的结果:
public class Example {
private static ISWRLFactory factory; //is a interface
private string url = "http://...";
private Service aService;
private OWLOntology ont;
void method_A(){
URI aURI = URI.create(url);
OWLKnowledgeBase aKB = OWLFactory.createKB();
aService = aKB.readService(aURI);
ont = aKB.createOntology(aURI);
ont.createService(aService.getURI());
}
void method_B(){
factory = SWRLFactory.createFactory(ont);
Atom builtAtom = factory.createNotEqual(x, variab); //x and variab are two variable
}
}
但如果我这样做,我就没有正确的结果:
public class Example {
private static ISWRLFactory factory; //is a interface
private string url = "http://...";
private Service aService;
private OWLOntology ont;
void method_A(){
URI aURI = URI.create(url);
OWLKnowledgeBase aKB = OWLFactory.createKB();
aService = aKB.readService(aURI);
ont = aKB.createOntology(aURI);
ont.createService(aService.getURI());
factory = SWRLFactory.createFactory(ont);
}
void method_B(){
Atom builtAtom = factory.createNotEqual(x, variab); //x and variab are two variable
}
}
为什么?
答案 0 :(得分:0)
执行“factory = SWRLFactory.createFactory(ont);”时存在差异method_A()和method_B()中的行。 你确定在method_A()和method_B()调用之间没有修改'factory'对象吗? 'x'和'variable'是否依赖于'factory'?