[MOBY-guts] biomoby commit

Gary Schlitz gss at pub.open-bio.org
Thu Jul 29 23:33:59 UTC 2004


gss
Thu Jul 29 19:33:59 EDT 2004
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph
In directory pub.open-bio.org:/tmp/cvs-serv20716/src/org/smoby/graph

Modified Files:
	MOBYDocument.java MOBYLiteral.java MOBYResource.java 
	MOBYFixedCollection.java MOBYResizableCollection.java 
	MOBYSingleElement.java MOBYPropertyValueConstraint.java 
	MOBYPropertyValueStatement.java MOBYEnumeration.java 
	MOBYProvider.java MOBYPropertyValue.java MOBYOntology.java 
	MOBYProviderSet.java MOBYMappingElement.java 
	MOBYDescriptor.java MOBYOrderedCollection.java 
	MOBYCollection.java MOBYUnorderedCollection.java 
	MOBYGraph.java MOBYGraphNode.java MOBYObject.java 
	MOBYSubject.java MOBYPropertyValueException.java 
Added Files:
	MOBYIntegerConstraint.java MOBYDateConstraint.java 
	MOBYNonNegativeIntegerConstraint.java 
	MOBYNumericConstraint.java 
	MOBYNonPositiveIntegerConstraint.java 
Log Message:
No longer separate graph interfaces from classes

moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph MOBYIntegerConstraint.java,NONE,1.1 MOBYDateConstraint.java,NONE,1.1 MOBYNonNegativeIntegerConstraint.java,NONE,1.1 MOBYNumericConstraint.java,NONE,1.1 MOBYNonPositiveIntegerConstraint.java,NONE,1.1 MOBYDocument.java,1.1,1.2 MOBYLiteral.java,1.1,1.2 MOBYResource.java,1.1,1.2 MOBYFixedCollection.java,1.1,1.2 MOBYResizableCollection.java,1.1,1.2 MOBYSingleElement.java,1.1,1.2 MOBYPropertyValueConstraint.java,1.1,1.2 MOBYPropertyValueStatement.java,1.1,1.2 MOBYEnumeration.java,1.1,1.2 MOBYProvider.java,1.1,1.2 MOBYPropertyValue.java,1.1,1.2 MOBYOntology.java,1.1,1.2 MOBYProviderSet.java,1.1,1.2 MOBYMappingElement.java,1.1,1.2 MOBYDescriptor.java,1.2,1.3 MOBYOrderedCollection.java,1.1,1.2 MOBYCollection.java,1.1,1.2 MOBYUnorderedCollection.java,1.1,1.2 MOBYGraph.java,1.1,1.2 MOBYGraphNode.java,1.1,1.2 MOBYObject.java,1.1,1.2 MOBYSubject.java,1.1,1.2 MOBYPropertyValueException.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYDocument.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/smoby/graph/MOBYDocument.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYDocument.java	2004/07/29 23:33:59	1.2
@@ -1,9 +1,15 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
- * This interface represents a document to be incorporated into
+ * This class represents a document to be incorporated into
  * the S-MOBY metadata repository.
  */
-public interface MOBYDocument extends MOBYDescriptor
+public abstract class MOBYDocument extends MOBYDescriptor
 {
+    public MOBYDocument(Resource resource, Model underlying)
+    {
+        super(resource, underlying);
+    }
 }

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYLiteral.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/smoby/graph/MOBYLiteral.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYLiteral.java	2004/07/29 23:33:59	1.2
@@ -1,7 +1,24 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.Literal;
 
-public interface MOBYLiteral extends MOBYPropertyValue
+public class MOBYLiteral extends MOBYPropertyValue
 {
-    public String getStringValue();
-}
\ No newline at end of file
+    private String stringValue;
+    
+    public MOBYLiteral(String stringValue) {
+        this.stringValue = stringValue;
+    }
+    
+    public String getStringValue() {
+        return stringValue;
+    }
+    
+    public boolean isLiteral() {
+        return true;
+    }
+
+    public boolean isResource() {
+        return false;
+    }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYResource.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/smoby/graph/MOBYResource.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYResource.java	2004/07/29 23:33:59	1.2
@@ -1,8 +1,29 @@
 package org.smoby.graph;
 
+import org.smoby.graph.*;
+import com.hp.hpl.jena.rdf.model.*;
 
-public interface MOBYResource extends MOBYPropertyValue
+public class MOBYResource extends MOBYPropertyValue
 {
-    public String getResourceURI();
-    public boolean isBlank();
+    private Resource resourceValue;
+    
+    public MOBYResource(Resource resourceValue) {
+        this.resourceValue = resourceValue;
+    }
+    
+    public String getResourceURI() {
+        return resourceValue.getURI();
+    }
+    
+    public boolean isLiteral() {
+        return false;
+    }
+
+    public boolean isResource() {
+        return true;
+    }
+    
+    public boolean isBlank() {
+        return resourceValue.isAnon();
+    }
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYFixedCollection.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/smoby/graph/MOBYFixedCollection.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYFixedCollection.java	2004/07/29 23:33:59	1.2
@@ -1,9 +1,20 @@
 package org.smoby.graph;
 
+import java.util.*;
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
- * An interface representing unordered, fixed sized collection
+ * A class representing unordered, fixed sized collection
  * of objects.
  */
-public interface MOBYFixedCollection extends MOBYCollection
+public class MOBYFixedCollection extends MOBYCollection
 {
-}
\ No newline at end of file
+    
+    public MOBYFixedCollection(Resource resource, List elements, Model underlying)
+    {
+        super(resource, elements, underlying);
+    }
+
+    public boolean isResizable() { return false; }
+    public boolean isFixedSized() { return true; }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYResizableCollection.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/smoby/graph/MOBYResizableCollection.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYResizableCollection.java	2004/07/29 23:33:59	1.2
@@ -1,14 +1,29 @@
 package org.smoby.graph;
 
+import java.util.*;
+
+import org.smoby.graph.*;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
+
 /**
- * An interface representing collections that can be resized (i.e.
+ * A class representing collections that can be resized (i.e.
  * elements added to or removed from); such collections can be
  * either ordered or unordered.
  */
-public interface MOBYResizableCollection extends MOBYCollection
+public abstract class MOBYResizableCollection extends MOBYCollection
 {
+	public MOBYResizableCollection(Resource resource, List elements, Model underlying)
+    {
+        super(resource, elements, underlying);
+    }
+
     /**
      * Return whether or not this collection is ordered.
      */
-    public boolean isOrdered();
-}
\ No newline at end of file
+    public abstract boolean isOrdered();
+    
+    public boolean isResizable() { return true; }
+    public boolean isFixedSized() { return false; }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYSingleElement.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/smoby/graph/MOBYSingleElement.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYSingleElement.java	2004/07/29 23:33:59	1.2
@@ -1,9 +1,23 @@
 package org.smoby.graph;
 
+import java.net.URI;
+
+import org.smoby.graph.*;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
+
 /**
- * An interface to represent singular objects, i.e. those that are
+ * A class to represent singular objects, i.e. those that are
  * not collections.
  */
-public interface MOBYSingleElement extends MOBYGraphNode
+public abstract class MOBYSingleElement extends MOBYGraphNode
 {
-}
+	public MOBYSingleElement(Resource resource, Model underlying)
+    {
+        super(resource, underlying);
+    }
+    
+    public boolean isSingular() { return true; }
+    public boolean isCollection() { return false; }
+}
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValueConstraint.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/smoby/graph/MOBYPropertyValueConstraint.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValueConstraint.java	2004/07/29 23:33:59	1.2
@@ -1,8 +1,9 @@
 package org.smoby.graph;
 
-public interface MOBYPropertyValueConstraint
+public abstract class MOBYPropertyValueConstraint
 {
-    public void validatePropertyValue(MOBYPropertyValueStatement stmt,
-                                      MOBYPropertyValue newValue)
+    public abstract void validatePropertyValue(
+    		MOBYPropertyValueStatement stmt,
+            MOBYPropertyValue newValue)
     	throws MOBYPropertyValueException;
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValueStatement.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/smoby/graph/MOBYPropertyValueStatement.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValueStatement.java	2004/07/29 23:33:59	1.2
@@ -1,28 +1,76 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
 
-public interface MOBYPropertyValueStatement
+public class MOBYPropertyValueStatement extends MOBYDescriptor
 {
+    private Statement jenaStatement;
+    private MOBYPropertyValue currentValue;
+    private MOBYPropertyValueConstraint constraint;
+    
+    public MOBYPropertyValueStatement(Statement jenaStatement,
+    		                              Model underlying) {
+        super(null, underlying);
+        this.jenaStatement = jenaStatement;
+        if (jenaStatement.getObject().canAs(Resource.class)) {
+            Resource value = (Resource) jenaStatement.getObject();
+            currentValue = new MOBYResource(value);
+        } else {
+            Literal value = (Literal) jenaStatement.getObject();
+            currentValue = new MOBYLiteral(value.getString());
+        }
+    }
+
     /**
      * Return the name of this property
      */
-    public String getPropertyName();
+    public String getPropertyName() {
+        return jenaStatement.getPredicate().getURI();
+    }
     
+    public String toString() {
+        return jenaStatement.toString();
+    }
+
     /**
      * Return the value currently associated with this property
      */
-    public MOBYPropertyValue getValue();
-    
+    public MOBYPropertyValue getValue() {
+        return currentValue;
+    }
+
     /**
      * Set the property value. This is just a placeholder; values of
      * different property types will be set to different types of
      * values.
      */
     public void setPropertyValue(MOBYPropertyValue newValue)
-    	throws MOBYPropertyValueException;
-    
+    	throws MOBYPropertyValueException
+    {
+        if (constraint != null) {
+            constraint.validatePropertyValue(this, newValue);
+        }
+        
+        if (newValue.isLiteral()) {
+            MOBYLiteral literal = (MOBYLiteral) newValue;
+            jenaStatement.changeObject(literal.getStringValue());
+        } else {
+            MOBYResource resource = (MOBYResource) newValue;
+            if (resource.isBlank()) {
+	            jenaStatement.changeObject(
+	                jenaStatement.getModel().createResource());
+            } else {
+	            jenaStatement.changeObject(
+		            jenaStatement.getModel().createResource(
+		                resource.getResourceURI()));
+            }
+        }
+    }
+
     /**
      * Set the given constraint for this property value statement
      */
-    public void setConstraint(MOBYPropertyValueConstraint constraint);
-}
\ No newline at end of file
+    public void setConstraint(MOBYPropertyValueConstraint constraint) {
+        this.constraint = constraint;
+    }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYEnumeration.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/smoby/graph/MOBYEnumeration.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYEnumeration.java	2004/07/29 23:33:59	1.2
@@ -1,10 +1,19 @@
 package org.smoby.graph;
 
+import java.util.*;
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
- * An interface representing a resizable collection of objects, in
+ * A class representing a resizable collection of objects, in
  * which the order of the elements is not defined; the intention is
  * for the elements to represent possible choices for a value.
  */
-public interface MOBYEnumeration extends MOBYUnorderedCollection
+public class MOBYEnumeration extends MOBYUnorderedCollection
 {
-}
+    public MOBYEnumeration(Resource resource, List elements, Model underlying)
+    {
+        super(resource, elements, underlying);
+    }
+    
+    public boolean isEnumeration() { return true; }
+}
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYProvider.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/smoby/graph/MOBYProvider.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYProvider.java	2004/07/29 23:33:59	1.2
@@ -1,38 +1,84 @@
 package org.smoby.graph;
 
 import java.io.*;
+import com.hp.hpl.jena.rdf.model.*;
 
 /**
- * The Provider interface represents a resource that provides a
+ * The Provider class represents a resource that provides a
  * service in MOBY.
  */
-public interface MOBYProvider extends MOBYDocument
+public class MOBYProvider extends MOBYDocument
 {
+    private String name;
+    private String oneLineDescription;
+    private String moreInfoURI;
+    private MOBYUnorderedCollection operatesOn;
+    
+    public MOBYProvider(Resource resource, String name, String oneLineDescription,
+            	     String moreInfoURI, MOBYUnorderedCollection operatesOn,
+            	     Model underlying)
+    {
+        super(resource, underlying);
+        this.name = name;
+        this.oneLineDescription = oneLineDescription;
+        this.moreInfoURI = moreInfoURI;
+        this.operatesOn = operatesOn;
+    }
+
     /**
      * Return a descriptive name for the provider.
      */
-    public String getName();
-    
+    public String getName()
+    {
+        return name;
+    }
+
     /**
      * Return a short (one line) description for the provider.
      */
-    public String getOneLineDescription();
-    
+    public String getOneLineDescription()
+    {
+        return oneLineDescription;
+    }
+
     /**
      * Return a URI that can be accessed to obtain more information
      * about the provider.
      */
-    public String getMoreInfoURI();
+    public String getMoreInfoURI()
+    {
+        return moreInfoURI;
+    }
     
     /**
      * Return a collection of graph nodes that this provider operates on.
      * Each graph node represents either a Graph or GraphCollection.
      */
-    public MOBYUnorderedCollection getOperatesOn();
+    public MOBYUnorderedCollection getOperatesOn()
+    {
+        return operatesOn;
+    }
     
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append("Provider [name=\"");
+        sb.append(name);
+        sb.append("\", oneLineDescription=\"");
+        sb.append(oneLineDescription);
+        sb.append("\", moreInfoURI=");
+        sb.append(moreInfoURI);
+        sb.append("\"]");
+        
+        return sb.toString();
+    }
+
     /**
-     * Provider implementations should be capable of serializing themselves
+     * Providers should be capable of serializing themselves
      * to an output stream
      */
-    public void serialize(OutputStream out);
-}
\ No newline at end of file
+    public void serialize(OutputStream out)
+    {
+        underlying.write(out);
+    }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValue.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/smoby/graph/MOBYPropertyValue.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValue.java	2004/07/29 23:33:59	1.2
@@ -1,18 +1,22 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.Model;
+
 /**
- * A superinterface for things that can appear as the subject
+ * A superclass for things that can appear as the subject
  * or object of a statement.
  */
-public interface MOBYPropertyValue
+public abstract class MOBYPropertyValue
 {
     /**
-     * Return whether or not this property value represents a literal
+     * Return whether or not this property value represents
+     * a literal value
      */
-    public boolean isLiteral();
-    
+	public abstract boolean isLiteral();
+
     /**
-     * Return whether or not this property value represents a resource
+     * Return whether or not this property value represents
+     * a resource
      */
-    public boolean isResource();
+	public abstract boolean isResource();
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYOntology.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/smoby/graph/MOBYOntology.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYOntology.java	2004/07/29 23:33:59	1.2
@@ -1,9 +1,14 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
- * This interface represents a collection of RDF statements to be
+ * This class represents a collection of RDF statements to be
  * incorporated into the S-MOBY metadata repository.
  */
-public interface MOBYOntology extends MOBYDocument
+public class MOBYOntology extends MOBYDocument
 {
-}
+	public MOBYOntology(Resource resource, Model underlying) {
+        super(resource, underlying);
+    }
+}
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYProviderSet.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/smoby/graph/MOBYProviderSet.java	2004/06/18 21:37:52	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYProviderSet.java	2004/07/29 23:33:59	1.2
@@ -1,25 +1,56 @@
 package org.smoby.graph;
 
 import java.io.*;
+import java.util.*;
+import org.smoby.tools.*;
+import com.hp.hpl.jena.rdf.model.*;
 
 /**
- * An interface to represent a set of providers
+ * An class to represent a set of providers
  */
-public interface MOBYProviderSet extends MOBYDocument
+public class MOBYProviderSet extends MOBYDocument
 {
+	private List providers = new ArrayList();
+	
+	public MOBYProviderSet()
+	{
+		super(null, null);
+	}
+
 	/**
-	 * Add a provider to the set
+	 * Return the size of the set
 	 */
-	public void addProvider(MOBYProvider provider);
-    
+	public int size()
+	{
+		return providers.size();
+	}
+
 	/**
-	 * Return the size of the set
+	 * Add a provider to the set
 	 */
-	public int size();
-	
+	public void addProvider(MOBYProvider provider)
+	{
+		providers.add(provider);
+	}
+
     /**
      * Provider sets should be capable of serializing themselves
      * to an output stream
      */
-    public void serialize(OutputStream out);
+	public void serialize(OutputStream out)
+	{
+		Model merged = ModelFactory.createDefaultModel();
+		
+		for (Iterator it = providers.iterator(); it.hasNext();)
+		{
+			MOBYProvider provider = (MOBYProvider) it.next();
+			Model underlying = provider.getUnderlying();
+			merged.add(underlying);
+			merged.setNsPrefixes(underlying.getNsPrefixMap());
+		}
+		
+		Util.removeUnusedNsPrefixes(merged);
+		
+		merged.write(out);
+	}
 }

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYMappingElement.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/smoby/graph/MOBYMappingElement.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYMappingElement.java	2004/07/29 23:33:59	1.2
@@ -1,17 +1,36 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
 
-public interface MOBYMappingElement extends MOBYSingleElement
+
+public class MOBYMappingElement extends MOBYSingleElement
 {
+    private MOBYFixedCollection statements;
+    private MOBYCollection nestedElements;
+    
+    public MOBYMappingElement(Resource resource, MOBYFixedCollection statements,
+            					  MOBYCollection nestedElements, Model underlying)
+    {
+        super(resource, underlying);
+        this.statements = statements;
+        this.nestedElements = nestedElements;
+    }
+
     /**
      * Return the collection of property-setting statements associated
-     * with this subject.
+     * with this mapping element.
      */
-    public MOBYFixedCollection getPropertyValueStatements();
-    
+    public MOBYFixedCollection getPropertyValueStatements()
+    {
+        return statements;
+    }
+
     /**
-     * Return the collection of mappings that are nested within this subject
-     * through its role as a data structure.
+     * Return the collection of mappings that are nested within this
+     * mapping element through its role as a data structure.
      */
-    public MOBYCollection getNestedElements();
+    public MOBYCollection getNestedElements() {
+        return nestedElements;
+    }
+
 }

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYDescriptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYDescriptor.java	2004/07/19 18:21:36	1.2
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYDescriptor.java	2004/07/29 23:33:59	1.3
@@ -1,17 +1,43 @@
 package org.smoby.graph;
 
-import java.net.URI;
-
-import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.*;
 
 /**
- * The Resource interface represents things that are available
+ * The MOBYDescriptor class represents things that are available
  * at a URI.
  */
-public interface MOBYDescriptor
+public abstract class MOBYDescriptor
 {
+    protected Model underlying;
+    protected Resource resource;
+    
+    public MOBYDescriptor(Resource resource, Model underlying)
+    {
+        this.resource = resource;
+        this.underlying = underlying;
+    }
+    
+    /**
+     * Return the resource associated with this descriptor.
+     */
+    public Resource getResource()
+    {
+        return resource;
+    }
+    
+    /**
+     * Return the underlying Jena model
+     */
+    public Model getUnderlying()
+    {
+        return underlying;
+    }
+    
     /**
-     * Return the URI represented by this node.
+     * Return the URI of the underlying resource, if any.
      */
-    public Resource getResource();
-}
+    public String getURI()
+    {
+    	return (resource == null) ? null : resource.getURI();
+    }
+}
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYOrderedCollection.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/smoby/graph/MOBYOrderedCollection.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYOrderedCollection.java	2004/07/29 23:33:59	1.2
@@ -1,13 +1,22 @@
 package org.smoby.graph;
 
-/**
- * An interface representing resizable collection of objects, in
- * which the order of the elements is defined.
- */
-public interface MOBYOrderedCollection extends MOBYResizableCollection
+import java.util.*;
+import com.hp.hpl.jena.rdf.model.*;
+
+public class MOBYOrderedCollection extends MOBYResizableCollection
 {
+    public MOBYOrderedCollection(Resource resource, List elements, Model underlying)
+    {
+        super(resource, elements, underlying);
+    }
+    
+    public boolean isOrdered() { return true; }
+
     /**
      * Return the object at a given zero-based index.
      */
-    public Object get(int index);
+    public Object get(int index)
+    {
+        return elements.get(index);
+    }
 }

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYCollection.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/smoby/graph/MOBYCollection.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYCollection.java	2004/07/29 23:33:59	1.2
@@ -1,30 +1,50 @@
 package org.smoby.graph;
 
-import java.util.Iterator;
+import com.hp.hpl.jena.rdf.model.*;
+import java.util.*;
 
 /**
- * A common interface for collections, both fixed sized and resizeable, of
- * elements in MOBY graphs.
+ * A common abstract class for collections, both fixed sized and resizeable,
+ * of elements in MOBY graphs.
  */
-public interface MOBYCollection extends MOBYGraphNode
+public abstract class MOBYCollection extends MOBYGraphNode
 {
+    protected List elements = new ArrayList();
+
+    public MOBYCollection(Resource resource, List elements, Model underlying)
+    {
+        super(resource, underlying);
+        for (Iterator it = elements.iterator(); it.hasNext();) {
+            this.elements.add(it.next());
+        }
+    }
+
     /**
-     * Return whether or not the collection is fixed in size
+     * Return the size of the collection.
      */
-    public boolean isFixedSized();
-    
+    public int size()
+    {
+        return elements.size();
+    }
+
     /**
-     * Return whether or not the collection is resizable
+     * Return an iterator for traversing the elements
      */
-    public boolean isResizable();
+    public Iterator iterator()
+    {
+        return elements.iterator();
+    }
     
     /**
-     * Return an iterator for traversing the elements
+     * Return whether or not the collection is fixed in size
      */
-    public Iterator iterator();
+    public abstract boolean isFixedSized();
     
     /**
-     * Return the size of the collection.
+     * Return whether or not the collection is resizable
      */
-    public int size();
+    public abstract boolean isResizable();
+    
+    public boolean isSingular() { return false; }
+    public boolean isCollection() { return true; }
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYUnorderedCollection.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/smoby/graph/MOBYUnorderedCollection.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYUnorderedCollection.java	2004/07/29 23:33:59	1.2
@@ -1,14 +1,28 @@
 package org.smoby.graph;
 
+import java.util.*;
+
+import org.smoby.graph.*;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
+
 /**
- * An interface representing resizable collection of objects, in
+ * A class representing resizable collection of objects, in
  * which the order of the elements is not defined.
  */
-public interface MOBYUnorderedCollection extends MOBYResizableCollection
+public class MOBYUnorderedCollection extends MOBYResizableCollection
 {
+	public MOBYUnorderedCollection(Resource resource, List elements, Model underlying)
+    {
+        super(resource, elements, underlying);
+    }
+    
+    public boolean isOrdered() { return false; }
+    
     /**
      * Return whether or not the elements of this collection represent
      * choices (i.e. elements of an enumeration of possible values).
      */
-    public boolean isEnumeration();
+    public boolean isEnumeration() { return false; }
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYGraph.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/smoby/graph/MOBYGraph.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYGraph.java	2004/07/29 23:33:59	1.2
@@ -1,13 +1,26 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
- * This interface represents singular (i.e. not collection) subgraphs
+ * This class represents singular (i.e. not collection) subgraphs
  * that have a single mapping.
  */
-public interface MOBYGraph extends MOBYSingleElement
+public class MOBYGraph extends MOBYSingleElement
 {
+    private MOBYGraphNode hasMapping;
+    
+    public MOBYGraph(Resource resource, MOBYGraphNode hasMapping, Model underlying)
+    {
+        super(resource, underlying);
+        this.hasMapping = hasMapping;
+    }
+
     /**
      * Return the object of this graph's hasMapping property.
      */
-    public MOBYGraphNode gethasMapping();
+    public MOBYGraphNode getHasMapping()
+    {
+        return hasMapping;
+    }
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYGraphNode.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/smoby/graph/MOBYGraphNode.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYGraphNode.java	2004/07/29 23:33:59	1.2
@@ -1,23 +1,33 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
- * An interface for nodes in an RDF graph; these nodes are either
+ * An abstract class for nodes in an RDF graph; these nodes are either
  * collections or singular elements.
  */
-public interface MOBYGraphNode extends MOBYDescriptor
+public abstract class MOBYGraphNode extends MOBYDescriptor
 {
+    public MOBYGraphNode(Resource resource, Model underlying)
+    {
+        super(resource, underlying);
+    }
+
     /**
      * Return whether or not this node represents a blank node
      */
-    public boolean isBlank();
+    public boolean isBlank()
+    {
+        return (resource == null) || (resource.getURI() == null);
+    }
     
     /**
      * Return whether or not this object is a collection.
      */
-    public boolean isCollection();
+    public abstract boolean isCollection();
     
     /**
      * Return whether or not this object is a singular element.
      */
-    public boolean isSingular();
+    public abstract boolean isSingular();
 }
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYObject.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/smoby/graph/MOBYObject.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYObject.java	2004/07/29 23:33:59	1.2
@@ -1,8 +1,15 @@
 package org.smoby.graph;
 
+import com.hp.hpl.jena.rdf.model.*;
+
 /**
  * An object that represents the object of a mapping.
  */
-public interface MOBYObject extends MOBYMappingElement
+public class MOBYObject extends MOBYMappingElement
 {
-}
\ No newline at end of file
+	public MOBYObject(Resource resource, MOBYFixedCollection statements,
+			              MOBYCollection nestedElements, Model underlying)
+    {
+        super(resource, statements, nestedElements, underlying);
+    }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYSubject.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/smoby/graph/MOBYSubject.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYSubject.java	2004/07/29 23:33:59	1.2
@@ -1,6 +1,9 @@
 package org.smoby.graph;
 
-import java.net.URI;
+import org.smoby.graph.*;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
 
 /**
  * An object that represents the subject of one or more mappings. In
@@ -16,11 +19,27 @@
  * of which can itself be either a moby:Subject, an RDF data structure,
  * or both. This collection of elements is returned by getNestedMappings().
  */
-public interface MOBYSubject extends MOBYMappingElement
+public class MOBYSubject extends MOBYMappingElement
 {
+	/**
+	 * The collection of direct mappings, i.e. moby:mapsTo statements
+	 * whose subject is this.
+	 */
+    private MOBYUnorderedCollection directMappings;
+    
+    public MOBYSubject(Resource resource, MOBYFixedCollection statements,
+                           MOBYUnorderedCollection directMappings,
+            	           MOBYCollection nestedMappings, Model underlying)
+    {
+        super(resource, statements, nestedMappings, underlying);
+        this.directMappings = directMappings;
+    }
+
     /**
      * Return a resizable, unordered collection of the MOBYNode instances,
      * which are objects of mapsTo statements, whose subjects are this.
      */
-    public MOBYUnorderedCollection getDirectMappings();
-}
\ No newline at end of file
+    public MOBYUnorderedCollection getDirectMappings() {
+        return directMappings;
+    }
+}

===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValueException.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/smoby/graph/MOBYPropertyValueException.java	2004/05/24 22:05:35	1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/smoby/graph/MOBYPropertyValueException.java	2004/07/29 23:33:59	1.2
@@ -1,6 +1,5 @@
 package org.smoby.graph;
 
-
 public class MOBYPropertyValueException extends Exception
 {
     public MOBYPropertyValueException(String message) {




More information about the MOBY-guts mailing list