if (host == null || host.equals(""))
throw new URISyntaxException(url, "Unable to gather host or no host found");
// Gather the domain object
InternetDomainName domainObj = InternetDomainName.from(host);
// Output the TLD
String publicSuffix = "[none]";
if (domainObj.hasPublicSuffix())
publicSuffix = domainObj.publicSuffix().name().trim().toLowerCase();
output.collect(new Text("TLD\t"+publicSuffix), new LongWritable(1));
// Output the private domain
// WARNING - This dramatically increases the size of the output.
String privateDomain = "[invalid]";
if (domainObj.topPrivateDomain() != null)
privateDomain = domainObj.topPrivateDomain().name().trim().toLowerCase();
//output.collect(new Text("Domain\t"+privateDomain), new LongWritable(1));
}
catch (URISyntaxException ex) {
output.collect(new Text("TLD\t[invalid URL]"), new LongWritable(1));