org.pf.settings.rw
Class AbstractSettingsFileReaderWriter

java.lang.Object
  extended byorg.pf.settings.rw.AbstractSettingsReaderWriter
      extended byorg.pf.settings.rw.AbstractSettingsFileReaderWriter
All Implemented Interfaces:
SettingsFileReader, SettingsReader, SettingsWriter
Direct Known Subclasses:
HttpdConfReaderWriter, IniReaderWriter, ManifestReaderWriter, PropertiesReaderWriter

public abstract class AbstractSettingsFileReaderWriter
extends AbstractSettingsReaderWriter
implements SettingsFileReader

This class provides a common implementation for SettingsReader and SettingsWriter that use a file as datastore.

Version:
1.5
Author:
Manfred Duchrow

Constructor Summary
AbstractSettingsFileReaderWriter()
          Initialize the new instance with default values.
AbstractSettingsFileReaderWriter(FileLocator fileLocator)
          Initialize the new instance with a file locator.
AbstractSettingsFileReaderWriter(java.lang.String filename)
          Initialize the new instance with a filename.
 
Method Summary
 java.lang.String getEncoding()
          Set the encoding to be used for reading an writing.
 java.lang.String getFileName()
          Returns the name of the file from which or to which the setting should be written/read.
 Settings loadSettings(java.lang.Class settingsClass)
          Returns a newly created Settings object filled with the data from the datastore the implementer supports.
 Settings loadSettingsFrom(ClasspathElement classpathElement)
          Returns a newly created Settings object filled with the data from the file the implementer supports.
 Settings loadSettingsFrom(ClasspathElement classpathElement, java.lang.Class settingsClass)
          Returns a newly created Settings object filled with the data from the file the implementer supports.
 Settings loadSettingsFrom(java.lang.String content)
          Uses the given string as content to parse the settings from.
 Settings loadSettingsFrom(java.lang.String content, java.lang.Class settingsClass)
          Uses the given string as content to parse the settings from.
 void setEncoding(java.lang.String newValue)
           
 void setFileName(java.lang.String aValue)
          Sets the name of the file from which or to which the setting should be written/read.
 
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
 
Methods inherited from interface org.pf.settings.SettingsWriter
storeSettings
 

Constructor Detail

AbstractSettingsFileReaderWriter

public AbstractSettingsFileReaderWriter()
Initialize the new instance with default values.


AbstractSettingsFileReaderWriter

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

Parameters:
filename - The name of the file the settings must be read from

AbstractSettingsFileReaderWriter

public AbstractSettingsFileReaderWriter(FileLocator fileLocator)
Initialize the new instance with a file locator.

Parameters:
fileLocator - The locator for the file the settings must be read from
Method Detail

getFileName

public java.lang.String getFileName()
Returns the name of the file from which or to which the setting should be written/read.

Specified by:
getFileName in interface SettingsFileReader

setFileName

public void setFileName(java.lang.String aValue)
Sets the name of the file from which or to which the setting should be written/read.


getEncoding

public java.lang.String getEncoding()
Set the encoding to be used for reading an writing. If encoding is null then the default encoding will be used.


setEncoding

public void setEncoding(java.lang.String newValue)

loadSettings

public Settings loadSettings(java.lang.Class settingsClass)
Returns a newly created Settings object filled with the data from the datastore the implementer supports.

Specified by:
loadSettings in interface SettingsReader
Parameters:
settingsClass - The class of which an instance should be created and returned
Returns:
An instance of the given class filled with the data from the datastore

loadSettingsFrom

public Settings loadSettingsFrom(ClasspathElement classpathElement)
                          throws java.io.IOException
Returns a newly created Settings object filled with the data from the file the implementer supports. The file is looked up in the given classpath element.

Parameters:
classpathElement - The classpath element from wich to load the settings file
Returns:
An new instance of a Settings class filled with the data from the file
Throws:
java.io.IOException - If the file cannot be found or opened

loadSettingsFrom

public Settings loadSettingsFrom(ClasspathElement classpathElement,
                                 java.lang.Class settingsClass)
                          throws java.io.IOException
Returns a newly created Settings object filled with the data from the file the implementer supports. The file is looked up in the given classpath element.

Parameters:
classpathElement - The classpath element from wich to load the settings file
settingsClass - The class of which an instance should be created and returned
Returns:
An instance of the given class filled with the data from the datastore
Throws:
java.io.IOException - If the file cannot be found or opened

loadSettingsFrom

public Settings loadSettingsFrom(java.lang.String content)
Uses the given string as content to parse the settings from.


loadSettingsFrom

public Settings loadSettingsFrom(java.lang.String content,
                                 java.lang.Class settingsClass)
Uses the given string as content to parse the settings from.