org.apache.commons.configuration
public static class PropertiesConfiguration.PropertiesWriter extends java.io.FilterWriter
writeProperty(String, Object, boolean)
, which is called
during a save operation for each property found in the configuration.Constructor and Description |
---|
PropertiesConfiguration.PropertiesWriter(java.io.Writer writer,
char delimiter)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
fetchSeparator(java.lang.String key,
java.lang.Object value)
Returns the separator to be used for the given property.
|
java.lang.String |
getCurrentSeparator()
Returns the current property separator.
|
java.lang.String |
getGlobalSeparator()
Returns the global property separator.
|
java.lang.String |
getLineSeparator()
Returns the line separator.
|
void |
setCurrentSeparator(java.lang.String currentSeparator)
Sets the current property separator.
|
void |
setGlobalSeparator(java.lang.String globalSeparator)
Sets the global property separator.
|
void |
setLineSeparator(java.lang.String lineSeparator)
Sets the line separator.
|
void |
writeComment(java.lang.String comment)
Write a comment.
|
void |
writeln(java.lang.String s)
Helper method for writing a line with the platform specific line
ending.
|
void |
writeProperty(java.lang.String key,
java.util.List values)
Write a property.
|
void |
writeProperty(java.lang.String key,
java.lang.Object value)
Write a property.
|
void |
writeProperty(java.lang.String key,
java.lang.Object value,
boolean forceSingleLine)
Writes the given property and its value.
|
public PropertiesConfiguration.PropertiesWriter(java.io.Writer writer, char delimiter)
writer
- a Writer object providing the underlying streamdelimiter
- the delimiter character for multi-valued propertiespublic java.lang.String getCurrentSeparator()
public void setCurrentSeparator(java.lang.String currentSeparator)
currentSeparator
- the current property separatorpublic java.lang.String getGlobalSeparator()
public void setGlobalSeparator(java.lang.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 java.lang.String getLineSeparator()
public void setLineSeparator(java.lang.String lineSeparator)
lineSeparator
- the line separator to be usedpublic void writeProperty(java.lang.String key, java.lang.Object value) throws java.io.IOException
key
- the key of the propertyvalue
- the value of the propertyjava.io.IOException
- if an I/O error occurspublic void writeProperty(java.lang.String key, java.util.List values) throws java.io.IOException
key
- The key of the propertyvalues
- The array of values of the propertyjava.io.IOException
- if an I/O error occurspublic void writeProperty(java.lang.String key, java.lang.Object value, boolean forceSingleLine) throws java.io.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" flagjava.io.IOException
- if an error occurspublic void writeComment(java.lang.String comment) throws java.io.IOException
comment
- the comment to writejava.io.IOException
- if an I/O error occurspublic void writeln(java.lang.String s) throws java.io.IOException
s
- the content of the line (may be null)java.io.IOException
- if an error occursprotected java.lang.String fetchSeparator(java.lang.String key, java.lang.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-2016. All Rights Reserved.