Class TLD


  • public class TLD
    extends Object
    Encapsulate the reading of Top level domains from settings and the embedded public_suffix.dat file.
    • Method Detail

      • getInstance

        public static TLD getInstance()
        GetInstance method for the TLD. Ensures singleton usage of the TLD class.
        Returns:
        the current instance of the TLD class.
      • reset

        public static void reset()
        Reset TLD instance. primarily used for testing.
      • readTldsFromSettings

        protected static void readTldsFromSettings​(List<String> tldList,
                                                   List<String> quotedTldList)
        Helper method for reading TLDs from settings. Will read all settings, validate them as legal TLDs and warn and ignore them if any are invalid. Settings may be with or without prefix "."
        Parameters:
        tldList - the list to add all the tlds found in the settings
        quotedTldList - the list to add all the tlds found in the settings - as a pattern
      • readTldsFromPublicSuffixFile

        protected static void readTldsFromPublicSuffixFile​(List<String> tldList,
                                                           List<String> quotedTldList)
        Helper method for reading TLDs from the embedded public suffix file. Will read all entries, validate them as legal TLDs and warn and ignore them if any are invalid. Now silently ignores starred tld's in public suffix file (e.g "*.kw") and exclusion rules (e.g. !metro.tokyo.jp)
        Parameters:
        tldList - the list to add all the tlds found in the public suffix file
        quotedTldList - the list to add all the tlds found in the public suffix file - as a pattern
      • getValidDomainMatcher

        public Pattern getValidDomainMatcher()
        Returns:
        the VALID_DOMAIN_MATCHER pattern.
      • getHostnamePattern

        public Pattern getHostnamePattern()
        Returns:
        the HOSTNAME_REGEX pattern.
      • getAllTlds

        public List<String> getAllTlds​(boolean quoted)
        GetAllTlds method.
        Parameters:
        quoted - do you want the quoted, or unquoted list.
        Returns:
        the quoted list (if quoted=true), else the unquoted list.