1 package club.wpia.gigi.util;
4 import java.io.PrintWriter;
5 import java.util.HashSet;
7 public class HighFinancialValueFetcherUmbrella extends HighFinancialValueFetcher {
9 public HighFinancialValueFetcherUmbrella(File f, int max) {
10 super(f, max, "https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip");
13 private HashSet<String> printed = new HashSet<>();
16 public void handle(String line, PrintWriter fos) {
17 String[] parts = line.split(",");
19 // Assert that the value before the "," is an integer
21 if (Integer.parseInt(parts[0]) < 1) {
22 throw new NumberFormatException("We expect a number greater then zero for the first column.");
24 } catch (NumberFormatException nfe) {
25 // Bail on lines with invalid first field
26 throw new Error("Invalid format of first column.", nfe);
29 String registrablePart = PublicSuffixes.getInstance().getRegistrablePart(parts[1]);
30 if (registrablePart != null && printed.add(registrablePart)) {
31 emit(fos, registrablePart);
32 System.out.println(registrablePart);