Package org.jfree.util
Class SortedConfigurationWriter
java.lang.Object
org.jfree.util.SortedConfigurationWriter
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The system-dependent End-Of-Line separator.private static final int
A constant defining that text should be escaped in a way which is suitable for property comments.private static final int
A constant defining that text should be escaped in a way which is suitable for property keys.private static final int
A constant defining that text should be escaped in a way which is suitable for property values.private static final char[]
A lookup-table. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getDescription
(String key) Returns a description for the given key.void
save
(File file, Configuration config) Saves the given configuration into a file specified by the given file object.void
save
(OutputStream outStream, Configuration config) Writes the configuration into the given output stream.void
save
(String filename, Configuration config) Saves the given configuration into a file specified by the given filename.private void
saveConvert
(String text, int escapeMode, Writer writer) Performs the necessary conversion of an java string into a property escaped string.private void
writeDescription
(String text, Writer writer) Writes a descriptive comment into the given print writer.
-
Field Details
-
ESCAPE_KEY
private static final int ESCAPE_KEYA constant defining that text should be escaped in a way which is suitable for property keys.- See Also:
-
ESCAPE_VALUE
private static final int ESCAPE_VALUEA constant defining that text should be escaped in a way which is suitable for property values.- See Also:
-
ESCAPE_COMMENT
private static final int ESCAPE_COMMENTA constant defining that text should be escaped in a way which is suitable for property comments.- See Also:
-
END_OF_LINE
The system-dependent End-Of-Line separator. -
HEX_CHARS
private static final char[] HEX_CHARSA lookup-table.
-
-
Constructor Details
-
SortedConfigurationWriter
public SortedConfigurationWriter()The default constructor, does nothing.
-
-
Method Details
-
getDescription
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
Saves the given configuration into a file specified by the given filename.- Parameters:
filename
- the filenameconfig
- the configuration- Throws:
IOException
- if an IOError occurs.
-
save
Saves the given configuration into a file specified by the given file object.- Parameters:
file
- the target fileconfig
- the configuration- Throws:
IOException
- if an IOError occurs.
-
save
Writes the configuration into the given output stream.- Parameters:
outStream
- the target output streamconfig
- the configuration- Throws:
IOException
- if writing fails.
-
writeDescription
Writes a descriptive comment into the given print writer.- Parameters:
text
- the text to be written. If it contains more than one line, every line will be prepended by the comment character.writer
- the writer that should receive the content.- Throws:
IOException
- if writing fails
-
saveConvert
Performs the necessary conversion of an java string into a property escaped string.- Parameters:
text
- the text to be escapedescapeMode
- the mode that should be applied.writer
- the writer that should receive the content.- Throws:
IOException
- if writing fails
-