From 60ba0a4bc6ac424dce4f36638c006aca234c3997 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Sun, 16 Aug 2009 21:16:46 +0000
Subject: [PATCH] - implement the new Visitable interface - add the
 getFragmentAsLabel utility function

---
 .../exmo/align/onto/BasicOntology.java        | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/fr/inrialpes/exmo/align/onto/BasicOntology.java b/src/fr/inrialpes/exmo/align/onto/BasicOntology.java
index 1be683d1..57d23175 100644
--- a/src/fr/inrialpes/exmo/align/onto/BasicOntology.java
+++ b/src/fr/inrialpes/exmo/align/onto/BasicOntology.java
@@ -22,11 +22,15 @@ package fr.inrialpes.exmo.align.onto;
 
 import java.net.URI;
 
+import org.semanticweb.owl.align.AlignmentVisitor;
+import org.semanticweb.owl.align.AlignmentException;
+
 /**
  * Store the information regarding ontologies in a specific structure
  */
 
 public class BasicOntology<O> implements Ontology<O> {
+
     protected URI uri = null;
     protected URI file = null;
     protected URI formalismURI = null;
@@ -35,6 +39,10 @@ public class BasicOntology<O> implements Ontology<O> {
 
     public BasicOntology() {};
 
+    public void accept( AlignmentVisitor visitor) throws AlignmentException {
+        visitor.visit( this );
+    }
+
     public URI getURI() { return uri; }
     public URI getFile() { return file; }
     public URI getFormURI() { return formalismURI; }
@@ -46,4 +54,17 @@ public class BasicOntology<O> implements Ontology<O> {
     public void setFormURI( URI u ) { formalismURI = u; }
     public void setFormalism( String name ) { formalism = name; }
     public void setOntology( O o ) { this.onto = o; }
+
+    public String getFragmentAsLabel( URI u ){
+	String result = u.getFragment();
+	if ( result == null ) {
+	    String suri = u.toString();
+	    int end = suri.length()-1;
+	    if ( suri.charAt(end) == '/' ) end--;
+	    int start = end-1;
+	    for ( ; suri.charAt( start ) != '/' && start != 0 ; start-- );
+	    result = suri.substring( start+1, end+1 );
+	}
+	return result;
+    }
 }
-- 
GitLab