henplus.io
Class ConfigurationContainer

java.lang.Object
  extended by henplus.io.ConfigurationContainer

public final class ConfigurationContainer
extends Object

Helper class to write the configuration. Focus is to avoid half-written configuration files if IO-Errors occur (full harddisk ..) and to merge properties.

Version:
$Revision: 1.1 $
Author:
hzeller

Nested Class Summary
static interface ConfigurationContainer.ReadAction
           
static interface ConfigurationContainer.WriteAction
           
 
Constructor Summary
ConfigurationContainer(File file)
           
 
Method Summary
 void read(ConfigurationContainer.ReadAction action)
          Execute the read action with the InputStream from the corresponding configuration file.
 Map readProperties()
           
 Map readProperties(Map prefill)
          convenience-method to read properties.
 void storeProperties(Map props, boolean allowMerge, String comment)
          convenience-method to write properties.
 void write(ConfigurationContainer.WriteAction action)
          Write configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationContainer

public ConfigurationContainer(File file)
Method Detail

read

public void read(ConfigurationContainer.ReadAction action)
Execute the read action with the InputStream from the corresponding configuration file.


write

public void write(ConfigurationContainer.WriteAction action)
Write configuration. The configuration is first written to a temporary file. Does not overwrite the original file if any Exception occurs in the course of this or the resulting file is no different.


readProperties

public Map readProperties()

readProperties

public Map readProperties(Map prefill)
convenience-method to read properties. If you handle simple properties within your command, then use this method so that versioning and merging is handled.


storeProperties

public void storeProperties(Map props,
                            boolean allowMerge,
                            String comment)
convenience-method to write properties. Properties must have been read before.

Parameters:
allowMerge - allow merging of properties that have been added by another instance of henplus.


? 1997..2006 Henner Zeller