我正在使用 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
}
}
为什么?
最佳答案
执行“factory = SWRLFactory.createFactory(ont);”时存在差异method_A() 和 method_B() 中的行。 您确定“工厂”对象在 method_A() 和 method_B() 调用之间没有被修改吗? “x”和“变量”对“工厂”有一定的依赖性吗?
关于Java 引用不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20225269/