import be.nikiroo.fanfix.searchable.BasicSearchable;
import be.nikiroo.fanfix.searchable.SearchableTag;
import be.nikiroo.fanfix.supported.SupportType;
+import be.nikiroo.utils.StringUtils;
/**
* Command line {@link Story} reader.
for (SearchableTag subtag : subtags) {
String total = "";
if (subtag.getCount() > 0) {
- // TODO: use StringUtils fromNumber
- total = " (" + subtag.getCount() + ")";
+ total = StringUtils.formatNumber(subtag
+ .getCount());
}
- System.out.println(i + ": " + subtag.getName()
- + total);
+
+ if (total.isEmpty()) {
+ System.out.println(String.format("%d: %s", i,
+ subtag.getName()));
+ } else {
+ System.out.println(String.format("%d: %s (%s)",
+ i, subtag.getName(), total));
+ }
+
i++;
}
}
nr = nr.substring(0, nr.length() - 1);
}
nr = nr.trim();
-
- //TODO: fix toNumber/fromNumber
+
+ // TODO: fix toNumber/fromNumber
nr = nr.replaceAll("\\.[0-9]*", "");
-
- subtag.setCount(toNumber(nr));
+
+ subtag.setCount(StringUtils.toNumber(nr));
}
}
}
tag.setComplete(true);
}
- /**
- * @deprecated use {@link StringUtils} when updated
- */
- @Deprecated
- private static long toNumber(String value) {
- // TODO: use StringUtils instead after update
- long count = 0l;
- if (value != null) {
- try {
- if (value.toLowerCase().endsWith("m")) {
- count = Long.parseLong(value.substring(0,
- value.length() - 1).trim());
- count *= 1000000;
- } else if (value.toLowerCase().endsWith("k")) {
- count = Long.parseLong(value.substring(0,
- value.length() - 1).trim());
- count *= 1000;
- } else {
- count = Long.parseLong(value);
- }
- } catch (NumberFormatException pe) {
- }
- }
-
- return count;
- }
-
@Override
public List<MetaData> search(String search) throws IOException {
String encoded = URLEncoder.encode(search.toLowerCase(), "utf-8");
url += "&p=" + page;
}
}
-
+
Document doc = load(url, false);
// Update the pages number if needed