Package dk.netarkivet.common.utils
Class TLD
- java.lang.Object
-
- dk.netarkivet.common.utils.TLD
-
public class TLD extends java.lang.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 java.lang.String
PUBLIC_SUFFIX_LIST_EMBEDDED_PATH
static java.lang.String
PUBLIC_SUFFIX_LIST_EXTERNAL_FILE_PATH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getAllTlds(boolean quoted)
GetAllTlds method.java.util.regex.Pattern
getHostnamePattern()
static TLD
getInstance()
GetInstance method for the TLD.java.util.regex.Pattern
getValidDomainMatcher()
protected static void
readTldsFromPublicSuffixFile(java.util.List<java.lang.String> tldList, java.util.List<java.lang.String> quotedTldList)
Helper method for reading TLDs from the embedded public suffix file.protected static void
readTldsFromSettings(java.util.List<java.lang.String> tldList, java.util.List<java.lang.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 java.lang.String PUBLIC_SUFFIX_LIST_EMBEDDED_PATH
- See Also:
- Constant Field Values
-
PUBLIC_SUFFIX_LIST_EXTERNAL_FILE_PATH
public static final java.lang.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(java.util.List<java.lang.String> tldList, java.util.List<java.lang.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(java.util.List<java.lang.String> tldList, java.util.List<java.lang.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 java.util.regex.Pattern getValidDomainMatcher()
- Returns:
- the VALID_DOMAIN_MATCHER pattern.
-
getHostnamePattern
public java.util.regex.Pattern getHostnamePattern()
- Returns:
- the HOSTNAME_REGEX pattern.
-
getAllTlds
public java.util.List<java.lang.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.
-
-