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
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 Summary
FieldsModifier and TypeFieldDescription(package private) static final DnsStringLookup
Defines the singleton for this class.Fields inherited from class org.apache.commons.text.lookup.AbstractStringLookup
SPLIT_CH, SPLIT_STR
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.commons.text.lookup.AbstractStringLookup
substringAfter, substringAfter, substringAfterLast, toLookupKey, toLookupKey
-
Field Details
-
INSTANCE
Defines the singleton for this class.
-
-
Constructor Details
-
DnsStringLookup
private DnsStringLookup()No need to build instances for now.
-
-
Method Details
-
lookup
Looks up the DNS value of the key.- Parameters:
key
- the key to be looked up, may be null- Returns:
- The DNS value.
-