Commit 77e30aa3 authored by Anders Nilsson's avatar Anders Nilsson
Browse files

Started added interface methods used from the SIARAS skillserver

parent e29eaa71
/*
* Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of OntologyCompiler.
*/
import AST.Start;
import AST.SiarasParser;
import AST.ParseException;
import java.io.*;
import java.net.URL;
public class Ontology extends Parser {
public static Start getAST(String ontologyURL) {
Start ast = null;
// String outfile = null;
// int i=0;
// for (i=0; i<args.length; i++) {
// if (args[i].equals("-o")) {
// outfile = args[++i];
// if (outfile.endsWith(".owl")) {
// outfile = outfile.substring(0,outfile.indexOf('.'));
// }
// }
// }
try {
Reader r = new StringReader((String)new URL(ontologyURL).getFile());
SiarasParser parser = new SiarasParser(r);
ast = parser.Start();
}
catch (ParseException e) {
System.out.println(e.getMessage());
}
// catch (FileNotFoundException e) {
// System.err.println("file " + ontologyURL + " not found");
// }
catch (IOException e) {
System.out.println(e.getMessage());
}
return ast;
// try {
// // Generate OWL ontology, possibly transformed from Owl
// // Full to OWL DL
// if (outfile == null) {
// outfile = "ontology";
// }
// PrintStream pStream = new PrintStream(new File(outfile+".owl"));
// ast.genOntology("",pStream);
// // have to create a matching repository file, otherwise
// // Protege will complain severely.
// pStream = new PrintStream(new File(outfile+".repository"));
// pStream.println("[Dublin Core DL Redirect]");
// } catch (java.io.FileNotFoundException e) {
// System.out.println("Could not create file: "+outfile);
// e.printStackTrace();
// }
}
}
/* -*-Java-*- */
/*
* Copyright (C) 2007 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of OntologyCompiler.
*/
aspect SkillserverInterface {
public Thing ASTNode.getIndividual(String id) {
System.out.println("foo");
for (int i=0; i<getNumChild(); i++) {
Thing t = getChild(i).getIndividual(id);
if (t!=null) {
return t;
}
}
return null;
}
public Thing Thing.getIndividual(String id) {
System.out.println("Looking for: "+id+" in: "+name());
if (id.equals(name())) {
return this;
} else {
return super.getIndividual(id);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment