[MOBY-guts] biomoby commit
Gary Schiltz
gss at pub.open-bio.org
Mon Mar 21 21:29:44 UTC 2005
gss
Mon Mar 21 16:29:44 EST 2005
Update of /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph
In directory pub.open-bio.org:/tmp/cvs-serv8173/src/org/semanticmoby/graph
Modified Files:
MOBYEnumeration.java MOBYCollection.java
MOBYSingleElement.java MOBYFixedCollection.java
MOBYProviderSet.java MOBYSubject.java MOBYDescriptor.java
MOBYProvider.java MOBYDocument.java MOBYOntology.java
MOBYGraphNode.java MOBYObject.java MOBYMappingElement.java
MOBYOrderedCollection.java MOBYUnorderedCollection.java
MOBYResizableCollection.java
Log Message:
Major cleanup of graph classes
moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph MOBYEnumeration.java,1.1,1.2 MOBYCollection.java,1.1,1.2 MOBYSingleElement.java,1.1,1.2 MOBYFixedCollection.java,1.1,1.2 MOBYProviderSet.java,1.1,1.2 MOBYSubject.java,1.1,1.2 MOBYDescriptor.java,1.1,1.2 MOBYProvider.java,1.1,1.2 MOBYDocument.java,1.1,1.2 MOBYOntology.java,1.1,1.2 MOBYGraphNode.java,1.1,1.2 MOBYObject.java,1.1,1.2 MOBYMappingElement.java,1.1,1.2 MOBYOrderedCollection.java,1.1,1.2 MOBYUnorderedCollection.java,1.1,1.2 MOBYResizableCollection.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYEnumeration.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYEnumeration.java 2005/03/21 21:29:44 1.2
@@ -1,19 +1,38 @@
package org.semanticmoby.graph;
import java.util.*;
+
import com.hp.hpl.jena.rdf.model.*;
/**
- * 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.
+ * A class representing collections that can be resized (i.e.
+ * elements added to or removed from), in which the order of
+ * the elements is not defined; the intention is for the elements
+ * to represent possible choices for a value; corresponds to an
+ * RDF Alt.
*/
public class MOBYEnumeration extends MOBYUnorderedCollection
{
- public MOBYEnumeration(Resource resource, List elements, Model underlying)
+ /**
+ * Create an instance with no elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
+ */
+ public MOBYEnumeration(Resource resource,
+ Model underlyingJenaModel)
{
- super(resource, elements, underlying);
+ super(null, resource, underlyingJenaModel);
}
- public boolean isEnumeration() { return true; }
+ /**
+ * Create an instance with the initial list of elements
+ * @param initialElements the initial elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
+ */
+ public MOBYEnumeration(List initialElements, Resource resource,
+ Model underlyingJenaModel)
+ {
+ super(initialElements, resource, underlyingJenaModel);
+ }
}
\ No newline at end of file
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYCollection.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYCollection.java 2005/03/21 21:29:44 1.2
@@ -1,24 +1,34 @@
package org.semanticmoby.graph;
-import com.hp.hpl.jena.rdf.model.*;
import java.util.*;
+import com.hp.hpl.jena.rdf.model.*;
+
/**
- * A common abstract class 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 abstract class MOBYCollection extends MOBYGraphNode
{
+ /**
+ * A list to hold the elements of the collection
+ */
protected List elements = new ArrayList();
-
- public MOBYCollection(Resource resource, List elements, Model underlying)
+
+ /**
+ * Create an instance with the initial list of elements
+ * @param initialElements the initial elements
+ */
+ public MOBYCollection(List initialElements, Resource resource,
+ Model model)
{
- super(resource, underlying);
- for (Iterator it = elements.iterator(); it.hasNext();) {
- this.elements.add(it.next());
+ super(resource, model);
+
+ if (initialElements != null) {
+ elements.addAll(initialElements);
}
}
-
+
/**
* Return the size of the collection.
*/
@@ -36,15 +46,18 @@
}
/**
- * Return whether or not the collection is fixed in size
+ * Return whether or not this object is a collection.
*/
- public abstract boolean isFixedSized();
+ public boolean isCollection()
+ {
+ return true;
+ }
/**
- * Return whether or not the collection is resizable
+ * Return whether or not this object is a singular element.
*/
- public abstract boolean isResizable();
-
- public boolean isSingular() { return false; }
- public boolean isCollection() { return true; }
+ public boolean isSingular()
+ {
+ return false;
+ }
}
\ No newline at end of file
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYSingleElement.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYSingleElement.java 2005/03/21 21:29:44 1.2
@@ -18,6 +18,19 @@
super(resource, underlying);
}
- public boolean isSingular() { return true; }
- public boolean isCollection() { return false; }
+ /**
+ * Return whether or not this object is a collection.
+ */
+ public boolean isCollection()
+ {
+ return false;
+ }
+
+ /**
+ * Return whether or not this object is a singular element.
+ */
+ public boolean isSingular()
+ {
+ return true;
+ }
}
\ No newline at end of file
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYFixedCollection.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYFixedCollection.java 2005/03/21 21:29:44 1.2
@@ -1,20 +1,34 @@
package org.semanticmoby.graph;
import java.util.*;
+
import com.hp.hpl.jena.rdf.model.*;
/**
- * A class representing unordered, fixed sized collection
- * of objects.
+ * A class for holding an ordered, fixed sized collection
+ * of objects; corresponds to an RDF List.
*/
public class MOBYFixedCollection extends MOBYCollection
{
+ /**
+ * Create an instance with the initial list of elements
+ * @param initialElements the initial elements
+ * @param resource the resource node that represents this collection
+ * @param model the Jena model from which this is derived
+ */
+ public MOBYFixedCollection(List initialElements, Resource resource,
+ Model model)
+ {
+ super(initialElements, resource, model);
+ }
- public MOBYFixedCollection(Resource resource, List elements, Model underlying)
+ /**
+ * Return the element at the given index
+ * @param index the zero-based index of the element to retrieve
+ * @return the element
+ */
+ public Object get(int index)
{
- super(resource, elements, underlying);
+ return elements.get(index);
}
-
- public boolean isResizable() { return false; }
- public boolean isFixedSized() { return true; }
}
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYProviderSet.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYProviderSet.java 2005/03/21 21:29:44 1.2
@@ -46,7 +46,7 @@
for (Iterator it = providers.iterator(); it.hasNext();)
{
MOBYProvider provider = (MOBYProvider) it.next();
- Model underlying = provider.getUnderlying();
+ Model underlying = provider.getModel();
merged.add(underlying);
merged.setNsPrefixes(underlying.getNsPrefixMap());
}
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYSubject.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYSubject.java 2005/03/21 21:29:44 1.2
@@ -15,7 +15,7 @@
* subject of one or more moby:mapsTo properties. The collection of
* objects of each of these properties is returned by getDirectMappings().
* <p>
- * As an RDF data structure, this can have one or more elements, each
+ * As an RDF data structure, it can have one or more elements, each
* of which can itself be either a moby:Subject, an RDF data structure,
* or both. This collection of elements is returned by getNestedMappings().
*/
@@ -36,10 +36,11 @@
}
/**
- * Return a resizable, unordered collection of the MOBYNode instances,
- * which are objects of mapsTo statements, whose subjects are this.
+ * Return the collection of direct mappings, i.e. moby:mapsTo statements
+ * whose subject is this.
*/
- public MOBYUnorderedCollection getDirectMappings() {
+ public MOBYUnorderedCollection getDirectMappings()
+ {
return directMappings;
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYDescriptor.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/graph/MOBYDescriptor.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYDescriptor.java 2005/03/21 21:29:44 1.2
@@ -3,18 +3,20 @@
import com.hp.hpl.jena.rdf.model.*;
/**
- * The MOBYDescriptor class represents things that are available
- * at a URI.
+ * The MOBYDescriptor class represents things that are also
+ * represented as a Jena Model
*/
public abstract class MOBYDescriptor
{
- protected Model underlying;
protected Resource resource;
+ protected Model model;
- public MOBYDescriptor(Resource resource, Model underlying)
+ public MOBYDescriptor() {}
+
+ public MOBYDescriptor(Resource resource, Model model)
{
this.resource = resource;
- this.underlying = underlying;
+ this.model = model;
}
/**
@@ -28,9 +30,9 @@
/**
* Return the underlying Jena model
*/
- public Model getUnderlying()
+ public Model getModel()
{
- return underlying;
+ return model;
}
/**
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYProvider.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYProvider.java 2005/03/21 21:29:44 1.2
@@ -1,7 +1,12 @@
package org.semanticmoby.graph;
import java.io.*;
+
+import org.semanticmoby.tools.Util;
+import org.semanticmoby.vocabulary.MOBY;
+
import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.vocabulary.RDF;
/**
* The Provider class represents a resource that provides a
@@ -9,19 +14,76 @@
*/
public class MOBYProvider extends MOBYDocument
{
- private String name;
- private String oneLineDescription;
- private String moreInfoURI;
+ /**
+ * The statement that asserts this provider is a moby:Provider
+ */
+ private Statement providerStmt;
+
+ /**
+ * The name of the provider; stored in MOBY.name property
+ */
+ private Statement nameStmt;
+
+ /**
+ * A one line description of the provider; stored in the
+ * MOBY.oneLineDescription property
+ */
+ private Statement oneLineDescriptionStmt;
+
+ /**
+ * A URI at which more information can be retrieved about the
+ * provider; stored in the MOBY.moreInfoURI property
+ */
+ private Statement aboutURIStmt;
+
+ /**
+ * An unordered collection of operatesOn subgraphs. Each
+ * subgraph is itself either a MOBYGraph, or a MOBYCollection
+ */
private MOBYUnorderedCollection operatesOn;
- public MOBYProvider(Resource resource, String name, String oneLineDescription,
- String moreInfoURI, MOBYUnorderedCollection operatesOn,
- Model underlying)
+ /**
+ * Constructor for building an instance from scratch (i.e. not one
+ * being parsed from a model).
+ */
+ public MOBYProvider(String uri, String name, String oneLineDescription,
+ String aboutURI)
+ {
+ // Create a model and resource within the model to represent the
+ // URI at which the model is located
+ //
+ this.model = Util.newJenaModel();
+ this.resource = model.createResource(uri);
+
+ // Assert that the provider is a moby:Provider
+ //
+ model.add(providerStmt = model.createStatement(
+ resource, RDF.type, MOBY.Provider));
+
+ // Save the literal properties by creating the corresponding
+ // statements and adding them to the model
+ //
+ model.add(nameStmt = model.createStatement(
+ resource, MOBY.name, name));
+
+ model.add(oneLineDescriptionStmt = model.createStatement(
+ resource, MOBY.oneLineDescription, oneLineDescription));
+
+ model.add(aboutURIStmt = model.createStatement(
+ resource, MOBY.aboutURI, aboutURI));
+ }
+
+ public MOBYProvider(Resource resource,
+ Statement nameStmt,
+ Statement oneLineDescriptionStmt,
+ Statement aboutURIStmt,
+ MOBYUnorderedCollection operatesOn,
+ Model underlying)
{
super(resource, underlying);
- this.name = name;
- this.oneLineDescription = oneLineDescription;
- this.moreInfoURI = moreInfoURI;
+ this.nameStmt = nameStmt;
+ this.oneLineDescriptionStmt = oneLineDescriptionStmt;
+ this.aboutURIStmt = aboutURIStmt;
this.operatesOn = operatesOn;
}
@@ -30,7 +92,11 @@
*/
public String getName()
{
- return name;
+ try {
+ return nameStmt.getObject().toString();
+ } catch (NullPointerException e) {
+ return "";
+ }
}
/**
@@ -38,16 +104,24 @@
*/
public String getOneLineDescription()
{
- return oneLineDescription;
+ try {
+ return oneLineDescriptionStmt.getObject().toString();
+ } catch (NullPointerException e) {
+ return "";
+ }
}
/**
* Return a URI that can be accessed to obtain more information
* about the provider.
*/
- public String getMoreInfoURI()
+ public String getAboutURI()
{
- return moreInfoURI;
+ try {
+ return aboutURIStmt.getObject().toString();
+ } catch (NullPointerException e) {
+ return "";
+ }
}
/**
@@ -63,11 +137,11 @@
{
StringBuffer sb = new StringBuffer();
sb.append("Provider [name=\"");
- sb.append(name);
+ sb.append(getName());
sb.append("\", oneLineDescription=\"");
- sb.append(oneLineDescription);
- sb.append("\", moreInfoURI=");
- sb.append(moreInfoURI);
+ sb.append(getOneLineDescription());
+ sb.append("\", aboutURI=");
+ sb.append(getAboutURI());
sb.append("\"]");
return sb.toString();
@@ -79,6 +153,11 @@
*/
public void serialize(OutputStream out)
{
- underlying.write(out);
+ model.write(out);
+ }
+
+ public void serializeAsN3(OutputStream out)
+ {
+ model.write(out, "N3");
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYDocument.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYDocument.java 2005/03/21 21:29:44 1.2
@@ -8,8 +8,10 @@
*/
public abstract class MOBYDocument extends MOBYDescriptor
{
- public MOBYDocument(Resource resource, Model underlying)
+ public MOBYDocument() {}
+
+ public MOBYDocument(Resource resource, Model model)
{
- super(resource, underlying);
+ super(resource, model);
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYOntology.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYOntology.java 2005/03/21 21:29:44 1.2
@@ -8,7 +8,7 @@
*/
public class MOBYOntology extends MOBYDocument
{
- public MOBYOntology(Resource resource, Model underlying) {
- super(resource, underlying);
+ public MOBYOntology(Resource resource, Model model) {
+ super(resource, model);
}
}
\ No newline at end of file
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYGraphNode.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYGraphNode.java 2005/03/21 21:29:44 1.2
@@ -8,9 +8,9 @@
*/
public abstract class MOBYGraphNode extends MOBYDescriptor
{
- public MOBYGraphNode(Resource resource, Model underlying)
+ public MOBYGraphNode(Resource resource, Model model)
{
- super(resource, underlying);
+ super(resource, model);
}
/**
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYObject.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYObject.java 2005/03/21 21:29:44 1.2
@@ -1,5 +1,6 @@
package org.semanticmoby.graph;
+
import com.hp.hpl.jena.rdf.model.*;
/**
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYMappingElement.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYMappingElement.java 2005/03/21 21:29:44 1.2
@@ -1,5 +1,6 @@
package org.semanticmoby.graph;
+
import com.hp.hpl.jena.rdf.model.*;
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYOrderedCollection.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYOrderedCollection.java 2005/03/21 21:29:44 1.2
@@ -1,22 +1,58 @@
package org.semanticmoby.graph;
import java.util.*;
+
import com.hp.hpl.jena.rdf.model.*;
+/**
+ * A class representing collections that can be resized (i.e.
+ * elements added to or removed from), in which the order of
+ * the elements is defined; corresponds to an RDF Seq
+ */
public class MOBYOrderedCollection extends MOBYResizableCollection
{
- public MOBYOrderedCollection(Resource resource, List elements, Model underlying)
+ /**
+ * Create an instance with no elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
+ */
+ public MOBYOrderedCollection(Resource resource,
+ Model underlyingJenaModel)
{
- super(resource, elements, underlying);
+ super(null, resource, underlyingJenaModel);
+ }
+
+ /**
+ * Create an instance with the initial list of elements
+ * @param initialElements the initial elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
+ */
+ public MOBYOrderedCollection(List initialElements, Resource resource,
+ Model underlyingJenaModel)
+ {
+ super(initialElements, resource, underlyingJenaModel);
}
- public boolean isOrdered() { return true; }
-
/**
- * Return the object at a given zero-based index.
+ * Return the element at the given index
+ * @param index the zero-based index of the element to retrieve
+ * @return the element
*/
public Object get(int index)
{
return elements.get(index);
}
+
+ /**
+ * Add the given element to the collection so that its new
+ * zero-based index is given index
+ * @param index the zero-based index at which the new element
+ * should be added
+ * @param elementToAdd the element to add
+ */
+ public void add(int index, Object elementToAdd)
+ {
+ elements.add(index, elementToAdd);
+ }
}
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYUnorderedCollection.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYUnorderedCollection.java 2005/03/21 21:29:44 1.2
@@ -2,27 +2,35 @@
import java.util.*;
-import org.semanticmoby.graph.*;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.*;
/**
- * A class representing resizable collection of objects, in
- * which the order of the elements is not defined.
+ * A class representing collections that can be resized (i.e.
+ * elements added to or removed from), in which the order of
+ * the elements is not defined; corresponds to an RDF Bag
*/
public class MOBYUnorderedCollection extends MOBYResizableCollection
{
- public MOBYUnorderedCollection(Resource resource, List elements, Model underlying)
+ /**
+ * Create an instance with no elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
+ */
+ public MOBYUnorderedCollection(Resource resource,
+ Model underlyingJenaModel)
{
- super(resource, elements, underlying);
+ super(null, resource, underlyingJenaModel);
}
- 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).
+ * Create an instance with the initial list of elements
+ * @param initialElements the initial elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
*/
- public boolean isEnumeration() { return false; }
+ public MOBYUnorderedCollection(List initialElements, Resource resource,
+ Model underlyingJenaModel)
+ {
+ super(initialElements, resource, underlyingJenaModel);
+ }
}
\ No newline at end of file
===================================================================
RCS file: /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/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/semanticmoby/graph/MOBYResizableCollection.java 2004/11/23 00:18:46 1.1
+++ /home/repository/moby/moby-live/S-MOBY/ref-impl/core/src/org/semanticmoby/graph/MOBYResizableCollection.java 2005/03/21 21:29:44 1.2
@@ -2,10 +2,7 @@
import java.util.*;
-import org.semanticmoby.graph.*;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.*;
/**
* A class representing collections that can be resized (i.e.
@@ -14,16 +11,51 @@
*/
public abstract class MOBYResizableCollection extends MOBYCollection
{
- public MOBYResizableCollection(Resource resource, List elements, Model underlying)
+ /**
+ * Create an instance with no elements
+ * @param resource the resource node that represents this collection
+ * @param model the Jena model from which this is derived
+ */
+ public MOBYResizableCollection(Resource resource, Model model)
{
- super(resource, elements, underlying);
+ super(null, resource, model);
}
-
+
/**
- * Return whether or not this collection is ordered.
+ * Create an instance with the initial list of elements
+ * @param initialElements the initial elements
+ * @param resource the resource node that represents this collection
+ * @param underlyingJenaModel the Jena model from which this is stored
*/
- public abstract boolean isOrdered();
+ public MOBYResizableCollection(List initialElements, Resource resource,
+ Model underlyingJenaModel)
+ {
+ super(initialElements, resource, underlyingJenaModel);
+ }
- public boolean isResizable() { return true; }
- public boolean isFixedSized() { return false; }
+ /**
+ * Add an element to the collection
+ * @param elementToAdd the element to add to the collection
+ */
+ public void add(Object elementToAdd)
+ {
+ elements.add(elementToAdd);
+ }
+
+ /**
+ * Remove an element from the collection
+ * @param elementToRemove the element to remove
+ */
+ public void remove(Object elementToRemove)
+ {
+ elements.remove(elementToRemove);
+ }
+
+ /**
+ * Remove all the elements from the collection
+ */
+ public void clear()
+ {
+ elements.clear();
+ }
}
More information about the MOBY-guts
mailing list