Package dk.netarkivet.common.utils
Class TLD
- java.lang.Object
-
- dk.netarkivet.common.utils.TLD
-
public class TLD extends Object
Encapsulate the reading of Top level domains from settings and the embedded public_suffix.dat file.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PUBLIC_SUFFIX_LIST_EMBEDDED_PATH
static String
PUBLIC_SUFFIX_LIST_EXTERNAL_FILE_PATH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getAllTlds(boolean quoted)
GetAllTlds method.Pattern
getHostnamePattern()
static TLD
getInstance()
GetInstance method for the TLD.Pattern
getValidDomainMatcher()
protected static void
readTldsFromPublicSuffixFile(List<String> tldList, List<String> quotedTldList)
Helper method for reading TLDs from the embedded public suffix file.protected static void
readTldsFromSettings(List<String> tldList, List<String> quotedTldList)
Helper method for reading TLDs from settings.static void
reset()
Reset TLD instance.
-
-
-
Field Detail
-
PUBLIC_SUFFIX_LIST_EMBEDDED_PATH
public static final String PUBLIC_SUFFIX_LIST_EMBEDDED_PATH
- See Also:
- Constant Field Values
-
PUBLIC_SUFFIX_LIST_EXTERNAL_FILE_PATH
public static final String PUBLIC_SUFFIX_LIST_EXTERNAL_FILE_PATH
- See Also:
- Constant Field Values
-
-
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 settingsquotedTldList
- 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 filequotedTldList
- 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.
-
-