/* -*-Java-*- */ /* * Copyright (C) 2006,2010 Anders Nilsson * * This file is part of OntologyCompiler. * * OntologyCompiler is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * OntologyCompiler is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with OntologyCompiler. If not, see . */ import java.util.ArrayList; aspect Types { syn lazy Declaration Declaration.getSuperClass() = null; eq ClassDeclaration.getSuperClass() { return goStart().getSuperClass(name()); } syn Declaration ASTNode.getSuperClass(String name) = null; eq Start.getSuperClass(String name) = getSpecification().getSuperClass(name); eq Specification.getSuperClass(String name) { Declaration decl = getOntoDeclaration().getSuperClass(name); if (decl == null) { decl = findDecl("Thing"); if (decl == null) { decl = new ClassDeclaration(); Clazz c = new Clazz(); c.addAttribute(new IRI(new Value("Thing"))); decl.addElement(c); getOntoDeclaration().addElement(decl); } } return decl; } eq ComplexElement.getSuperClass(String name) { for (Element e : getElements()) { Declaration d = e.getSuperClass(name); if (d != null) { return d; } } return null; } eq SubClassOf.getSuperClass(String name) { if (getElement(0).name().equals(name)) { return goStart().findDecl(getElement(1).name()); } return null; } syn Declaration ASTNode.findDecl(String name) = null; eq Start.findDecl(String name) = getSpecification().findDecl(name); eq Specification.findDecl(String name) = getOntoDeclaration().findDecl(name); eq ComplexElement.findDecl(String name) { for (Element e : getElements()) { Declaration d = e.findDecl(name); if (d != null) { return d; } } return null; } eq ClassDeclaration.findDecl(String name) { if (name.equals(name())) { return this; } return null; } syn lazy OClass OClass.getSuperClass(); eq OwlClassDecl.getSuperClass() { for (int i=0; i