org.jnetpcap.util.config
Class JConfig

java.lang.Object
  extended by org.jnetpcap.util.config.JConfig

public class JConfig
extends java.lang.Object

JConfig is responsible for jNetPcap configuration and global environment maintentance. Its main purpose to locate resources such as config files, read system properties and create an environment where resolver files can be stored and maintained. The class provides various static (global) methods for this purpose.

Property names and constant values:

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
protected static class JConfig.ClasspathSearch
          The Class ClasspathSearch.
protected static class JConfig.FilesystemSearch
          The Class FilesystemSearch.
static interface JConfig.SearchPath
          Interface used to piece together specific types of search paths.
protected static class JConfig.URLSearch
          The Class URLSearch.
 
Field Summary
static java.lang.String CACHE_DIR_PROPERTY
          Java property for resolver directory where resolver files are saved.
static java.lang.String CACHE_FILE_SUFFIX
          Suffix of a resolver file.
static java.lang.String CACHE_FILE_SUFFIX_PROPERTY
          Suffix of a resolver file.
static java.lang.String CACHE_SUB_DIR
          If resolver directory is not explicitely defined with a property, this is the default sub directory name used in user's home directory for all resolver files.
static java.lang.String CACHE_SUB_DIR_PROPERTY
          If resolver directory is not explicitely defined with a.
static java.lang.String RESOURCE_SEARCH_PATH_PROPERTY
          The Constant RESOURCE_SEARCH_PATH_PROPERTY.
static java.lang.String USER_HOME_PROPERTY
          System property name used to lookup user's home directory.
 
Constructor Summary
JConfig()
           
 
Method Summary
static void addListener(java.beans.PropertyChangeListener listener, java.lang.String defaults)
          Adds listener on any property change event.
static void addListener(java.beans.PropertyChangeListener listener, java.lang.String property, boolean defaults)
          Adds the listener.
static void addListener(java.beans.PropertyChangeListener listener, java.lang.String property, int defaults)
          Adds the listener.
static void addListener(java.beans.PropertyChangeListener listener, java.lang.String property, long defaults)
          Adds the listener.
static void addListener(java.beans.PropertyChangeListener listener, java.lang.String property, java.lang.String defaults)
          Adds the listener.
static ConfigString createConfigString(java.lang.String str)
          Creates the config string.
static java.io.File createDir(java.lang.String property, java.lang.String defaults)
          Creates the dir.
static JConfig.SearchPath[] createSearchPath(java.lang.String property)
          Creates the search path.
static SearchpathString createSearchString(java.lang.String str)
          Creates the search string.
static java.io.File getDir(JConfig.SearchPath[] paths)
          Gets the dir.
static java.io.File getDir(java.lang.String property)
          Gets the dir.
static java.lang.String getExpandedProperty(java.lang.String property)
          Gets the expanded property.
static java.lang.String getExpandedProperty(java.lang.String property, java.lang.String defaults)
          Gets the expanded property.
static java.io.File getFile(java.lang.String name, JConfig.SearchPath[] paths)
          Gets the file.
static java.io.File getFile(java.lang.String name, java.lang.String property)
          Gets the file.
static java.util.Map<java.lang.String,java.lang.String> getGlobalVariables()
          Gets the global variables.
static java.io.InputStream getInputStream(java.lang.String name, JConfig.SearchPath[] paths)
          Gets the input stream.
static java.io.InputStream getInputStream(java.lang.String name, java.lang.String property)
          Gets the input stream.
static java.lang.String getProperty(java.lang.String property)
          Gets the property.
static java.lang.String getProperty(java.lang.String property, java.lang.String defaults)
          Gets the property.
static java.io.InputStream getResourceInputStream(java.lang.String name)
          Gets the resource input stream.
static java.net.URL getResourceURL(java.lang.String name)
          Gets the resource url.
static java.util.Properties getTopProperties()
          Gets the top properties.
static java.net.URL getURL(java.lang.String name, java.lang.String property)
          Gets the uRL.
static java.util.Properties getUserProperties()
          Gets the user properties.
static void init()
          Inits the.
static void removeListener(java.beans.PropertyChangeListener listener)
          Removes the listener.
static void removeListener(java.beans.PropertyChangeListener listener, java.lang.String property)
          Removes the listener.
static java.lang.String setProperty(java.lang.String property, java.lang.String value)
          Sets the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_DIR_PROPERTY

public static final java.lang.String CACHE_DIR_PROPERTY
Java property for resolver directory where resolver files are saved. Property name is "jnetpcap.resolver.dir".

See Also:
Constant Field Values

CACHE_FILE_SUFFIX

public static final java.lang.String CACHE_FILE_SUFFIX
Suffix of a resolver file. Default is ".resolver".

See Also:
Constant Field Values

CACHE_FILE_SUFFIX_PROPERTY

public static final java.lang.String CACHE_FILE_SUFFIX_PROPERTY
Suffix of a resolver file. Property name is "jnetpcap.resolver.suffix".

See Also:
Constant Field Values

CACHE_SUB_DIR

public static final java.lang.String CACHE_SUB_DIR
If resolver directory is not explicitely defined with a property, this is the default sub directory name used in user's home directory for all resolver files. Default is ".jnp".

See Also:
Constant Field Values

CACHE_SUB_DIR_PROPERTY

public static final java.lang.String CACHE_SUB_DIR_PROPERTY
If resolver directory is not explicitely defined with a. "jnetpcap.resolver.dir", this is the default sub directory name used in user's home directory for all resolver files. The property name is "jnetpcap.resolver.subdir".

See Also:
Constant Field Values

RESOURCE_SEARCH_PATH_PROPERTY

public static final java.lang.String RESOURCE_SEARCH_PATH_PROPERTY
The Constant RESOURCE_SEARCH_PATH_PROPERTY.

See Also:
Constant Field Values

USER_HOME_PROPERTY

public static final java.lang.String USER_HOME_PROPERTY
System property name used to lookup user's home directory. The property name is "user.home".

See Also:
Constant Field Values
Constructor Detail

JConfig

public JConfig()
Method Detail

addListener

public static void addListener(java.beans.PropertyChangeListener listener,
                               java.lang.String defaults)
Adds listener on any property change event.

Parameters:
listener - the listener
defaults - the defaults

addListener

public static void addListener(java.beans.PropertyChangeListener listener,
                               java.lang.String property,
                               boolean defaults)
Adds the listener.

Parameters:
listener - the listener
property - the property
defaults - the defaults

addListener

public static void addListener(java.beans.PropertyChangeListener listener,
                               java.lang.String property,
                               int defaults)
Adds the listener.

Parameters:
listener - the listener
property - the property
defaults - the defaults

addListener

public static void addListener(java.beans.PropertyChangeListener listener,
                               java.lang.String property,
                               long defaults)
Adds the listener.

Parameters:
listener - the listener
property - the property
defaults - the defaults

addListener

public static void addListener(java.beans.PropertyChangeListener listener,
                               java.lang.String property,
                               java.lang.String defaults)
Adds the listener.

Parameters:
listener - the listener
property - the property
defaults - the defaults

createSearchPath

public static JConfig.SearchPath[] createSearchPath(java.lang.String property)
Creates the search path.

Parameters:
property - the property
Returns:
the search path[]

getFile

public static java.io.File getFile(java.lang.String name,
                                   JConfig.SearchPath[] paths)
                            throws java.io.IOException
Gets the file.

Parameters:
name - the name
paths - the paths
Returns:
the file
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getFile

public static java.io.File getFile(java.lang.String name,
                                   java.lang.String property)
                            throws java.io.IOException
Gets the file.

Parameters:
name - the name
property - the property
Returns:
the file
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getInputStream

public static java.io.InputStream getInputStream(java.lang.String name,
                                                 JConfig.SearchPath[] paths)
                                          throws java.io.IOException
Gets the input stream.

Parameters:
name - the name
paths - the paths
Returns:
the input stream
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getInputStream

public static java.io.InputStream getInputStream(java.lang.String name,
                                                 java.lang.String property)
                                          throws java.io.IOException
Gets the input stream.

Parameters:
name - the name
property - the property
Returns:
the input stream
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getProperty

public static java.lang.String getProperty(java.lang.String property)
Gets the property.

Parameters:
property - the property
Returns:
the property

getExpandedProperty

public static java.lang.String getExpandedProperty(java.lang.String property)
Gets the expanded property.

Parameters:
property - the property
Returns:
the expanded property

getExpandedProperty

public static java.lang.String getExpandedProperty(java.lang.String property,
                                                   java.lang.String defaults)
Gets the expanded property.

Parameters:
property - the property
defaults - the defaults
Returns:
the expanded property

getProperty

public static java.lang.String getProperty(java.lang.String property,
                                           java.lang.String defaults)
Gets the property.

Parameters:
property - the property
defaults - the defaults
Returns:
the property

getResourceInputStream

public static java.io.InputStream getResourceInputStream(java.lang.String name)
                                                  throws java.io.IOException
Gets the resource input stream.

Parameters:
name - the name
Returns:
the resource input stream
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getResourceURL

public static java.net.URL getResourceURL(java.lang.String name)
                                   throws java.io.IOException
Gets the resource url.

Parameters:
name - the name
Returns:
the resource url
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getURL

public static java.net.URL getURL(java.lang.String name,
                                  java.lang.String property)
                           throws java.io.IOException
Gets the uRL.

Parameters:
name - the name
property - the property
Returns:
the uRL
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

init

public static void init()
Inits the.


removeListener

public static void removeListener(java.beans.PropertyChangeListener listener)
Removes the listener.

Parameters:
listener - the listener

removeListener

public static void removeListener(java.beans.PropertyChangeListener listener,
                                  java.lang.String property)
Removes the listener.

Parameters:
listener - the listener
property - the property

setProperty

public static java.lang.String setProperty(java.lang.String property,
                                           java.lang.String value)
Sets the property.

Parameters:
property - the property
value - the value
Returns:
the string

getDir

public static java.io.File getDir(JConfig.SearchPath[] paths)
Gets the dir.

Parameters:
paths - the paths
Returns:
the dir

getDir

public static java.io.File getDir(java.lang.String property)
Gets the dir.

Parameters:
property - the property
Returns:
the dir

createDir

public static java.io.File createDir(java.lang.String property,
                                     java.lang.String defaults)
Creates the dir.

Parameters:
property - the property
defaults - the defaults
Returns:
the file

createConfigString

public static ConfigString createConfigString(java.lang.String str)
Creates the config string.

Parameters:
str - the str
Returns:
the config string

createSearchString

public static SearchpathString createSearchString(java.lang.String str)
Creates the search string.

Parameters:
str - the str
Returns:
the searchpath string

getTopProperties

public static java.util.Properties getTopProperties()
Gets the top properties.

Returns:
the top properties

getUserProperties

public static java.util.Properties getUserProperties()
Gets the user properties.

Returns:
the user properties

getGlobalVariables

public static java.util.Map<java.lang.String,java.lang.String> getGlobalVariables()
Gets the global variables.

Returns:
the global variables