org.jfree.util
Class SortedConfigurationWriter

java.lang.Object
  extended by org.jfree.util.SortedConfigurationWriter

public class SortedConfigurationWriter
extends java.lang.Object

Writes a Configuration instance into a property file, where the keys are sorted by their name. Writing sorted keys make it easier for users to find and change properties in the file.

Author:
Thomas Morgner

Constructor Summary
SortedConfigurationWriter()
          The default constructor, does nothing.
 
Method Summary
protected  java.lang.String getDescription(java.lang.String key)
          Returns a description for the given key.
 void save(java.io.File file, Configuration config)
          Saves the given configuration into a file specified by the given file object.
 void save(java.io.OutputStream outStream, Configuration config)
          Writes the configuration into the given output stream.
 void save(java.lang.String filename, Configuration config)
          Saves the given configuration into a file specified by the given filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedConfigurationWriter

public SortedConfigurationWriter()
The default constructor, does nothing.

Method Detail

getDescription

protected java.lang.String getDescription(java.lang.String key)
Returns a description for the given key. This implementation returns null to indicate that no description should be written. Subclasses can overwrite this method to provide comments for every key. These descriptions will be included as inline comments.

Parameters:
key - the key for which a description should be printed.
Returns:
the description or null if no description should be printed.

save

public void save(java.lang.String filename,
                 Configuration config)
          throws java.io.IOException
Saves the given configuration into a file specified by the given filename.

Parameters:
filename - the filename
config - the configuration
Throws:
java.io.IOException - if an IOError occurs.

save

public void save(java.io.File file,
                 Configuration config)
          throws java.io.IOException
Saves the given configuration into a file specified by the given file object.

Parameters:
file - the target file
config - the configuration
Throws:
java.io.IOException - if an IOError occurs.

save

public void save(java.io.OutputStream outStream,
                 Configuration config)
          throws java.io.IOException
Writes the configuration into the given output stream.

Parameters:
outStream - the target output stream
config - the configuration
Throws:
java.io.IOException - if writing fails.