[MOBY-guts] biomoby commit

Paul Gordon gordonp at pub.open-bio.org
Thu Aug 4 04:16:41 UTC 2005


gordonp
Thu Aug  4 00:16:41 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data
In directory pub.open-bio.org:/tmp/cvs-serv6229

Modified Files:
	MobyDataFloat.java MobyDataInt.java 
Log Message:
Added convenience methods to retrieve Java primitives from the Moby data directly, with a precision loss warning in the Javadocs

moby-live/Java/src/main/org/biomoby/shared/data MobyDataFloat.java,1.3,1.4 MobyDataInt.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.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/MobyDataFloat.java	2005/07/22 05:11:54	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java	2005/08/04 04:16:41	1.4
@@ -225,6 +225,15 @@
     public Object getObject(){
 	return value;
     }
+    /**
+     * A convenience method, which returns the underlying BigInteger's primitive int representation.
+     * Caution: if the number is too big to fit, you'll end up with Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY
+     * Caution, you may lose precision on the data, even if it is within the range, especially for large e-value from BLAST, etc.
+     * Use the BigDecimal returned by getObject if you aren't sure of the range of your input.
+     */
+    public double doubleValue(){
+	return value.doubleValue();
+    }
 
     public String getValue(){
 	return ""+value;

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.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/MobyDataInt.java	2005/07/22 05:11:54	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java	2005/08/04 04:16:41	1.4
@@ -269,12 +269,30 @@
     }
 
     /**
-     * @return a BigInteger
+     * @return a BigInteger, the full precision value of the data
      */
     public Object getObject(){
 	return value;
     }
 
+    /**
+     * A convenience method, which returns the underlying BigInteger's primitive int representation.
+     * Caution: if the number is too big to fit, you're only getting the lower 32 bits!
+     * Use the BigInteger returned by getObject if you aren't sure of the range of your input.
+     */
+    public int intValue(){
+	return value.intValue();
+    }
+
+    /**
+     * A convenience method, which returns the underlying BigInteger's primitive int representation.
+     * Caution: if the number is too big to fit, you're only getting the lower 64 bits!
+     * Use the BigInteger returned by getObject if you aren't sure of the range of your input.
+     */
+    public long longValue(){
+	return value.longValue();
+    }
+
     public String getValue(){
 	return ""+value;
     }




More information about the MOBY-guts mailing list