|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jnetpcap.util.resolver.AbstractResolver
public abstract class AbstractResolver
Default adaptor class for Resovler interface. This abstract class provides the default caching mechanism for positive and negative resolver lookups. It also provides a timeout mechanism to time out lookup results.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.jnetpcap.util.resolver.Resolver |
|---|
Resolver.ResolverType |
| Field Summary | |
|---|---|
protected static long |
INFINITE_TIMEOUT
Timeout of 5 years. |
protected java.util.logging.Logger |
logger
Logger is supplied from subclass. |
| Fields inherited from interface org.jnetpcap.util.resolver.Resolver |
|---|
RESOLVER_SEARCH_PATH_PROPERTY |
| Constructor Summary | |
|---|---|
AbstractResolver(java.util.logging.Logger logger,
Resolver.ResolverType type)
Instantiates a new abstract resolver. |
|
AbstractResolver(java.util.logging.Logger logger,
java.lang.String name)
Instantiates a new abstract resolver. |
|
| Method Summary | |
|---|---|
void |
addToCache(long hash,
java.lang.String name)
Adds the to cache. |
void |
addToCache(long hash,
java.lang.String name,
long timeout)
Adds the to cache. |
boolean |
canBeResolved(byte[] address)
Can be resolved. |
void |
clearCache()
Clear cache and timeout queues. |
protected void |
finalize()
Finalize. |
int |
getCacheCapacity()
Gets the just an initial map size. |
float |
getCacheLoadFactor()
Gets the cache load factor. |
long |
getNegativeTimeout()
Gets the when failed to resolve to a name, store the failure information in cache and set the negative hit timeout. |
long |
getPositiveTimeout()
Gets the resolved to a name. |
protected boolean |
hasCacheFile()
Checks for cache file. |
void |
initializeIfNeeded()
Called by JRegistry when resolver when it is being retrieved. |
boolean |
isCached(byte[] address)
Checks if is cached. |
int |
loadCache()
Load cache entries using default mechanism. |
int |
loadCache(java.lang.String file)
Load cache entries from file. |
int |
loadCache(java.net.URL url)
Load cache. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Property change. |
java.lang.String |
resolve(byte[] address)
Resolve. |
protected abstract java.lang.String |
resolveToName(byte[] address,
long hash)
Resolves an address to a name. |
protected abstract java.lang.String |
resolveToName(long number,
long hash)
Resolves number to a name. |
int |
saveCache()
Save the cache using default mechanism, if set. |
int |
saveCache(java.lang.String file)
Save the cache to file. |
void |
setCacheCapacity(int cacheCapacity)
Sets the just an initial map size. |
void |
setCacheLoadFactor(float cacheLoadFactor)
Sets the cache load factor. |
void |
setNegativeTimeout(long negativeTimeout)
Sets the when failed to resolve to a name, store the failure information in cache and set the negative hit timeout. |
void |
setPositiveTimeout(long positiveTimeout)
Sets the resolved to a name. |
protected abstract long |
toHashCode(byte[] address)
To hash code. |
protected long |
toHashCode(long number)
To hash code. |
java.lang.String |
toString()
To string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final long INFINITE_TIMEOUT
protected final java.util.logging.Logger logger
| Constructor Detail |
|---|
public AbstractResolver(java.util.logging.Logger logger,
Resolver.ResolverType type)
logger - the loggertype - the type
public AbstractResolver(java.util.logging.Logger logger,
java.lang.String name)
logger - the loggername - the name| Method Detail |
|---|
public void addToCache(long hash,
java.lang.String name)
hash - the hashname - the name
public void addToCache(long hash,
java.lang.String name,
long timeout)
hash - the hashname - the nametimeout - the timeoutpublic boolean canBeResolved(byte[] address)
canBeResolved in interface Resolveraddress - the address
Resolver.canBeResolved(byte[])public void clearCache()
clearCache in interface Resolver
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - the throwableObject.finalize()public final int getCacheCapacity()
public final float getCacheLoadFactor()
public final long getNegativeTimeout()
public final long getPositiveTimeout()
protected boolean hasCacheFile()
public void initializeIfNeeded()
initializeIfNeeded in interface Resolverpublic boolean isCached(byte[] address)
isCached in interface Resolveraddress - the address
Resolver.isCached(byte[])
public int loadCache()
throws java.io.IOException
java.io.IOException - Signals that an I/O exception has occurred.
public int loadCache(java.lang.String file)
throws java.io.IOException
file - file to load cache entries from
java.io.IOException - any IO errors
public int loadCache(java.net.URL url)
throws java.io.IOException
loadCache in interface Resolverurl - the url
java.io.IOException - Signals that an I/O exception has occurred.Resolver.loadCache(java.net.URL)public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerevt - the evtPropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)public final java.lang.String resolve(byte[] address)
resolve in interface Resolveraddress - the address
Resolver.resolve(byte[])
protected abstract java.lang.String resolveToName(byte[] address,
long hash)
address - address to resolvehash - computed hash code for the address, identifies the address
uniquely
protected abstract java.lang.String resolveToName(long number,
long hash)
number - a number value to resolvehash - computed hash code for the number, identifies the number uniquely
public int saveCache()
throws java.io.IOException
saveCache in interface Resolverjava.io.IOException - Signals that an I/O exception has occurred.
public int saveCache(java.lang.String file)
throws java.io.IOException
file - file to save to
java.io.IOException - any IO errorspublic final void setCacheCapacity(int cacheCapacity)
cacheCapacity - the new just an initial map sizepublic final void setCacheLoadFactor(float cacheLoadFactor)
cacheLoadFactor - the new cache load factorpublic final void setNegativeTimeout(long negativeTimeout)
negativeTimeout - the new when failed to resolve to a name, store the failure
information in cache and set the negative hit timeoutpublic final void setPositiveTimeout(long positiveTimeout)
positiveTimeout - the new resolved to a nameprotected abstract long toHashCode(byte[] address)
address - the address
protected long toHashCode(long number)
number - the number
public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||