public final class Lookup extends Object
A Lookup object may be reused, but should not be used by multiple threads.
Cache
,
Resolver
,
ResolverConfig
Modifier and Type | Field and Description |
---|---|
static int |
HOST_NOT_FOUND
The host does not exist.
|
static int |
SUCCESSFUL
The lookup was successful.
|
static int |
TRY_AGAIN
The lookup failed due to a network error.
|
static int |
TYPE_NOT_FOUND
The host exists, but has no records associated with the queried type.
|
static int |
UNRECOVERABLE
The lookup failed due to a data or server error.
|
Constructor and Description |
---|
Lookup(Name name)
Create a Lookup object that will find records of type A at the given name in the IN class.
|
Lookup(Name name,
int type)
Create a Lookup object that will find records of the given name and type in the IN class.
|
Lookup(Name name,
int type,
int dclass)
Create a Lookup object that will find records of the given name, type, and class.
|
Lookup(String name)
Create a Lookup object that will find records of type A at the given name in the IN class.
|
Lookup(String name,
int type)
Create a Lookup object that will find records of the given name and type in the IN class.
|
Lookup(String name,
int type,
int dclass)
Create a Lookup object that will find records of the given name, type, and class.
|
Modifier and Type | Method and Description |
---|---|
Name[] |
getAliases()
Returns all known aliases for this name.
|
Record[] |
getAnswers()
Returns the answers from the lookup.
|
static Cache |
getDefaultCache(int dclass)
Gets the Cache that will be used as the default for the specified class by future Lookups.
|
static HostsFileParser |
getDefaultHostsFileParser()
Gets the default
HostsFileParser to use for new Lookup instances. |
static Resolver |
getDefaultResolver()
Gets the Resolver that will be used as the default by future Lookups.
|
static List<Name> |
getDefaultSearchPath()
Gets the search path that will be used as the default by future Lookups.
|
String |
getErrorString()
Returns an error string describing the result code of this lookup.
|
HostsFileParser |
getHostsFileParser()
Gets or sets the local hosts database parser to use for lookup before using a
Resolver . |
int |
getResult()
Returns the result code of the lookup.
|
static void |
refreshDefault() |
Record[] |
run()
Performs the lookup, using the specified Cache, Resolver, and search path.
|
void |
setCache(Cache cache)
Sets the cache to use when performing this lookup.
|
void |
setCredibility(int credibility)
Sets the minimum credibility level that will be accepted when performing the lookup.
|
void |
setCycleResults(boolean cycleResults)
Controls the behavior if results being returned from the cache should be cycled in a
round-robin style (true) or if the raw lookup results should be returned (false).
|
static void |
setDefaultCache(Cache cache,
int dclass)
Sets the Cache to be used as the default for the specified class by future Lookups.
|
static void |
setDefaultHostsFileParser(HostsFileParser hostsFileParser)
Sets the default
HostsFileParser to use for new Lookup instances. |
static void |
setDefaultNdots(int ndots)
Sets the default ndots to use when performing a lookup, overriding the default value.
|
static void |
setDefaultResolver(Resolver resolver)
Sets the default Resolver to be used as the default by future Lookups.
|
static void |
setDefaultSearchPath(List<Name> domains)
Sets the search path to be used as the default by future Lookups.
|
static void |
setDefaultSearchPath(Name... domains)
Sets the search path to be used as the default by future Lookups.
|
static void |
setDefaultSearchPath(String... domains)
Sets the search path that will be used as the default by future Lookups.
|
void |
setHostsFileParser(HostsFileParser hostsFileParser)
Gets or sets the local hosts database parser to use for lookup before using a
Resolver . |
void |
setNdots(int ndots)
Sets ndots to use when performing this lookup, overriding the default value.
|
static void |
setPacketLogger(PacketLogger logger)
Sets a custom logger that will be used to log the sent and received packets.
|
void |
setResolver(Resolver resolver)
Sets the resolver to use when performing this lookup.
|
void |
setSearchPath(List<Name> domains)
Sets the search path to use when performing this lookup.
|
void |
setSearchPath(Name... domains)
Sets the search path to use when performing this lookup.
|
void |
setSearchPath(String... domains)
Sets the search path to use when performing this lookup.
|
public static final int SUCCESSFUL
public static final int UNRECOVERABLE
public static final int TRY_AGAIN
public static final int HOST_NOT_FOUND
public static final int TYPE_NOT_FOUND
public Lookup(Name name, int type, int dclass)
name
- The name of the desired recordstype
- The type of the desired recordsdclass
- The class of the desired recordsIllegalArgumentException
- The type is a meta type other than ANY.Cache
,
Resolver
,
Credibility
,
Name
,
Type
,
DClass
public Lookup(Name name, int type)
name
- The name of the desired recordstype
- The type of the desired recordsIllegalArgumentException
- The type is a meta type other than ANY.Lookup(Name,int,int)
public Lookup(Name name)
name
- The name of the desired recordsLookup(Name,int,int)
public Lookup(String name, int type, int dclass) throws TextParseException
name
- The name of the desired recordstype
- The type of the desired recordsdclass
- The class of the desired recordsTextParseException
- The name is not a valid DNS nameIllegalArgumentException
- The type is a meta type other than ANY.Lookup(Name,int,int)
public Lookup(String name, int type) throws TextParseException
name
- The name of the desired recordstype
- The type of the desired recordsTextParseException
- The name is not a valid DNS nameIllegalArgumentException
- The type is a meta type other than ANY.Lookup(Name,int,int)
public Lookup(String name) throws TextParseException
name
- The name of the desired recordsTextParseException
- The name is not a valid DNS nameLookup(Name,int,int)
public static void refreshDefault()
public static Resolver getDefaultResolver()
public static void setDefaultResolver(Resolver resolver)
resolver
- The default resolver.public static Cache getDefaultCache(int dclass)
dclass
- The class whose cache is being retrieved.public static void setDefaultCache(Cache cache, int dclass)
cache
- The default cache for the specified class.dclass
- The class whose cache is being set.public static List<Name> getDefaultSearchPath()
public static void setDefaultSearchPath(List<Name> domains)
domains
- The default search path.IllegalArgumentException
- if a domain in the search path is not absolute and cannot be
made absolute.public static void setDefaultSearchPath(Name... domains)
domains
- The default search path.IllegalArgumentException
- if a domain in the search path is not absolute and cannot be
made absolute.public static void setDefaultSearchPath(String... domains) throws TextParseException
domains
- The default search path.TextParseException
- A name in the array is not a valid DNS name.public static HostsFileParser getDefaultHostsFileParser()
HostsFileParser
to use for new Lookup instances.public static void setDefaultHostsFileParser(HostsFileParser hostsFileParser)
HostsFileParser
to use for new Lookup instances.public static void setPacketLogger(PacketLogger logger)
logger
- The loggerpublic void setResolver(Resolver resolver)
resolver
- The resolver to use.public void setSearchPath(List<Name> domains)
domains
- An array of names containing the search path.IllegalArgumentException
- if a domain in the search path is not absolute and cannot be
made absolute.public void setSearchPath(Name... domains)
domains
- An array of names containing the search path.IllegalArgumentException
- if a domain in the search path is not absolute and cannot be
made absolute.public void setSearchPath(String... domains) throws TextParseException
domains
- An array of names containing the search path.TextParseException
- A name in the array is not a valid DNS name.public void setCache(Cache cache)
cache
- The cache to use.public static void setDefaultNdots(int ndots)
ndots
- The ndots value to use, which must be greater than or equal to 0.public void setNdots(int ndots)
ndots
- The ndots value to use, which must be greater than or equal to 0.public void setCredibility(int credibility)
credibility
- The minimum credibility level.public void setCycleResults(boolean cycleResults)
cycleResults
- The desired behavior of the order of the resultspublic Record[] run()
public Record[] getAnswers()
IllegalStateException
- The lookup has not completed.public Name[] getAliases()
IllegalStateException
- The lookup has not completed.public int getResult()
IllegalStateException
- The lookup has not completed.public String getErrorString()
IllegalStateException
- The lookup has not completed.public HostsFileParser getHostsFileParser()
Resolver
.public void setHostsFileParser(HostsFileParser hostsFileParser)
Resolver
.Copyright © 2021 dnsjava.org. All rights reserved.