org.montsuqi.client
Class Configuration

java.lang.Object
  extended by org.montsuqi.client.Configuration

public class Configuration
extends java.lang.Object

A class to manage configuration settings of the application.

Configuration is stored using the Preferences API. On Unix based systems, it is stored in XML files somewhere in user's home directory. On Windows, it is stored in the registry.


Field Summary
(package private) static java.lang.String DEFAULT_APPLICATION
          Default application name: "demo".
(package private) static java.lang.String DEFAULT_CACHE_PATH
          Default cache directory: [value of System property user.home]/.monsiaj/cache
(package private) static java.lang.String DEFAULT_CLIENT_CERTIFICATE
          Default client certificate path: empty string.
(package private) static java.lang.String DEFAULT_CLIENT_CERTIFICATE_PASSWORD
          Default client certificate password: empty string.
(package private) static java.lang.String DEFAULT_ENCODING
          Default encoding for the stream: EUC-JP.
(package private) static java.lang.String DEFAULT_HOST
          Default host: localhost
(package private) static java.lang.String DEFAULT_LOOK_AND_FEEL_CLASS_NAME
          Default look and feel class name: system look and feel.
(package private) static java.lang.String DEFAULT_PASSWORD
          Default password: empty string.
(package private) static int DEFAULT_PORT
          Default port: 8000
(package private) static int DEFAULT_PROTOCOL_VERSION
          Default protocol version: 1.
(package private) static boolean DEFAULT_SAVE_CLIENT_CERTIFICATE_PASSWORD
          Default value of save client certificate password checkbox: false.
(package private) static boolean DEFAULT_SAVE_PASSWORD
          Default value of save password checkbox: false.
(package private) static java.lang.String DEFAULT_STYLE_RESOURCE_NAME
          Default style resource name: /org/montsuqi/client/style.properteis.
(package private) static java.lang.String DEFAULT_STYLES
          Default style definitions: empty string.
(package private) static boolean DEFAULT_USE_LOG_VIEWER
          Default value of use log viewer checkbox: false.
(package private) static boolean DEFAULT_USE_SSL
          Default value of use SSL checkbox: false.
(package private) static java.lang.String DEFAULT_USER
          Default user: value of System property user.name.
protected static Logger logger
           
 
Constructor Summary
Configuration(java.lang.Class clazz)
          Constructs a configuration object.
 
Method Summary
 java.lang.String getApplication()
          Returns the name of the application.
protected  boolean getBoolean(java.lang.String key, boolean defaultValue)
          Returns configuration value(boolean).
 java.lang.String getCache()
          Returns the cache directory.
 java.lang.String getClientCertificateFileName()
          Returns the name of client certificate file.
 java.lang.String getClientCertificatePassword()
          Returns the client certificate password.
 java.lang.String getEncoding()
          Returns the encoding.
 java.lang.String getHost()
          Returns the host.
protected  int getInt(java.lang.String key, int defaultValue)
          Returns configuration value(int).
 java.lang.String getLookAndFeelClassName()
          Returns the look and feel class name.
 java.lang.String getPass()
          Returns the password.
 int getPort()
          Returns the port.
 java.lang.String getProperties()
          Returns other properties as string.
 int getProtocolVersion()
          Returns the protocol version.
 boolean getSaveClientCertificatePassword()
          Returns the value of save client certificate password.
 boolean getSavePassword()
          Returns the value of save password.
protected  java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Returns configuration value(String).
 java.lang.String getStyleFileName()
          Returns the style file name.
 java.net.URL getStyleURL()
          Returns the style URL.
 boolean getUseLogViewer()
          Returns the value of use log viewer.
 java.lang.String getUser()
          Returns the user.
 boolean getUseSSL()
          Returns the value of use SSL.
protected  void save()
          Ensures the configuration is saved.
 void setApplication(java.lang.String app)
          Sets the name of the application.
protected  void setBoolean(java.lang.String key, boolean value)
          Sets configuration value(boolean).
 void setCache(java.lang.String cache)
          Sets the cache directory.
 void setClientCertificateFileName(java.lang.String fileName)
          Sets the name of client certificate file.
 void setClientCertificatePassword(java.lang.String pass)
          Sets the client certificate password.
 void setEncoding(java.lang.String encoding)
          Sets the encoding.
 void setHost(java.lang.String host)
          Sets the host.
protected  void setInt(java.lang.String key, int value)
          Sets configuration value(int).
 void setLookAndFeelClassName(java.lang.String className)
          Sets the look and feel class name.
 void setPass(java.lang.String pass)
          Sets the password.
 void setPort(int port)
          Sets the port.
 void setProperties(java.lang.String properties)
          Sets other properties.
 void setProtocolVersion(int version)
          Sets the protocol version.
 void setSaveClientCertificatePassword(boolean flag)
          Sets the value of save client certificate password.
 void setSavePassword(boolean flag)
          Sets the value of save password.
protected  void setString(java.lang.String key, java.lang.String value)
          Sets configuration value(String).
 void setStyleFileName(java.lang.String styles)
          Sets the style file name.
 void setUseLogViewer(boolean flag)
          Sets the value of use log viewer.
 void setUser(java.lang.String user)
          Sets the user.
 void setUseSSL(boolean flag)
          Sets the value of use SSL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

static final int DEFAULT_PORT

Default port: 8000

See Also:
Constant Field Values

DEFAULT_HOST

static final java.lang.String DEFAULT_HOST

Default host: localhost

See Also:
Constant Field Values

DEFAULT_USER

static final java.lang.String DEFAULT_USER

Default user: value of System property user.name.


DEFAULT_PASSWORD

static final java.lang.String DEFAULT_PASSWORD

Default password: empty string.

See Also:
Constant Field Values

DEFAULT_CLIENT_CERTIFICATE_PASSWORD

static final java.lang.String DEFAULT_CLIENT_CERTIFICATE_PASSWORD

Default client certificate password: empty string.

See Also:
Constant Field Values

DEFAULT_CLIENT_CERTIFICATE

static final java.lang.String DEFAULT_CLIENT_CERTIFICATE

Default client certificate path: empty string.

See Also:
Constant Field Values

DEFAULT_SAVE_PASSWORD

static final boolean DEFAULT_SAVE_PASSWORD

Default value of save password checkbox: false.

See Also:
Constant Field Values

DEFAULT_APPLICATION

static final java.lang.String DEFAULT_APPLICATION

Default application name: "demo".

See Also:
Constant Field Values

DEFAULT_ENCODING

static final java.lang.String DEFAULT_ENCODING

Default encoding for the stream: EUC-JP.

See Also:
Constant Field Values

DEFAULT_CACHE_PATH

static final java.lang.String DEFAULT_CACHE_PATH

Default cache directory: [value of System property user.home]/.monsiaj/cache


DEFAULT_STYLES

static final java.lang.String DEFAULT_STYLES

Default style definitions: empty string.

See Also:
Constant Field Values

DEFAULT_STYLE_RESOURCE_NAME

static final java.lang.String DEFAULT_STYLE_RESOURCE_NAME

Default style resource name: /org/montsuqi/client/style.properteis.

See Also:
Constant Field Values

DEFAULT_USE_SSL

static final boolean DEFAULT_USE_SSL

Default value of use SSL checkbox: false.

See Also:
Constant Field Values

DEFAULT_SAVE_CLIENT_CERTIFICATE_PASSWORD

static final boolean DEFAULT_SAVE_CLIENT_CERTIFICATE_PASSWORD

Default value of save client certificate password checkbox: false.

See Also:
Constant Field Values

DEFAULT_PROTOCOL_VERSION

static final int DEFAULT_PROTOCOL_VERSION

Default protocol version: 1.

See Also:
Constant Field Values

DEFAULT_LOOK_AND_FEEL_CLASS_NAME

static final java.lang.String DEFAULT_LOOK_AND_FEEL_CLASS_NAME

Default look and feel class name: system look and feel.


DEFAULT_USE_LOG_VIEWER

static final boolean DEFAULT_USE_LOG_VIEWER

Default value of use log viewer checkbox: false.

See Also:
Constant Field Values

logger

protected static final Logger logger
Constructor Detail

Configuration

public Configuration(java.lang.Class clazz)

Constructs a configuration object.

Parameters:
clazz - class object used to obtain user preference node.
Method Detail

save

protected void save()

Ensures the configuration is saved.


getPass

public java.lang.String getPass()

Returns the password.

If save password is set to false, it always returns DEFAULT_PASSWORD("").

Returns:
the password or empty string.

setPass

public void setPass(java.lang.String pass)

Sets the password.

It stores the new password into the member field.

If save password is set to true, it also store the password into the configuration, otherwise it sets the DEFAULT_PASSWORD("") to clear it.

Parameters:
pass - the new password.

getSavePassword

public boolean getSavePassword()

Returns the value of save password.

Returns:
value of save password.


setSavePassword

public void setSavePassword(boolean flag)

Sets the value of save password.

Parameters:
flag - new value of save password.

getClientCertificatePassword

public java.lang.String getClientCertificatePassword()

Returns the client certificate password.

If save password is set to false, it always returns DEFAULT_PASSWORD("").

Returns:
the password or empty string.

setClientCertificatePassword

public void setClientCertificatePassword(java.lang.String pass)

Sets the client certificate password.

It stores the new password into the member field.

If save client password is set to true, it also store the password into the configuration, otherwise it sets the DEFAULT_PASSWORD("") to clear it.

Parameters:
pass - the new password.

getSaveClientCertificatePassword

public boolean getSaveClientCertificatePassword()

Returns the value of save client certificate password.

Returns:
value of save client certificate password.


setSaveClientCertificatePassword

public void setSaveClientCertificatePassword(boolean flag)

Sets the value of save client certificate password.

Parameters:
flag - new value of save client certificate password.

getPort

public int getPort()

Returns the port.

Returns:
the port number.

setPort

public void setPort(int port)

Sets the port.

Parameters:
port - new value of the port.

getHost

public java.lang.String getHost()

Returns the host.

Returns:
the host.

setHost

public void setHost(java.lang.String host)

Sets the host.

Parameters:
host - new value of the host.

getUser

public java.lang.String getUser()

Returns the user.

Returns:
the user.

setUser

public void setUser(java.lang.String user)

Sets the user.

Parameters:
user - new value of the user.

getCache

public java.lang.String getCache()

Returns the cache directory.

Returns:
the cache directory.

setCache

public void setCache(java.lang.String cache)

Sets the cache directory.

Parameters:
cache - new value of the cache directory.

getEncoding

public java.lang.String getEncoding()

Returns the encoding.

Returns:
the encoding.

setEncoding

public void setEncoding(java.lang.String encoding)

Sets the encoding.

Parameters:
encoding - new value of the encoding.

getStyleURL

public java.net.URL getStyleURL()

Returns the style URL.

It first tries converting style file name specified in the configuration to URL. If it fails it falls back to default style resource.

Returns:
the style URL.

getStyleFileName

public java.lang.String getStyleFileName()

Returns the style file name.

Returns:
the style file name.

setStyleFileName

public void setStyleFileName(java.lang.String styles)

Sets the style file name.

Parameters:
styles - new value of style file name.

getApplication

public java.lang.String getApplication()

Returns the name of the application.

Returns:
the name of the application.

setApplication

public void setApplication(java.lang.String app)

Sets the name of the application.

Parameters:
app - new value of the name of the pplication.

getUseSSL

public boolean getUseSSL()

Returns the value of use SSL.

Returns:
true if using SSL. false otherwise.

setUseSSL

public void setUseSSL(boolean flag)

Sets the value of use SSL.

Parameters:
flag - new value of use SSL.

getClientCertificateFileName

public java.lang.String getClientCertificateFileName()

Returns the name of client certificate file.

Returns:
the name of client certificate.

setClientCertificateFileName

public void setClientCertificateFileName(java.lang.String fileName)

Sets the name of client certificate file.

Parameters:
fileName - new name of client certificate file.

getProtocolVersion

public int getProtocolVersion()

Returns the protocol version.

Returns:
protocol version.

setProtocolVersion

public void setProtocolVersion(int version)

Sets the protocol version.

Parameters:
version - version number(1 or 2).

getLookAndFeelClassName

public java.lang.String getLookAndFeelClassName()

Returns the look and feel class name.

Returns:
look and feel class name.

setLookAndFeelClassName

public void setLookAndFeelClassName(java.lang.String className)

Sets the look and feel class name.

Parameters:
className - look and feel class name.

getUseLogViewer

public boolean getUseLogViewer()

Returns the value of use log viewer.

Returns:
the value of use log viewer.

setUseLogViewer

public void setUseLogViewer(boolean flag)

Sets the value of use log viewer.

Parameters:
flag - new value of use log viewer.

getProperties

public java.lang.String getProperties()

Returns other properties as string.


setProperties

public void setProperties(java.lang.String properties)

Sets other properties.

Parameters:
properties - new line separated property assignments.

getString

protected java.lang.String getString(java.lang.String key,
                                     java.lang.String defaultValue)

Returns configuration value(String).

Parameters:
key - configuration key.
defaultValue - value if the configuration for the given key is missing.
Returns:
the configuration value.

getInt

protected int getInt(java.lang.String key,
                     int defaultValue)

Returns configuration value(int).

Parameters:
key - configuration key.
defaultValue - value if the configuration for the given key is missing.
Returns:
the configuration value.

getBoolean

protected boolean getBoolean(java.lang.String key,
                             boolean defaultValue)

Returns configuration value(boolean).

Parameters:
key - configuration key.
defaultValue - value if the configuration for the given key is missing.
Returns:
the configuration value.

setString

protected void setString(java.lang.String key,
                         java.lang.String value)

Sets configuration value(String).

Parameters:
key - configuration key.
value - the configuration value.

setInt

protected void setInt(java.lang.String key,
                      int value)

Sets configuration value(int).

Parameters:
key - configuration key.
value - the configuration value.

setBoolean

protected void setBoolean(java.lang.String key,
                          boolean value)

Sets configuration value(boolean).

Parameters:
key - configuration key.
value - the configuration value.