org.glite.slcs.config
Class SLCSConfiguration

java.lang.Object
  extended by org.glite.slcs.config.SLCSConfiguration

public abstract class SLCSConfiguration
extends java.lang.Object

SLCSConfiguration is a wrapper class for a XML file based configuration.

Version:
$Revision: 1.7 $
Author:
Valery Tschopp
See Also:
XMLConfiguration

Constructor Summary
protected SLCSConfiguration()
          Default constructor
protected SLCSConfiguration(java.lang.String filename)
           
 
Method Summary
protected abstract  void checkConfiguration()
          Checks the validity of the configuration
 boolean contains(java.lang.String name)
          Checks if configuration key name is defined
protected static org.apache.commons.configuration.FileConfiguration downloadConfiguration(java.net.URL url)
          Creates a XMLConfiguration loaded from the given url.
 org.apache.commons.configuration.Configuration getConfiguration()
           
 org.apache.commons.configuration.FileConfiguration getFileConfiguration()
           
protected  java.lang.String getFilename()
           
 int getInt(java.lang.String name)
           
 java.util.List getList(java.lang.String name)
           
 java.lang.String getString(java.lang.String name)
          Returns the value of the key and throw exception if the key is not defined.
 java.lang.String getString(java.lang.String name, boolean throwException)
          Returns the value of the key and throw exception if the key is not defined only if throwException is true.
protected static org.apache.commons.configuration.FileConfiguration loadConfiguration(java.lang.String filename)
          Creates a XMLConfiguration loaded with the given file.
protected  void setFileConfiguration(org.apache.commons.configuration.FileConfiguration configuration)
          Sets the FileConfiguration and checks for validity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SLCSConfiguration

protected SLCSConfiguration()
Default constructor


SLCSConfiguration

protected SLCSConfiguration(java.lang.String filename)
                     throws SLCSConfigurationException
Parameters:
filename -
Throws:
SLCSConfigurationException
Method Detail

loadConfiguration

protected static org.apache.commons.configuration.FileConfiguration loadConfiguration(java.lang.String filename)
                                                                               throws SLCSConfigurationException
Creates a XMLConfiguration loaded with the given file.

Parameters:
filename - The file name to load the XML configuration from.
Returns:
The new FileConfiguration object
Throws:
SLCSConfigurationException - If a configuration error occurs while loading the XML file.

downloadConfiguration

protected static org.apache.commons.configuration.FileConfiguration downloadConfiguration(java.net.URL url)
                                                                                   throws SLCSConfigurationException
Creates a XMLConfiguration loaded from the given url.

Parameters:
url - The URL of the file to load the XML configuration from.
Returns:
The new FileConfiguration object
Throws:
SLCSConfigurationException - If a configuration error occurs while downloading and loading the XML file.

checkConfiguration

protected abstract void checkConfiguration()
                                    throws SLCSConfigurationException
Checks the validity of the configuration

Throws:
SLCSConfigurationException - iff the configuration is not valid

getString

public java.lang.String getString(java.lang.String name)
                           throws SLCSConfigurationException
Returns the value of the key and throw exception if the key is not defined.

Parameters:
name - The key of the value to get
Returns:
The value of for this key
Throws:
SLCSConfigurationException - if the key is missing from configuration or empty

getString

public java.lang.String getString(java.lang.String name,
                                  boolean throwException)
                           throws SLCSConfigurationException
Returns the value of the key and throw exception if the key is not defined only if throwException is true.

Parameters:
name - The key name of the value to read.
throwException - Throw an exception if the key is not found or not.
Returns:
The value or null if the key is not found or the value empty.
Throws:
SLCSConfigurationException

getInt

public int getInt(java.lang.String name)
Parameters:
name -
Returns:

getList

public java.util.List getList(java.lang.String name)
Parameters:
name - The configuration key.
Returns:
The associated List. Empty if the name is not in configuration.

contains

public boolean contains(java.lang.String name)
Checks if configuration key name is defined

Parameters:
name - The configuration key name.
Returns:
true iff the key is defined, false otherwise.

setFileConfiguration

protected void setFileConfiguration(org.apache.commons.configuration.FileConfiguration configuration)
                             throws SLCSConfigurationException
Sets the FileConfiguration and checks for validity.

Parameters:
configuration - The FileConfiguration to set.
Throws:
SLCSConfigurationException

getFileConfiguration

public org.apache.commons.configuration.FileConfiguration getFileConfiguration()
Returns:
The FileConfiguration interface.

getConfiguration

public org.apache.commons.configuration.Configuration getConfiguration()
Returns:
The Configuration interface.

getFilename

protected java.lang.String getFilename()
Returns:
The XML configuration absolute filename.