[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Feb 3 22:05:37 UTC 2011


gordonp
Thu Feb  3 17:05:37 EST 2011
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data
In directory dev.open-bio.org:/tmp/cvs-serv21626/src/main/org/biomoby/shared/data

Modified Files:
	MobyDataFloat.java 
Log Message:
Unparseable floats are not set to zero instead of causing exception
moby-live/Java/src/main/org/biomoby/shared/data MobyDataFloat.java,1.11,1.12
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.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/MobyDataFloat.java	2008/01/07 22:11:36	1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java	2011/02/03 22:05:37	1.12
@@ -2,6 +2,7 @@
 package org.biomoby.shared.data;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.logging.*;
 
 import org.biomoby.registry.meta.Registry;
 import org.biomoby.shared.MobyDataType;
@@ -21,6 +22,7 @@
 public class MobyDataFloat extends MobyDataObject{
 
     private BigDecimal value;
+    private static Logger logger = Logger.getLogger(MobyDataFloat.class.getName());
     
     /**
      * Construct the object using a DOM fragment.
@@ -102,7 +104,12 @@
     public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{
 	super(articleName, registry);
 	setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry));
-	value = new BigDecimal(stringNumber.trim());
+	try{
+	    value = new BigDecimal(stringNumber.trim());
+	} catch(Exception e){
+	    logger.log(Level.WARNING, "Could not parse '"+stringNumber+"' as a decimal number, using zero instead");
+	    value = BigDecimal.ZERO;
+	}
     }
 
     public MobyDataFloat(String stringNumber){




More information about the MOBY-guts mailing list