/** * Scans a character sequence for URIs. Then add all unique domain strings * derived from those found URIs to the supplied HashSet. * <p> * This function calls scanContentForHosts() to grab all the host strings. * Then it calls domainFromHost() on each host string found to distill them * to their basic "registrar" domains. * * @param domains a HashSet to be populated with all domain strings found in * the content * @param content a character sequence to be scanned for URIs * @return newDomains the domains which were extracted */ static public HashSet<String> scanContentForDomains(HashSet<String> domains, CharSequence content) { HashSet<String> newDomains = new HashSet<String>(); HashSet<String> hosts = scanContentForHosts(content); for (final String host:hosts) { final String domain = domainFromHost(host); if (null != domain) { if (false == domains.contains(domain)) { newDomains.add(domain); } } } return newDomains; }