Class RdapSearchPattern

java.lang.Object
google.registry.rdap.RdapSearchPattern

public final class RdapSearchPattern extends Object
Object containing the results of parsing an RDAP partial match search pattern. Search patterns are of the form XXXX, XXXX* or XXXX*.YYYY. There can be at most one wildcard character, and it must be at the end, except for a possible suffix string on the end to restrict the search to a particular TLD (for domains) or domain (for nameservers).
See Also:
  • Method Details

    • getInitialString

      public String getInitialString()
    • getHasWildcard

      public boolean getHasWildcard()
    • getSuffix

      @Nullable public String getSuffix()
    • getNextInitialString

      public String getNextInitialString()
      Attempts to return the next string in sort order after initialString. This can be used to convert a wildcard query into a range query, by looking for strings greater than or equal to initialString and less than nextInitialString.
    • createFromUnicodeString

      public static RdapSearchPattern createFromUnicodeString(String searchQuery)
      Creates a SearchPattern using the provided search pattern string in Unicode.

      The search query might end in an asterix, in which case that asterix is considered a wildcard and can match 0 or more characters. Without that asterix - the match will be exact.

      Parameters:
      searchQuery - the string containing the partial match pattern, optionally ending in a wildcard asterix
      Throws:
      HttpException.UnprocessableEntityException - if pattern has a wildcard not at the end of the query
    • createFromLdhDomainName

      public static RdapSearchPattern createFromLdhDomainName(String searchQuery)
      Creates a SearchPattern using the provided domain search pattern in LDH format.

      The domain search pattern can have a single wildcard asterix that can match 0 or more charecters. If such an asterix exists - it must be at the end of a domain label.

      Parameters:
      searchQuery - the string containing the partial match pattern
      Throws:
      HttpException.UnprocessableEntityException - if pattern does not meet the requirements of RFC 7482
    • createFromLdhOrUnicodeDomainName

      public static RdapSearchPattern createFromLdhOrUnicodeDomainName(String searchQuery)
      Creates a SearchPattern using the provided domain search pattern in LDH or Unicode format.

      The domain search pattern can have a single wildcard asterix that can match 0 or more charecters. If such an asterix exists - it must be at the end of a domain label.

      In theory, according to RFC 9082 4.1 - we should make some checks about partial matching in unicode queries. We don't, but we might want to just disable partial matches for unicode inputs (meaning if it doesn't match LDH_PATTERN, then don't allow wildcard at all).

      Parameters:
      searchQuery - the string containing the partial match pattern
      Throws:
      HttpException.UnprocessableEntityException - if pattern does not meet the requirements of RFC 7482
    • matches

      public boolean matches(@Nullable String string)
      Checks a string to make sure that it matches the search pattern.
      Parameters:
      string - the string to be matched
      Returns:
      true if the pattern matches the string