import java.util.*; import java.io.*; /** A class the represents a bare-bones OWL ontology. Essentially, the architecture is * frame/slot approach similar to the underlying model of Protege. In this case, each * "frame" is an OwlClass object and each "slot" is an OwlProperty object. * Note, to ensure compatibility with older versions of Java, the various data structures * are not parameterized.*/ public class OwlOnt{ /** A data structure that contain objects for each class in the ontology, allowing efficient lookup by URI of the class. */ protected Hashtable classes; public OwlOnt() { classes = new Hashtable(); } /** Returns an array of all classes defined in the ontology. */ public OwlClass[] getClasses() { OwlClass[] classArray; OwlClass nextClass; int i = 0; classArray = new OwlClass[classes.size()]; Enumeration classEnum = classes.elements(); while (classEnum.hasMoreElements()) { nextClass = (OwlClass)classEnum.nextElement(); classArray[i] = nextClass; i = i +1; } return classArray; } /** Given the URI of a class, returns an object that represents it. If there is no class with that ID, returns null. */ public OwlClass getClass(String classId) { Object lookup; lookup = classes.get(classId); if (lookup == null) return null; else return (OwlClass)lookup; } /** Returns true if the child class is a subclass of the parent, either directly or through the transitivity of subClassOf. */ public boolean isSubClassOf(String childId, String parentId) { // ***** YOU NEED TO WRITE THIS METHOD!!! ***** return false; // temporary return value so that program compiles } /** Reads an ontology from the given reader, parses it, and creates new OwlClass objects representing its contents.*/ public void parseOntology(InputStream in) { // ***** YOU NEED TO WRITE THIS METHOD!!! ***** } /** Adds a class to the ontology. Inserts it into the classes hashtable with its id as a key. */ protected void addClass(OwlClass newClass) { String classId; classId = newClass.getId(); classes.put(classId,newClass); newClass.setOntology(this); } }