[MOBY-guts] biomoby commit

Gary Schiltz gss at pub.open-bio.org
Thu Oct 6 17:59:43 UTC 2005


gss
Thu Oct  6 13:59:43 EDT 2005
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/tools
In directory pub.open-bio.org:/tmp/cvs-serv9695/src/org/semanticmoby/tools

Modified Files:
	Util.java 
Log Message:
Added reachableStatements() method

moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/tools Util.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/tools/Util.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/tools/Util.java	2004/11/23 00:18:46	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/tools/Util.java	2005/10/06 17:59:43	1.2
@@ -43,6 +43,12 @@
     	return model;
     }
     
+    public static Model reachableStmts(Model source, Resource subject, String uri) {
+        Model newModel = newJenaModel();
+        addReachableStmts(source, newModel, subject, uri);
+        return newModel;
+    }
+    
 	public static void addReachableStmts(
 		Model source, Model dest, Resource subject, String uri)
 	{
@@ -60,7 +66,7 @@
 			dest.add(dest.createStatement(
 				stmt.getSubject(), stmt.getPredicate(), stmt.getObject()));
 			
-			// If the object of the statement is a blank node or a
+			// If the object of the statement is a blank node, or a
 			// resource whose URI starts with the provider URI, then
 			// recursively add the statements that are reachable
 			// from the object
@@ -68,7 +74,10 @@
 			if (stmt.getObject().canAs(Resource.class))
 			{
 				Resource object = (Resource) stmt.getObject().as(Resource.class);
-				if (object.isAnon() || (uri != null && object.getURI().startsWith(uri))) {
+				if ((object.isAnon()) ||
+                    (uri == null) ||
+                    (object.getURI().startsWith(uri)))
+                {
 					addReachableStmts(source, dest, object, uri);
 				}
 			}




More information about the MOBY-guts mailing list