[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Mon Mar 12 17:03:24 UTC 2007


gordonp
Mon Mar 12 13:03:24 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data
In directory dev.open-bio.org:/tmp/cvs-serv4627/src/main/org/biomoby/shared/data

Modified Files:
	MobyDataObject.java 
Log Message:
Added special case for Base64 encoded data to create MobyDataBytes objects
moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.13,1.14
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java	2006/12/13 23:15:58	1.13
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java	2007/03/12 17:03:24	1.14
@@ -113,10 +113,11 @@
 	else if(MobyTags.MOBYDATETIME.equals(typeName)){
 	    return new MobyDataDateTime("", value);
 	}
-	else if("text-base64".equals(typeName)){
-	    return new MobyDataBytes("", value);
-	}
 	else{
+	    MobyDataType type = MobyDataType.getDataType(typeName);
+	    if(type != null && type.inheritsFrom(MobyDataBytes.BASE64_DATATYPE)){
+		return new MobyDataBytes("", value, type);
+	    }
 	    throw new MobyException("Attempted to construct a data instance from a string " +
 				    "value for a non-primitive data type (" + typeName + ")");
 	}
@@ -172,9 +173,6 @@
 	else if(MobyTags.MOBYDATETIME.equals(objectClass)){
 	    return new MobyDataDateTime(objectTag);
 	}
-	else if("text-base64".equals(objectClass)){
-	    return new MobyDataBytes(objectTag);
-	}
 	else if(MobyTags.COLLECTION.equals(objectClass)){
 	    return new MobyDataObjectSet(objectTag);
 	}
@@ -182,8 +180,15 @@
 	    return new MobyDataSecondaryInstance(objectTag);
 	}
 	// Must otherwise be a composite
-	else{	    
-	    return new MobyDataComposite(objectTag);
+	else{	   
+	    MobyDataType type = MobyDataType.getDataType(objectClass);
+	    // Treat base64-encoded binary data as a special case, as we have a convenience class for it
+	    if(type != null && type.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){
+		return new MobyDataBytes(objectTag);
+	    }
+	    else{
+		return new MobyDataComposite(objectTag);
+	    }
 	}
     }
 




More information about the MOBY-guts mailing list