diff --git a/htroot/Network.java b/htroot/Network.java index 9b238b230..d7cfab1aa 100644 --- a/htroot/Network.java +++ b/htroot/Network.java @@ -142,8 +142,8 @@ public class Network { prop.put("table_my-version", seed.get(yacySeed.VERSION, "-")); prop.put("table_my-utc", seed.get(yacySeed.UTC, "-")); prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "")))); - prop.put("table_my-links", groupDigits(Long.toString(links))); - prop.put("table_my-words", groupDigits(Long.toString(words))); + prop.put("table_my-links", groupDigits(links)); + prop.put("table_my-words", groupDigits(words)); prop.put("table_my-sI", groupDigits(seed.get(yacySeed.INDEX_OUT, "0"))); prop.put("table_my-sU", groupDigits(seed.get(yacySeed.URL_OUT, "0"))); prop.put("table_my-rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0"))); @@ -523,10 +523,7 @@ public class Network { lValue = Long.parseLong(sValue); } catch (Exception e) {lValue = 0;} if (lValue == 0) { return "-"; } - sValue = Long.toString(lValue); - String rValue = ""; - for (int i = 0; i < sValue.length(); i++) { rValue = sValue.charAt(sValue.length() - i - 1) + (((i % 3) == 0) ? "." : "") + rValue; } - return rValue.substring(0, rValue.length() - 1); + return groupDigits(lValue); } private static String groupDigits(long Number) { diff --git a/htroot/Status.java b/htroot/Status.java index 36d283d43..347708571 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -238,8 +238,8 @@ public class Status { prop.put("peerStatistics_uptime", serverDate.intervalToString(uptime)); prop.put("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed.get(yacySeed.ISPEED, "unknown")); prop.put("peerStatistics_queriesperhour", Double.toString(Math.round(6000d * yacyCore.seedDB.mySeed.getQPM()) / 100d)); - prop.put("peerStatistics_links", yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "unknown")); - prop.put("peerStatistics_words", yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "unknown")); + prop.put("peerStatistics_links", groupDigits(yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "0"))); + prop.put("peerStatistics_words", groupDigits(yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "0"))); prop.put("peerStatistics_juniorConnects", yacyCore.peerActions.juniorConnects); prop.put("peerStatistics_seniorConnects", yacyCore.peerActions.seniorConnects); prop.put("peerStatistics_principalConnects", yacyCore.peerActions.principalConnects); @@ -402,5 +402,25 @@ public class Status { } } + + + //TODO: groupDigits-functions (Status.java & Network.java) should + // be referenced in a single class (now double-implemented) + private static String groupDigits(String sValue) { + long lValue; + try { + if (sValue.endsWith(".0")) { sValue = sValue.substring(0, sValue.length() - 2); } // for Connects per hour, why float ? + lValue = Long.parseLong(sValue); + } catch (Exception e) {lValue = 0;} + if (lValue == 0) { return "-"; } + return groupDigits(lValue); + } + + private static String groupDigits(long Number) { + final String s = Long.toString(Number); + String t = ""; + for (int i = 0; i < s.length(); i++) t = s.charAt(s.length() - i - 1) + (((i % 3) == 0) ? "." : "") + t; + return t.substring(0, t.length() - 1); + } }