Package org.apache.commons.text.lookup
Class DnsStringLookup
- java.lang.Object
-
- org.apache.commons.text.lookup.AbstractStringLookup
-
- org.apache.commons.text.lookup.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 theStringLookupFactory
: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 Summary
Fields Modifier and Type Field Description (package private) static DnsStringLookup
INSTANCE
Defines the singleton for this class.-
Fields inherited from class org.apache.commons.text.lookup.AbstractStringLookup
SPLIT_CH, SPLIT_STR
-
-
Constructor Summary
Constructors Modifier Constructor Description private
DnsStringLookup()
No need to build instances for now.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
lookup(java.lang.String key)
Looks up the DNS value of the key.-
Methods inherited from class org.apache.commons.text.lookup.AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKey
-
-
-
-
Field Detail
-
INSTANCE
static final DnsStringLookup INSTANCE
Defines the singleton for this class.
-
-