org.apache.commons.configuration
Class ConfigurationUtils

java.lang.Object
  extended byorg.apache.commons.configuration.ConfigurationUtils

public class ConfigurationUtils
extends java.lang.Object

Miscellaneous utility methods for configurations.

Author:
Herve Quiroz, Oliver Heger

Field Summary
protected static java.lang.String fileSeparator
          File separator.
 
Constructor Summary
private ConfigurationUtils()
           
 
Method Summary
(package private) static java.io.File constructFile(java.lang.String basePath, java.lang.String fileName)
          Helper method for constructing a file object from a base path and a file name.
static void dump(Configuration configuration, java.io.PrintStream out)
          Dump the configuration key/value mappings to some ouput stream.
static void dump(Configuration configuration, java.io.PrintWriter out)
          Dump the configuration key/value mappings to some writer.
static java.net.URL getURL(java.lang.String basePath, java.lang.String file)
          Constructs a URL from a base path and a file name.
static java.lang.String toString(Configuration configuration)
          Get a string representation of the key/value mappings of a configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileSeparator

protected static java.lang.String fileSeparator
File separator.

Constructor Detail

ConfigurationUtils

private ConfigurationUtils()
Method Detail

dump

public static void dump(Configuration configuration,
                        java.io.PrintStream out)
Dump the configuration key/value mappings to some ouput stream.

Parameters:
configuration - the configuration
out - the output stream to dump the configuration to

dump

public static void dump(Configuration configuration,
                        java.io.PrintWriter out)
Dump the configuration key/value mappings to some writer.

Parameters:
configuration - the configuration
out - the writer to dump the configuration to

toString

public static java.lang.String toString(Configuration configuration)
Get a string representation of the key/value mappings of a configuration.

Parameters:
configuration - the configuration
Returns:
a string representation of the configuration

getURL

public static java.net.URL getURL(java.lang.String basePath,
                                  java.lang.String file)
                           throws java.net.MalformedURLException
Constructs a URL from a base path and a file name. The file name can be absolute, relative or a full URL. If necessary the base path URL is applied.

Parameters:
basePath - the base path URL (can be null)
file - the file name
Returns:
the resulting URL
Throws:
java.net.MalformedURLException - if URLs are invalid

constructFile

static java.io.File constructFile(java.lang.String basePath,
                                  java.lang.String fileName)
Helper method for constructing a file object from a base path and a file name. This method is called if the base path passed to getURL() does not seem to be a valid URL.

Parameters:
basePath - the base path
fileName - the file name
Returns:
the resulting file