Java Doc for ConfigurationUtils.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.configuration.ConfigurationUtils

ConfigurationUtils
final public class ConfigurationUtils (Code)
Miscellaneous utility methods for configurations.
See Also:   ConfigurationConverter
See Also:    Utility methods to convert configurations.
author:
   Herve Quiroz
author:
   Oliver Heger
author:
   Emmanuel Bourg
version:
   $Revision: 503227 $, $Date: 2007-02-03 17:19:15 +0100 (Sa, 03 Feb 2007) $


Field Summary
final static  StringPROTOCOL_FILE
     Constant for the file URL protocol.
final static  StringRESOURCE_PATH_SEPARATOR
     Constant for the resource path separator.


Method Summary
public static  voidappend(Configuration source, Configuration target)
     Append all properties from the source configuration to the target configuration.
static  Objectclone(Object obj)
     An internally used helper method for cloning objects.
public static  ConfigurationcloneConfiguration(Configuration config)
     Clones the given configuration object if this is possible.
static  FileconstructFile(String basePath, String fileName)
     Helper method for constructing a file object from a base path and a file name.
public static  HierarchicalConfigurationconvertToHierarchical(Configuration conf)
     Converts the passed in configuration to a hierarchical one.
public static  voidcopy(Configuration source, Configuration target)
     Copy all properties from the source configuration to the target configuration.
public static  voiddump(Configuration configuration, PrintStream out)
     Dump the configuration key/value mappings to some ouput stream.
public static  voiddump(Configuration configuration, PrintWriter out)
     Dump the configuration key/value mappings to some writer.
public static  voidenableRuntimeExceptions(Configuration src)
     Enables runtime exceptions for the specified configuration object.
public static  FilefileFromURL(URL url)
     Tries to convert the specified URL to a file object.
static  StringgetBasePath(URL url)
    
public static  FilegetFile(String basePath, String fileName)
     Tries to convert the specified base path and file name into a file object. This method is called e.g.
static  StringgetFileName(URL url)
     Extract the file name from the specified URL.
public static  URLgetURL(String basePath, String file)
     Constructs a URL from a base path and a file name.
public static  URLlocate(String name)
     Return the location of the specified resource by searching the user home directory, the current classpath and the system classpath.
public static  URLlocate(String base, String name)
     Return the location of the specified resource by searching the user home directory, the current classpath and the system classpath.
static  URLlocateFromClasspath(String resourceName)
     Tries to find a resource with the given name in the classpath.
public static  StringtoString(Configuration configuration)
     Get a string representation of the key/value mappings of a configuration.

Field Detail
PROTOCOL_FILE
final static String PROTOCOL_FILE(Code)
Constant for the file URL protocol.



RESOURCE_PATH_SEPARATOR
final static String RESOURCE_PATH_SEPARATOR(Code)
Constant for the resource path separator.





Method Detail
append
public static void append(Configuration source, Configuration target)(Code)
Append all properties from the source configuration to the target configuration. Properties in the source configuration are appended to the properties with the same key in the target configuration.
Parameters:
  source - the source configuration
Parameters:
  target - the target configuration
since:
   1.1



clone
static Object clone(Object obj) throws CloneNotSupportedException(Code)
An internally used helper method for cloning objects. This implementation is not very sophisticated nor efficient. Maybe it can be replaced by an implementation from Commons Lang later. The method checks whether the passed in object implements the 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.
Parameters:
  obj - the object to be cloned the cloned object
throws:
  CloneNotSupportedException - if the object cannot be cloned



cloneConfiguration
public static Configuration cloneConfiguration(Configuration config) throws ConfigurationRuntimeException(Code)
Clones the given configuration object if this is possible. If the passed in configuration object implements the Cloneable interface, its clone() method will be invoked. Otherwise an exception will be thrown.
Parameters:
  config - the configuration object to be cloned (can be null) the cloned configuration (null if the argument wasnull, too)
throws:
  ConfigurationRuntimeException - if cloning is not supported forthis object
since:
   1.3



constructFile
static File constructFile(String basePath, String fileName)(Code)
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
Parameters:
  fileName - the file name the resulting file



convertToHierarchical
public static HierarchicalConfiguration convertToHierarchical(Configuration conf)(Code)
Converts the passed in configuration to a hierarchical one. If the configuration is already hierarchical, it is directly returned. Otherwise all properties are copied into a new hierarchical configuration.
Parameters:
  conf - the configuration to convert the new hierarchical configuration (the result is null ifand only if the passed in configuration is null)
since:
   1.3



copy
public static void copy(Configuration source, Configuration target)(Code)
Copy all properties from the source configuration to the target configuration. Properties in the target configuration are replaced with the properties with the same key in the source configuration. Note: This method won't work well on hierarchical configurations because it is not able to copy information about the properties' structure. So when dealing with hierarchical configuration objects their HierarchicalConfiguration.clone clone() methods should be used.
Parameters:
  source - the source configuration
Parameters:
  target - the target configuration
since:
   1.1



dump
public static void dump(Configuration configuration, PrintStream out)(Code)
Dump the configuration key/value mappings to some ouput stream.
Parameters:
  configuration - the configuration
Parameters:
  out - the output stream to dump the configuration to



dump
public static void dump(Configuration configuration, PrintWriter out)(Code)
Dump the configuration key/value mappings to some writer.
Parameters:
  configuration - the configuration
Parameters:
  out - the writer to dump the configuration to



enableRuntimeExceptions
public static void enableRuntimeExceptions(Configuration src)(Code)
Enables runtime exceptions for the specified configuration object. This method can be used for configuration implementations that may face errors on normal property access, e.g. DatabaseConfiguration or JNDIConfiguration. Per default such errors are simply logged and then ignored. This implementation will register a special ConfigurationErrorListener that throws a runtime exception (namely a ConfigurationRuntimeException) on each received error event.
Parameters:
  src - the configuration, for which runtime exceptions are to beenabled; this configuration must be derived fromEventSource



fileFromURL
public static File fileFromURL(URL url)(Code)
Tries to convert the specified URL to a file object. If this fails, null is returned.
Parameters:
  url - the URL the resulting file object



getBasePath
static String getBasePath(URL url)(Code)
Return the path without the file name, for example http://xyz.net/foo/bar.xml results in http://xyz.net/foo/
Parameters:
  url - the URL from which to extract the path the path component of the passed in URL



getFile
public static File getFile(String basePath, String fileName)(Code)
Tries to convert the specified base path and file name into a file object. This method is called e.g. by the save() methods of file based configurations. The parameter strings can be relative files, absolute files and URLs as well. This implementation checks first whether the passed in file name is absolute. If this is the case, it is returned. Otherwise further checks are performed whether the base path and file name can be combined to a valid URL or a valid file name. Note: The test if the passed in file name is absolute is performed using java.io.File.isAbsolute(). If the file name starts with a slash, this method will return true on Unix, but false on Windows. So to ensure correct behavior for relative file names on all platforms you should never let relative paths start with a slash. E.g. in a configuration definition file do not use something like that:
 <properties fileName="/subdir/my.properties"/>
 
Under Windows this path would be resolved relative to the configuration definition file. Under Unix this would be treated as an absolute path name.
Parameters:
  basePath - the base path
Parameters:
  fileName - the file name the file object (null if no file can be obtained)



getFileName
static String getFileName(URL url)(Code)
Extract the file name from the specified URL.
Parameters:
  url - the URL from which to extract the file name the extracted file name



getURL
public static URL getURL(String basePath, String file) throws MalformedURLException(Code)
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)
Parameters:
  file - the file name the resulting URL
throws:
  MalformedURLException - if URLs are invalid



locate
public static URL locate(String name)(Code)
Return the location of the specified resource by searching the user home directory, the current classpath and the system classpath.
Parameters:
  name - the name of the resource the location of the resource



locate
public static URL locate(String base, String name)(Code)
Return the location of the specified resource by searching the user home directory, the current classpath and the system classpath.
Parameters:
  base - the base path of the resource
Parameters:
  name - the name of the resource the location of the resource



locateFromClasspath
static URL locateFromClasspath(String resourceName)(Code)
Tries to find a resource with the given name in the classpath.
Parameters:
  resourceName - the name of the resource the URL to the found resource or null if the resourcecannot be found



toString
public static String toString(Configuration configuration)(Code)
Get a string representation of the key/value mappings of a configuration.
Parameters:
  configuration - the configuration a string representation of the configuration



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.