public static class PropertiesConfiguration.PropertiesWriter extends FilterWriter
writeProperty(String, Object, boolean)
, which is called
during a save operation for each property found in the configuration.out
Constructor and Description |
---|
PropertiesConfiguration.PropertiesWriter(Writer writer,
char delimiter)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected String |
fetchSeparator(String key,
Object value)
Returns the separator to be used for the given property.
|
String |
getCurrentSeparator()
Returns the current property separator.
|
String |
getGlobalSeparator()
Returns the global property separator.
|
String |
getLineSeparator()
Returns the line separator.
|
void |
setCurrentSeparator(String currentSeparator)
Sets the current property separator.
|
void |
setGlobalSeparator(String globalSeparator)
Sets the global property separator.
|
void |
setLineSeparator(String lineSeparator)
Sets the line separator.
|
void |
writeComment(String comment)
Write a comment.
|
void |
writeln(String s)
Helper method for writing a line with the platform specific line
ending.
|
void |
writeProperty(String key,
List<?> values)
Write a property.
|
void |
writeProperty(String key,
Object value)
Write a property.
|
void |
writeProperty(String key,
Object value,
boolean forceSingleLine)
Writes the given property and its value.
|
public PropertiesConfiguration.PropertiesWriter(Writer writer, char delimiter)
writer
- a Writer object providing the underlying streamdelimiter
- the delimiter character for multi-valued propertiespublic String getCurrentSeparator()
public void setCurrentSeparator(String currentSeparator)
currentSeparator
- the current property separatorpublic String getGlobalSeparator()
public void setGlobalSeparator(String globalSeparator)
globalSeparator
property of
PropertiesConfigurationLayout
. It defines the separator to be
used for all properties. If it is undefined, the current separator is
used.globalSeparator
- the global property separatorpublic String getLineSeparator()
public void setLineSeparator(String lineSeparator)
lineSeparator
- the line separator to be usedpublic void writeProperty(String key, Object value) throws IOException
key
- the key of the propertyvalue
- the value of the propertyIOException
- if an I/O error occurspublic void writeProperty(String key, List<?> values) throws IOException
key
- The key of the propertyvalues
- The array of values of the propertyIOException
- if an I/O error occurspublic void writeProperty(String key, Object value, boolean forceSingleLine) throws IOException
forceSingleLine
flag is evaluated. If it is
set, all values are written on a single line using the list delimiter
as separator.key
- the property keyvalue
- the property valueforceSingleLine
- the "force single line" flagIOException
- if an error occurspublic void writeComment(String comment) throws IOException
comment
- the comment to writeIOException
- if an I/O error occurspublic void writeln(String s) throws IOException
s
- the content of the line (may be null)IOException
- if an error occursprotected String fetchSeparator(String key, Object value)
writeProperty()
. The string returned here
is used as separator between the property key and its value. Per
default the method checks whether a global separator is set. If this
is the case, it is returned. Otherwise the separator returned by
getCurrentSeparator()
is used, which was set by the
associated layout object. Derived classes may implement a different
strategy for defining the separator.key
- the property keyvalue
- the valueCopyright © 2001–2013 The Apache Software Foundation. All rights reserved.