public final class ConfigurationUtils extends Object
| Modifier and Type | Method and Description | 
|---|---|
static void | 
append(Configuration source,
      Configuration target)
Append all properties from the source configuration to the target
 configuration. 
 | 
static void | 
append(ImmutableConfiguration source,
      Configuration target)
Append all properties from the source configuration to the target
 configuration. 
 | 
static EventSource | 
asEventSource(Object obj,
             boolean mockIfUnsupported)
Casts the specified object to an  
EventSource if possible. | 
static Configuration | 
cloneConfiguration(Configuration config)
Clones the given configuration object if this is possible. 
 | 
static Object | 
cloneIfPossible(Object obj)
Returns a clone of the passed in object if cloning is supported or the
 object itself if not. 
 | 
static Synchronizer | 
cloneSynchronizer(Synchronizer sync)
Creates a clone of the specified  
Synchronizer. | 
static HierarchicalConfiguration<?> | 
convertToHierarchical(Configuration conf)
Converts the passed in configuration to a hierarchical one. 
 | 
static HierarchicalConfiguration<?> | 
convertToHierarchical(Configuration conf,
                     ExpressionEngine engine)
Converts the passed in  
Configuration object to a
 hierarchical one using the specified ExpressionEngine. | 
static void | 
copy(Configuration source,
    Configuration target)
Copy all properties from the source configuration to the target
 configuration. 
 | 
static void | 
copy(ImmutableConfiguration 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 void | 
dump(ImmutableConfiguration configuration,
    PrintStream out)
Dump the configuration key/value mappings to some ouput stream. 
 | 
static void | 
dump(ImmutableConfiguration configuration,
    PrintWriter out)
Dump the configuration key/value mappings to some writer. 
 | 
static void | 
enableRuntimeExceptions(Configuration src)
Enables runtime exceptions for the specified configuration object. 
 | 
static Class<?> | 
loadClass(String clsName)
Loads the class with the given name. 
 | 
static Class<?> | 
loadClassNoEx(String clsName)
Loads the class with the specified name re-throwing
  
ClassNotFoundException exceptions as runtime exceptions. | 
static String | 
toString(Configuration configuration)
Get a string representation of the key/value mappings of a
 configuration. 
 | 
static String | 
toString(ImmutableConfiguration configuration)
Get a string representation of the key/value mappings of a
 configuration. 
 | 
static ImmutableConfiguration | 
unmodifiableConfiguration(Configuration c)
Creates an  
ImmutableConfiguration from the given
 Configuration object. | 
static ImmutableHierarchicalConfiguration | 
unmodifiableConfiguration(HierarchicalConfiguration<?> c)
Creates an  
ImmutableHierarchicalConfiguration from the given
 HierarchicalConfiguration object. | 
public static void dump(ImmutableConfiguration configuration, PrintStream out)
configuration - the configurationout - the output stream to dump the configuration topublic static void dump(Configuration configuration, PrintStream out)
configuration - the configurationout - the output stream to dump the configuration topublic static void dump(ImmutableConfiguration configuration, PrintWriter out)
configuration - the configurationout - the writer 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(ImmutableConfiguration configuration)
configuration - the configurationpublic static String toString(Configuration configuration)
configuration - the configurationpublic static void copy(ImmutableConfiguration source, Configuration target)
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 is not able to handle some specifics of
 configurations derived from AbstractConfiguration (e.g.
 list delimiters). For a full support of all of these features the
 copy() method of AbstractConfiguration should
 be used. In a future release this method might become deprecated.
source - the source configurationtarget - the target configurationpublic static void copy(Configuration source, Configuration target)
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 is not able to handle some specifics of
 configurations derived from AbstractConfiguration (e.g.
 list delimiters). For a full support of all of these features the
 copy() method of AbstractConfiguration should
 be used. In a future release this method might become deprecated.
source - the source configurationtarget - the target configurationpublic static void append(ImmutableConfiguration source, Configuration target)
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.
Note: This method is not able to handle some specifics of
 configurations derived from AbstractConfiguration (e.g.
 list delimiters). For a full support of all of these features the
 copy() method of AbstractConfiguration should
 be used. In a future release this method might become deprecated.
source - the source configurationtarget - the target configurationpublic static void append(Configuration source, Configuration target)
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.
Note: This method is not able to handle some specifics of
 configurations derived from AbstractConfiguration (e.g.
 list delimiters). For a full support of all of these features the
 copy() method of AbstractConfiguration should
 be used. In a future release this method might become deprecated.
source - the source configurationtarget - the target configurationpublic static HierarchicalConfiguration<?> convertToHierarchical(Configuration conf)
conf - the configuration to convertpublic static HierarchicalConfiguration<?> convertToHierarchical(Configuration conf, ExpressionEngine engine)
Configuration object to a
 hierarchical one using the specified ExpressionEngine. This
 conversion works by adding the keys found in the configuration to a newly
 created hierarchical configuration. When adding new keys to a
 hierarchical configuration the keys are interpreted by its
 ExpressionEngine. If they contain special characters (e.g.
 brackets) that are treated in a special way by the default expression
 engine, it may be necessary using a specific engine that can deal with
 such characters. Otherwise null can be passed in for the
 ExpressionEngine; then the default expression engine is
 used. If the passed in configuration is already hierarchical, it is
 directly returned. (However, the ExpressionEngine is set if
 it is not null.) Otherwise all properties are copied into a new
 hierarchical configuration.conf - the configuration to convertengine - the ExpressionEngine for the hierarchical
        configuration or null for the defaultpublic 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 objectpublic static Object cloneIfPossible(Object obj)
Cloneable interface. If this is the case, the
 clone() method is invoked. Otherwise, the object is directly
 returned. Errors that might occur during reflection calls are caught and
 also cause this method to return the original object.obj - the object to be clonedpublic static Synchronizer cloneSynchronizer(Synchronizer sync)
Synchronizer. This method can be
 called by clone() implementations in configuration classes that
 also need to copy the Synchronizer object. This method can handle
 some well-known Synchronizer implementations directly. For other
 classes, it uses the following algorithm:
 Synchronizer has a standard constructor,
 a new instance is created using reflection.ConfigurationRuntimeException is thrown.sync - the Synchronizer object to be clonedSynchronizerConfigurationRuntimeException - if no clone can be createdIllegalArgumentException - if null is passed inpublic static void enableRuntimeExceptions(Configuration src)
DatabaseConfiguration or
 JNDIConfiguration. Per default such errors are simply
 logged and then ignored. This implementation will register a special
 EventListener that throws a runtime
 exception (namely a ConfigurationRuntimeException) on
 each received error event.src - the configuration, for which runtime exceptions are to be
 enabled; this configuration must implement EventSourcepublic static Class<?> loadClass(String clsName) throws ClassNotFoundException
clsName - the name of the class to be loadedClassNotFoundException - if the class cannot be resolvedpublic static Class<?> loadClassNoEx(String clsName)
ClassNotFoundException exceptions as runtime exceptions. This
 method works like loadClass(String). However, checked exceptions
 are caught and re-thrown as ConfigurationRuntimeException.clsName - the name of the class to be loadedConfigurationRuntimeException - if the class cannot be resolvedpublic static ImmutableConfiguration unmodifiableConfiguration(Configuration c)
ImmutableConfiguration from the given
 Configuration object. This method creates a proxy object wrapping
 the original configuration and making it available under the
 ImmutableConfiguration interface. Through this interface the
 configuration cannot be manipulated. It is also not possible to cast the
 returned object back to a Configuration instance to circumvent
 this protection.c - the Configuration to be wrapped (must not be
        null)ImmutableConfiguration view on the specified
         Configuration objectNullPointerException - if the passed in Configuration is
         nullpublic static ImmutableHierarchicalConfiguration unmodifiableConfiguration(HierarchicalConfiguration<?> c)
ImmutableHierarchicalConfiguration from the given
 HierarchicalConfiguration object. This method works exactly like
 the method with the same name, but it operates on hierarchical
 configurations.c - the HierarchicalConfiguration to be wrapped (must not be
        null)ImmutableHierarchicalConfiguration view on the
         specified HierarchicalConfiguration objectNullPointerException - if the passed in
         HierarchicalConfiguration is nullpublic static EventSource asEventSource(Object obj, boolean mockIfUnsupported)
EventSource if possible. The
 boolean argument determines the method's behavior if the object does not
 implement the EventSource event: if set to false, a
 ConfigurationRuntimeException is thrown; if set to true, a
 dummy EventSource is returned; on this object all methods can be
 called, but they do not have any effect.obj - the object to be cast as EventSourcemockIfUnsupported - a flag whether a mock object should be returned
        if necessaryEventSourceConfigurationRuntimeException - if the object cannot be cast to
         EventSource and the mock flag is falseCopyright © 2001–2020 The Apache Software Foundation. All rights reserved.