code cleanup
authorNiki Roo <niki@nikiroo.be>
Sat, 13 Apr 2019 05:08:26 +0000 (07:08 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 13 Apr 2019 05:08:26 +0000 (07:08 +0200)
src/be/nikiroo/fanfix/reader/BasicReader.java
src/be/nikiroo/fanfix/reader/cli/CliReader.java

index c749a59cdc6e1c1149282a78c6b777ef1f680a2b..e0970e3ef09621e9f8c582d65fb7e4a2c2afba13 100644 (file)
@@ -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;
 
index 89eb3ac034b0ef1c9e5d338d6528a7050a200eac..03cb22738b37b1f25cb4ff9c5c73d2d4bcb5ff82 100644 (file)
@@ -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 {