From b851582ca9b8758ffcd52038e0ad9799fe1bc650 Mon Sep 17 00:00:00 2001 From: "sandeep.konchady%sun.com" Date: Fri, 28 Oct 2005 22:22:44 +0000 Subject: [PATCH] Bugzila bug : 314098 Changed Double to Double.doubleValue() in constructing java.Security.Provider(). sr=wtc --- security/jss/org/mozilla/jss/JSSProvider.java | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/security/jss/org/mozilla/jss/JSSProvider.java b/security/jss/org/mozilla/jss/JSSProvider.java index 1117289f5297..001820b3eacd 100644 --- a/security/jss/org/mozilla/jss/JSSProvider.java +++ b/security/jss/org/mozilla/jss/JSSProvider.java @@ -35,6 +35,8 @@ * ***** END LICENSE BLOCK ***** */ package org.mozilla.jss; +import java.math.*; + public final class JSSProvider extends java.security.Provider { /********************************************************************/ @@ -49,11 +51,11 @@ public final class JSSProvider extends java.security.Provider { /* */ /********************************************************************/ - private static String JSS_MAJOR_VERSION = "4"; - private static String JSS_MINOR_VERSION = "1"; - private static String JSS_PATCH_VERSION = "1"; - private static Double JSS_VERSION = new Double(JSS_MAJOR_VERSION + - "."+JSS_MINOR_VERSION); + private static int JSS_MAJOR_VERSION = 4; + private static int JSS_MINOR_VERSION = 1; + private static int JSS_PATCH_VERSION = 1; + private static double JSS_VERSION = round((double)(JSS_MAJOR_VERSION + + (double)JSS_MINOR_VERSION/10),2); public JSSProvider() { super("Mozilla-JSS", JSS_VERSION, @@ -225,9 +227,23 @@ public final class JSSProvider extends java.security.Provider { } public String toString() { - return "Mozilla-JSS version " + - JSS_MAJOR_VERSION + "." + - JSS_MINOR_VERSION + "." + - JSS_PATCH_VERSION; + String mozillaProviderVersion = new Double(JSS_VERSION).toString(); + if ( JSS_PATCH_VERSION != 0 ) { + mozillaProviderVersion = mozillaProviderVersion + "." + + JSS_PATCH_VERSION; + } + + return "Mozilla-JSS version " + mozillaProviderVersion; + } + + /** + * Convenience method to round double + * @param double value, int round value + * @return rounded double + */ + private static double round(double value, int decimalPlace) { + BigDecimal bd = new BigDecimal(value); + bd = bd.setScale(decimalPlace,BigDecimal.ROUND_UP); + return bd.doubleValue(); } }