From 53f76130c5337a77362b191f22115b461811ba36 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 13 Apr 2019 07:08:26 +0200 Subject: [PATCH] code cleanup --- src/be/nikiroo/fanfix/reader/BasicReader.java | 32 +++---------------- .../nikiroo/fanfix/reader/cli/CliReader.java | 13 ++++---- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index c749a59c..e0970e3e 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -232,9 +232,11 @@ public abstract class BasicReader implements Reader { metaDesc.put("Published on", meta.getPublisher()); metaDesc.put("URL", meta.getUrl()); if (meta.isImageDocument()) { - metaDesc.put("Number of images", format(meta.getWords())); + metaDesc.put("Number of images", + StringUtils.formatNumber(meta.getWords())); } else { - metaDesc.put("Number of words", format(meta.getWords())); + metaDesc.put("Number of words", + StringUtils.formatNumber(meta.getWords())); } metaDesc.put("Source", meta.getSource()); metaDesc.put("Subject", meta.getSubject()); @@ -351,32 +353,6 @@ public abstract class BasicReader implements Reader { } } - /** - * @deprecated use StringUtils when updated - */ - @Deprecated - static private String format(long value) { - //TODO: use StringUtils - - String display = ""; - String suffix = ""; - - if (value > 4000) { - value = value / 1000; - suffix = "k"; - } - - while (value > 0) { - if (!display.isEmpty()) { - display = "." + display; - } - display = (value % 1000) + display; - value = value / 1000; - } - - return display + suffix; - } - static private String formatDate(String date) { long ms = 0; diff --git a/src/be/nikiroo/fanfix/reader/cli/CliReader.java b/src/be/nikiroo/fanfix/reader/cli/CliReader.java index 89eb3ac0..03cb2273 100644 --- a/src/be/nikiroo/fanfix/reader/cli/CliReader.java +++ b/src/be/nikiroo/fanfix/reader/cli/CliReader.java @@ -187,16 +187,17 @@ class CliReader extends BasicReader { } // TODO: i18n + String stories = "stories"; + String num = StringUtils.formatNumber(subtag + .getCount()); if (sp.isEmpty()) { System.out.println(String.format( - "%d/%d: %s, %d %s", page, item, - subtag.getName(), subtag.getCount(), - "stories")); + "%d/%d: %s, %s %s", page, item, + subtag.getName(), num, stories)); } else { System.out.println(String.format( - "%d/%d: %s (%s), %d %s", page, item, - subtag.getName(), sp, - subtag.getCount(), "stories")); + "%d/%d: %s (%s), %s %s", page, item, + subtag.getName(), sp, num, stories)); } } } else { -- 2.27.0