|
|||||||||
| 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)
|
|
AbstractResolver(java.util.logging.Logger logger,
java.lang.String name)
|
|
| Method Summary | |
|---|---|
void |
addToCache(long hash,
java.lang.String name)
|
void |
addToCache(long hash,
java.lang.String name,
long timeout)
|
boolean |
canBeResolved(byte[] address)
Checks if a mapping exists or can be made. |
void |
clearCache()
Clear cache and timeout queues |
protected void |
finalize()
|
int |
getCacheCapacity()
|
float |
getCacheLoadFactor()
|
long |
getNegativeTimeout()
|
long |
getPositiveTimeout()
|
protected boolean |
hasCacheFile()
|
void |
initializeIfNeeded()
Called by JRegistry when resolver when it is being retrieved. |
boolean |
isCached(byte[] address)
Checks if resolver already has a mapping made for this particular address. |
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)
Attempts to load the cache from the given URL. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
|
java.lang.String |
resolve(byte[] address)
Attempts to resole an address to a human readable form. |
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)
|
void |
setCacheLoadFactor(float cacheLoadFactor)
|
void |
setNegativeTimeout(long negativeTimeout)
|
void |
setPositiveTimeout(long positiveTimeout)
|
protected abstract long |
toHashCode(byte[] address)
|
protected long |
toHashCode(long number)
|
java.lang.String |
toString()
|
| 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)
public AbstractResolver(java.util.logging.Logger logger,
java.lang.String name)
| Method Detail |
|---|
public void addToCache(long hash,
java.lang.String name)
public void addToCache(long hash,
java.lang.String name,
long timeout)
public boolean canBeResolved(byte[] address)
Resolver
canBeResolved in interface Resolveraddress - address to check mapping for
public void clearCache()
clearCache in interface Resolver
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic 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)
Resolver
isCached in interface Resolveraddress - address to check for
public int loadCache()
throws java.io.IOException
java.io.IOException
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
Resolver
loadCache in interface Resolverurl - URL of the resource containing the database to load
java.io.IOException - any IO errorspublic void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerpublic final java.lang.String resolve(byte[] address)
Resolver
resolve in interface Resolveraddress - address to try and resolve
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
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)
public final void setCacheLoadFactor(float cacheLoadFactor)
public final void setNegativeTimeout(long negativeTimeout)
public final void setPositiveTimeout(long positiveTimeout)
protected abstract long toHashCode(byte[] address)
protected long toHashCode(long number)
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||