commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r745044 - /commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
Date Tue, 17 Feb 2009 13:27:47 GMT
Author: nicolas
Date: Tue Feb 17 13:27:46 2009
New Revision: 745044

URL: http://svn.apache.org/viewvc?rev=745044&view=rev
Log:
convert method

Modified:
    commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java

Modified: commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java?rev=745044&r1=745043&r2=745044&view=diff
==============================================================================
--- commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
(original)
+++ commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
Tue Feb 17 13:27:46 2009
@@ -145,14 +145,17 @@
         return scale;
     }
 
-//    public long getScale( Unit other )
-//    {
-//        if ( !isCompatible( other ) )
-//        {
-//            throw new IllegalArgumentException( other + " is incompatible with " + this
);
-//        }
-//        return scale;
-//    }
+    /**
+     * Convert value from unit to this unit (if conpatible)
+     * 
+     * @param value value to convert
+     * @param unit unit of value
+     * @return value converted to this unit
+     */
+    public double convert( double value, Unit unit )
+    {
+        return value * unit.getScale() / this.getScale();
+    }
 
     public boolean isPrimary()
     {



Mime
View raw message