Class DnsStringLookup

  • All Implemented Interfaces:
    StringLookup

    final class DnsStringLookup
    extends AbstractStringLookup
    Looks up keys related to DNS entries like host name, canonical host name, host address.

    The lookup keys are:

    • name|address: for the host name, for example "name|93.184.216.34" -> "example.com".
    • canonical-name|address: for the canonical host name, for example "name|93.184.216.34" -> "example.com".
    • address|hostname: for the host address, for example "address|example.com" -> "93.184.216.34".
    • address: same as address|hostname.

    Using a StringLookup from the StringLookupFactory:

     StringLookupFactory.INSTANCE.dnsStringLookup().lookup("address|apache.org");
     

    Using a StringSubstitutor:

     StringSubstitutor.createInterpolator().replace("... ${dns:address|apache.org} ..."));
     

    The above examples convert "address|apache.org" to "95.216.24.32 (or "40.79.78.1").

    Since:
    1.8
    • Field Detail

      • INSTANCE

        static final DnsStringLookup INSTANCE
        Defines the singleton for this class.
    • Constructor Detail

      • DnsStringLookup

        private DnsStringLookup()
        No need to build instances for now.
    • Method Detail

      • lookup

        public java.lang.String lookup​(java.lang.String key)
        Looks up the DNS value of the key.
        Parameters:
        key - the key to be looked up, may be null
        Returns:
        The DNS value.