Class PublicSuffixMatcher


  • @Contract(threading=SAFE)
    public final class PublicSuffixMatcher
    extends java.lang.Object
    Utility class that can test if DNS names match the content of the Public Suffix List.

    An up-to-date list of suffixes can be obtained from publicsuffix.org

    Since:
    4.4
    See Also:
    PublicSuffixList
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDomainRoot​(java.lang.String domain)
      Returns registrable part of the domain for the given domain name or null if given domain represents a public suffix.
      java.lang.String getDomainRoot​(java.lang.String domain, DomainType expectedType)
      Returns registrable part of the domain for the given domain name or null if given domain represents a public suffix.
      boolean matches​(java.lang.String domain)
      Tests whether the given domain matches any of entry from the public suffix list.
      boolean matches​(java.lang.String domain, DomainType expectedType)
      Tests whether the given domain matches any of entry from the public suffix list.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PublicSuffixMatcher

        public PublicSuffixMatcher​(java.util.Collection<java.lang.String> rules,
                                   java.util.Collection<java.lang.String> exceptions)
      • PublicSuffixMatcher

        public PublicSuffixMatcher​(DomainType domainType,
                                   java.util.Collection<java.lang.String> rules,
                                   java.util.Collection<java.lang.String> exceptions)
        Since:
        4.5
      • PublicSuffixMatcher

        public PublicSuffixMatcher​(java.util.Collection<PublicSuffixList> lists)
        Since:
        4.5
    • Method Detail

      • getDomainRoot

        public java.lang.String getDomainRoot​(java.lang.String domain)
        Returns registrable part of the domain for the given domain name or null if given domain represents a public suffix.
        Parameters:
        domain -
        Returns:
        domain root
      • getDomainRoot

        public java.lang.String getDomainRoot​(java.lang.String domain,
                                              DomainType expectedType)
        Returns registrable part of the domain for the given domain name or null if given domain represents a public suffix.
        Parameters:
        domain -
        expectedType - expected domain type or null if any.
        Returns:
        domain root
        Since:
        4.5
      • matches

        public boolean matches​(java.lang.String domain)
        Tests whether the given domain matches any of entry from the public suffix list.
      • matches

        public boolean matches​(java.lang.String domain,
                               DomainType expectedType)
        Tests whether the given domain matches any of entry from the public suffix list.
        Parameters:
        domain -
        expectedType - expected domain type or null if any.
        Returns:
        true if the given domain matches any of the public suffixes.
        Since:
        4.5