[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Thu Dec 6 23:42:55 UTC 2007
gordonp
Thu Dec 6 18:42:55 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data
In directory dev.open-bio.org:/tmp/cvs-serv31194/src/main/org/biomoby/shared/data
Modified Files:
MobyDataObjectSet.java MobyDataObjectSetSAI.java
Log Message:
Added registry support in c-tors
moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectSet.java,1.11,1.12 MobyDataObjectSetSAI.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/12/06 20:12:26 1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2007/12/06 23:42:55 1.12
@@ -21,6 +21,7 @@
public class MobyDataObjectSet extends MobyPrimaryDataSet implements MobyDataInstance, Collection<MobyDataObject>{
Vector<MobyDataObject> bag;
+ Registry registry;
private int xmlMode = MobyDataInstance.CENTRAL_XML_MODE;
public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{
@@ -55,30 +56,40 @@
* Creates an empty collection bag with a name.
*/
public MobyDataObjectSet(String name){
+ this(name, (Registry) null);
+ }
+
+ public MobyDataObjectSet(String name, Registry reg){
super(name);
+ registry = reg;
bag = new Vector<MobyDataObject>();
}
/**
- * Creates a collection with a name, initializing the members with the given array
+ * Creates a collection with a name, initializing the members with the given array.
+ * The registry is inferred from the input values. If the values array is blank, the default
+ * registry is used. This can be avoided by using the (name, registry) c-tor instead,
+ * which created a blank array for you automatically.
+ *
+ * @param values a set of MobyDataObjects, all from the same registry
*
* @throws NullPointerException if the input array is null, or contains null elements
*/
public MobyDataObjectSet(String name, MobyDataObject[] values) throws NullPointerException{
- this(name);
+ this(name, (Registry) (values.length == 0 ? null : values[0].getDataType().getRegistry()));
setElements(values);
}
/**
* Creates a collection with a name, initializing the members with the members of the given collection.
*
- * @param c usually another MobyDataObjectSet, or a Vector of MobyDataObjects
+ * @param c usually another MobyDataObjectSet, or a Vector of MobyDataObjects, all in the same namespace
*
* @throws ClassCastException if a member of the input collection is not a MobyDataObject
* @throws NullPointerException if the collection or one of its members is a null object
*/
public MobyDataObjectSet(String name, Collection<? extends MobyDataObject> c) throws ClassCastException, NullPointerException{
- this(name);
+ this(name, (Registry) (c.isEmpty() ? null : c.iterator().next().getDataType().getRegistry()));
addAll(c);
}
@@ -129,13 +140,13 @@
}
}
if(lineage != null && lineage.length == 0){
- return MobyDataType.getDataType("Object");
+ return MobyDataType.getDataType(MobyTags.MOBYOBJECT, registry);
}
return lineage == null ? null : lineage[lineage.length-1];
}
else{
// We know that any we could hold would at least be an Object...
- return MobyDataType.getDataType("Object");
+ return MobyDataType.getDataType(MobyTags.MOBYOBJECT, registry);
}
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java 2007/12/06 16:45:19 1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java 2007/12/06 23:42:55 1.4
@@ -3,6 +3,7 @@
import java.util.Collection;
import java.util.Iterator;
+import org.biomoby.registry.meta.Registry;
import org.biomoby.shared.*;
/**
@@ -24,9 +25,13 @@
* Constructor for base Objects.
*/
public MobyDataObjectSetSAI(String name, MobyService[] services){
- super(""); // Not using c-tor(namespace, id), then assigning "this" to
- // dataInstance, because that would cause recursion in the shadowed calls
- dataInstance = new MobyDataObjectSet(name);
+ this(name, services, null);
+ }
+
+ public MobyDataObjectSetSAI(String name, MobyService[] services, Registry registry){
+ super("", registry); // Not using c-tor(namespace, id), then assigning "this" to
+ // dataInstance, because that would cause recursion in the shadowed calls
+ dataInstance = new MobyDataObjectSet(name, registry);
mobyServices = services;
}
@@ -34,7 +39,7 @@
* Constructor that takes an existing object and associates services with it.
*/
public MobyDataObjectSetSAI(MobyDataObjectSet collection, MobyService[] services){
- super(collection.getName());
+ super(collection.getName(), collection.getDataType().getRegistry());
dataInstance = collection;
mobyServices = services;
}
More information about the MOBY-guts
mailing list