|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.configuration.ConfigurationUtils
Miscellaneous utility methods for configurations.
Utility methods to convert configurations.
Field Summary | |
(package private) static String |
PROTOCOL_FILE
Constant for the file URL protocol. |
(package private) static String |
RESOURCE_PATH_SEPARATOR
Constant for the resource path separator. |
Method Summary | |
static void |
append(Configuration source,
Configuration target)
Append all properties from the source configuration to the target configuration. |
(package private) static Object |
clone(Object obj)
An internally used helper method for cloning objects. |
static Configuration |
cloneConfiguration(Configuration config)
Clones the given configuration object if this is possible. |
(package private) static File |
constructFile(String basePath,
String fileName)
Helper method for constructing a file object from a base path and a file name. |
static HierarchicalConfiguration |
convertToHierarchical(Configuration conf)
Converts the passed in configuration to a hierarchical one. |
static void |
copy(Configuration source,
Configuration target)
Copy all properties from the source configuration to the target configuration. |
static void |
dump(Configuration configuration,
PrintStream out)
Dump the configuration key/value mappings to some ouput stream. |
static void |
dump(Configuration configuration,
PrintWriter out)
Dump the configuration key/value mappings to some writer. |
static File |
fileFromURL(URL url)
Tries to convert the specified URL to a file object. |
(package private) static String |
getBasePath(URL url)
Return the path without the file name, for example http://xyz.net/foo/bar.xml results in http://xyz.net/foo/ |
static File |
getFile(String basePath,
String fileName)
Tries to convert the specified base path and file name into a file object. |
(package private) static String |
getFileName(URL url)
Extract the file name from the specified URL. |
static URL |
getURL(String basePath,
String file)
Constructs a URL from a base path and a file name. |
static URL |
locate(String name)
Return the location of the specified resource by searching the user home directory, the current classpath and the system classpath. |
static URL |
locate(String base,
String name)
Return the location of the specified resource by searching the user home directory, the current classpath and the system classpath. |
(package private) static URL |
locateFromClasspath(String resourceName)
Tries to find a resource with the given name in the classpath. |
static 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 |
static final String PROTOCOL_FILE
static final String RESOURCE_PATH_SEPARATOR
Method Detail |
public static void dump(Configuration configuration, PrintStream out)
configuration
- the configurationout
- the output stream to dump the configuration topublic static void dump(Configuration configuration, PrintWriter out)
configuration
- the configurationout
- the writer to dump the configuration topublic static String toString(Configuration configuration)
configuration
- the configuration
public static void copy(Configuration source, Configuration target)
clone()
methods
should be used.
source
- the source configurationtarget
- the target configurationpublic static void append(Configuration source, Configuration target)
source
- the source configurationtarget
- the target configurationpublic static HierarchicalConfiguration convertToHierarchical(Configuration conf)
conf
- the configuration to convert
public static Configuration cloneConfiguration(Configuration config) throws ConfigurationRuntimeException
Cloneable
interface, its clone()
method will be invoked. Otherwise
an exception will be thrown.
config
- the configuration object to be cloned (can be null)
ConfigurationRuntimeException
- if cloning is not supported for
this objectstatic Object clone(Object obj) throws CloneNotSupportedException
Cloneable
interface. If
this is the case, the clone()
method is invoked by
reflection. Errors that occur during the cloning process are re-thrown as
runtime exceptions.
obj
- the object to be cloned
CloneNotSupportedException
- if the object cannot be clonedpublic static URL getURL(String basePath, String file) throws MalformedURLException
basePath
- the base path URL (can be null)file
- the file name
MalformedURLException
- if URLs are invalidstatic File constructFile(String basePath, String fileName)
getURL()
does not seem to be a valid URL.
basePath
- the base pathfileName
- the file name
public static URL locate(String name)
name
- the name of the resource
public static URL locate(String base, String name)
base
- the base path of the resourcename
- the name of the resource
static URL locateFromClasspath(String resourceName)
resourceName
- the name of the resource
static String getBasePath(URL url)
url
- the URL from which to extract the path
static String getFileName(URL url)
url
- the URL from which to extract the file name
public static File getFile(String basePath, String fileName)
basePath
- the base pathfileName
- the file name
public static File fileFromURL(URL url)
url
- the URL
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |