org.pf.settings.rw
Class IniReaderWriter

java.lang.Object
  extended by org.pf.settings.rw.AbstractSettingsReaderWriter
      extended by org.pf.settings.rw.AbstractSettingsFileReaderWriter
          extended by org.pf.settings.rw.IniReaderWriter
All Implemented Interfaces:
SettingsFileReader, SettingsReader, SettingsWriter

public class IniReaderWriter
extends AbstractSettingsFileReaderWriter

Read and writes settings from/into Windows ini files.

Version:
1.5
Author:
Manfred Duchrow

Constructor Summary
IniReaderWriter(FileLocator locator)
          Initialize the new instance with a locator that points to an ini file.
IniReaderWriter(FileLocator locator, java.lang.String charsetName)
          Initialize the new instance with a locator that points to an ini file and a name for the character encoding of that file.
IniReaderWriter(java.lang.String filename)
          Initialize the new instance with a filename.
IniReaderWriter(java.lang.String filename, java.lang.String charsetName)
          Initialize the new instance with a filename and a character encoding.
 
Method Summary
 java.lang.String getCommentSeparator()
          Returns the separator that indicates the beginning of a comment The default is ";"
 java.lang.String getKeyValueSeparator()
          Returns the separator between a key and its associated value The default is "="
 boolean getNewlineAfterSection()
          Returns true if a new line gets added after each [section]
 void setCommentSeparator(java.lang.String newValue)
          Set the comment separator that indicates the start of a comment
 void setKeyValueSeparator(java.lang.String newValue)
          Sets the separator that is used between a key and its associated value
 void setNewlineAfterSection(boolean newValue)
          If set to true then a new line gets added after each [section]
 boolean storeSettings(Settings settings)
          Stores the given settings to the file with this object's filename in the format of Windows ini files.
 
Methods inherited from class org.pf.settings.rw.AbstractSettingsFileReaderWriter
getEncoding, getFileName, loadSettings, loadSettingsFrom, loadSettingsFrom, setEncoding, setFileName
 
Methods inherited from class org.pf.settings.rw.AbstractSettingsReaderWriter
loadSettings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pf.settings.SettingsReader
loadSettings
 

Constructor Detail

IniReaderWriter

public IniReaderWriter(java.lang.String filename)
Initialize the new instance with a filename.

Parameters:
filename - The name of the file to read from

IniReaderWriter

public IniReaderWriter(java.lang.String filename,
                       java.lang.String charsetName)
Initialize the new instance with a filename and a character encoding.

Parameters:
filename - The name of the file to read from
charsetName - The character encoding (e.g. "UTF-8") or null

IniReaderWriter

public IniReaderWriter(FileLocator locator)
Initialize the new instance with a locator that points to an ini file.

Parameters:
locator - A file locator that points to the file from which to read

IniReaderWriter

public IniReaderWriter(FileLocator locator,
                       java.lang.String charsetName)
Initialize the new instance with a locator that points to an ini file and a name for the character encoding of that file.

Parameters:
locator - A file locator that points to the file from which to read
charsetName - The character encoding (e.g. "UTF-8") or null
Method Detail

getCommentSeparator

public java.lang.String getCommentSeparator()
Returns the separator that indicates the beginning of a comment The default is ";"


setCommentSeparator

public void setCommentSeparator(java.lang.String newValue)
Set the comment separator that indicates the start of a comment

Parameters:
newValue - The new separator

getKeyValueSeparator

public java.lang.String getKeyValueSeparator()
Returns the separator between a key and its associated value The default is "="


setKeyValueSeparator

public void setKeyValueSeparator(java.lang.String newValue)
Sets the separator that is used between a key and its associated value


getNewlineAfterSection

public boolean getNewlineAfterSection()
Returns true if a new line gets added after each [section]


setNewlineAfterSection

public void setNewlineAfterSection(boolean newValue)
If set to true then a new line gets added after each [section]


storeSettings

public boolean storeSettings(Settings settings)
Stores the given settings to the file with this object's filename in the format of Windows ini files.

Parameters:
settings - The settings to store
Returns:
true, if the settings have been successfully stored. Otherwise false.