From 9ecfcce03ce099a2f6df28fd5b666a213eb5e5d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Sun, 19 Oct 2008 15:20:20 +0000
Subject: [PATCH] - improved the interface and corrected some bugs while
 creating tests

---
 .../exmo/align/onto/HeavyLoadedOntology.java       |  4 ++--
 .../inrialpes/exmo/align/onto/LoadedOntology.java  |  3 ++-
 src/fr/inrialpes/exmo/align/onto/Ontology.java     |  2 --
 .../inrialpes/exmo/align/onto/OntologyFactory.java |  1 -
 .../exmo/align/onto/jena25/JENAOntology.java       |  6 +++++-
 .../exmo/align/onto/owlapi10/OWLAPIOntology.java   | 14 ++++++++++----
 6 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/fr/inrialpes/exmo/align/onto/HeavyLoadedOntology.java b/src/fr/inrialpes/exmo/align/onto/HeavyLoadedOntology.java
index f750fe0a..a57dfbab 100644
--- a/src/fr/inrialpes/exmo/align/onto/HeavyLoadedOntology.java
+++ b/src/fr/inrialpes/exmo/align/onto/HeavyLoadedOntology.java
@@ -47,8 +47,8 @@ public interface HeavyLoadedOntology<O> extends LoadedOntology<O> {
     /* Property methods */
     public Set<Object> getSubProperties( Object p, int local, int asserted, int named );
     public Set<Object> getSuperProperties( Object p, int local, int asserted, int named );
-    public Set<Object> getRange( Object p, boolean asserted );
-    public Set<Object> getDomain( Object p, boolean asserted );
+    public Set<Object> getRange( Object p, int asserted );
+    public Set<Object> getDomain( Object p, int asserted );
 
     /* Individual methods */
     public Set<Object> getClasses( Object i, int local, int asserted, int named );
diff --git a/src/fr/inrialpes/exmo/align/onto/LoadedOntology.java b/src/fr/inrialpes/exmo/align/onto/LoadedOntology.java
index 6a690aa9..2c7b153a 100644
--- a/src/fr/inrialpes/exmo/align/onto/LoadedOntology.java
+++ b/src/fr/inrialpes/exmo/align/onto/LoadedOntology.java
@@ -52,11 +52,12 @@ public interface LoadedOntology<O> extends Ontology<O> {
     public Set<?> getDataProperties();
     public Set<?> getIndividuals();
 
+    public int nbEntities();
     public int nbClasses();
     public int nbProperties();
     public int nbDataProperties();
     public int nbObjectProperties();
-    public int nbInstances();
+    public int nbIndividuals();
 
     public void unload();
 }
diff --git a/src/fr/inrialpes/exmo/align/onto/Ontology.java b/src/fr/inrialpes/exmo/align/onto/Ontology.java
index b6faee03..e5197635 100644
--- a/src/fr/inrialpes/exmo/align/onto/Ontology.java
+++ b/src/fr/inrialpes/exmo/align/onto/Ontology.java
@@ -21,8 +21,6 @@
 package fr.inrialpes.exmo.align.onto;
 
 import java.net.URI;
-import java.util.Set;
-
 
 public interface Ontology<O> {
 
diff --git a/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java b/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java
index 4548e3d9..f0e4e591 100644
--- a/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java
+++ b/src/fr/inrialpes/exmo/align/onto/OntologyFactory.java
@@ -43,7 +43,6 @@ public abstract class OntologyFactory {
     public static int MENTIONNED = 11;
     public static int ALL = 12;
 
-    //protected static OntologyFactory instance = null;
     protected static Hashtable<String,OntologyFactory> instances = null;
 
     private static String API_NAME="fr.inrialpes.exmo.align.onto.owlapi10.OWLAPIOntologyFactory";
diff --git a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java
index fedbb7f7..f68b6790 100644
--- a/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java
+++ b/src/fr/inrialpes/exmo/align/onto/jena25/JENAOntology.java
@@ -178,6 +178,10 @@ public class JENAOntology extends BasicOntology<OntModel> implements LoadedOntol
 	return o instanceof OntProperty;
     }
 
+    public int nbEntities() {
+	return this.getEntities().size();
+    }
+
     public int nbClasses() {
 	return this.getClasses().size();
     }
@@ -186,7 +190,7 @@ public class JENAOntology extends BasicOntology<OntModel> implements LoadedOntol
 	return this.getDataProperties().size();
     }
 
-    public int nbInstances() {
+    public int nbIndividuals() {
 	return this.getIndividuals().size();
     }
 
diff --git a/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java b/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java
index f53a649f..05af7d13 100644
--- a/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java
+++ b/src/fr/inrialpes/exmo/align/onto/owlapi10/OWLAPIOntology.java
@@ -306,6 +306,12 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL
 	}
     }
 
+    public int nbEntities() {
+	if ( nbentities != -1 ) return nbentities;
+	nbentities = nbClasses()+nbProperties()+nbIndividuals();
+	return nbentities;
+    }
+
     public int nbClasses() {
 	if ( nbclasses != -1 ) return nbclasses;
 	try {
@@ -342,7 +348,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL
 	}
     }
 
-    public int nbInstances() {
+    public int nbIndividuals() {
 	if ( nbindividuals != -1 ) return nbindividuals;
 	try {
 	    nbindividuals = ((OWLOntology)onto).getIndividuals().size();
@@ -408,7 +414,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL
 	    try {
 		for ( Object ent : ((OWLClass)cl).getSuperClasses( getOntology() ) ){
 		    if ( ent instanceof OWLRestriction ) 
-			prop.add( ((OWLRestriction)cl).getProperty() );
+			prop.add( ((OWLRestriction)ent).getProperty() );
 		}
 	    } catch (OWLException e) { e.printStackTrace(); }
 	} else {
@@ -474,7 +480,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL
 	}
 	return supers;
     }
-    public Set<Object> getRange( Object p, boolean asserted ){
+    public Set<Object> getRange( Object p, int asserted ){
 	Set resultSet = new HashSet(); 
 	try {
 	    for ( Object ent : ((OWLProperty)p).getRanges( getOntology() ) ){
@@ -487,7 +493,7 @@ public class OWLAPIOntology extends BasicOntology<OWLOntology> implements HeavyL
 	} catch (OWLException ex) {};
 	return resultSet;
     }
-    public Set<Object> getDomain( Object p, boolean asserted ){
+    public Set<Object> getDomain( Object p, int asserted ){
 	Set resultSet = new HashSet(); 
 	try {
 	    for ( Object ent : ((OWLProperty)p).getDomains( getOntology() ) ){
-- 
GitLab