net.sourceforge.java.feednread.backend.configuration
Class XMLConfigurationPersistenceEngine

java.lang.Object
  extended bynet.sourceforge.java.feednread.backend.configuration.XMLConfigurationPersistenceEngine
All Implemented Interfaces:
IConfigurationPersistenceEngine

public class XMLConfigurationPersistenceEngine
extends Object
implements IConfigurationPersistenceEngine

XMLConfigurationPersistenceEngine represents an xml based persistence layer for the Feed'n Read cconfiguration. It is plugged into net.sourceforge.java.feednread.backend.configuration to use it in conjunction with the JFace preference api.

Author:
Sebastian Machhausen

Field Summary
private  HashMap configurationData
           
private  String filename
           
 
Constructor Summary
XMLConfigurationPersistenceEngine(String filename)
           Creates a new XMLConfigurationPersistenceEngine bound to the specified filename.
 
Method Summary
private  void createArchiveOptions(Element root, Namespace defaultNs)
           Creates the archive options Element which holds archive specific application settings.
private  void createBrowserOptions(Element element, Namespace defaultNs)
           Creates the browser options Element which holds the settings for browser specific behaviour of the application.
private  void createCacheOptions(Element root, Namespace defaultNs)
           Creates the cache options Element which holds cache specific application settings.
private  void createConnectionOptions(Element root, Namespace defaultNs)
           Creates the connection options Element which holds the settings for all connections established by the application.
private  void createControlOptions(Element root, Namespace defaultNs)
           Creates the control options Element which holds the information on the application control settings.
private  void createCoolBarOptions(Element root, Namespace defaultNs)
           Creates the CoolBar options Element which holds the information on the application CoolBar settings.
private  Document createDocument()
           Creates a default configuration Document.
private  void createElement(Element topElement, String name, Namespace ns)
           Creates a new Element in the specified topElement using the given settings.
private  void createEnclosureOptions(Element root, Namespace defaultNs)
           Creates the enclosure options Element which holds the settings for enclosure specific behaviour of the application.
private  void createFavoriteOptions(Element root, Namespace defaultNs)
           Creates the Favorite options Element which holds the information on the application Favorite settings.
private  void createGeneralOptions(Element root, Namespace defaultNs)
           Creates the general options Element which holds general application settings.
private  void createLanguageOptions(Element element, Namespace defaultNs)
           Creates the language options Element which holds the language specific settings of the application.
private  void createPodcastOptions(Element element, Namespace defaultNs)
           Creates the podcast options Element which holds the settings for podcast specific behaviour of the application.
private  void createProxyOptions(Element element, Namespace defaultNs)
           Creates the proxy server options Element which holds the settings for the proxy server to be used for all connections established by the application.
private  void createTrayOptions(Element element, Namespace defaultNs)
           Creates the tray options Element which holds the settings for tray specific behaviour of the application.
private  void createWindowOptions(Element root, Namespace defaultNs)
           Creates the window options Element which holds the information on the application window settings.
private  void parseDocument(Document doc)
           Parses the specified Document holding the application configuration.
 void persist()
           Writes the configuration back to the xml based configuration file.
 Map retrieve()
           Retrieves the configuration data from the underlying xml based persistance layer and deposits the parsed key/value pairs in a Map.
private  void traverse(Element elem)
           Recuirsively traverses the specified Element and maps the xml configuration elements to their values in the internal Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

private String filename

configurationData

private HashMap configurationData
Constructor Detail

XMLConfigurationPersistenceEngine

public XMLConfigurationPersistenceEngine(String filename)

Creates a new XMLConfigurationPersistenceEngine bound to the specified filename.

Parameters:
filename - the name of the xml based configuration file that holds the configuration data
Method Detail

retrieve

public Map retrieve()
             throws PersistenceException

Retrieves the configuration data from the underlying xml based persistance layer and deposits the parsed key/value pairs in a Map.

Specified by:
retrieve in interface IConfigurationPersistenceEngine
Returns:
a Map cotaining a list of key/value pairs holding the settings from the xml based persistance layer
Throws:
PersistenceException - if an error occured while retrieving the configuration data from the xml based persistance layer

persist

public void persist()
             throws PersistenceException

Writes the configuration back to the xml based configuration file.

Specified by:
persist in interface IConfigurationPersistenceEngine
Throws:
PersistenceException - if an error occured while writing the configuration back to xml configuration file

parseDocument

private void parseDocument(Document doc)
                    throws JDOMException

Parses the specified Document holding the application configuration.

Parameters:
doc - the Document holding the application configuration
Throws:
JDOMException - if the specified Document could not be parsed correctly

traverse

private void traverse(Element elem)

Recuirsively traverses the specified Element and maps the xml configuration elements to their values in the internal Map.

Parameters:
elem - the Element to travers

createDocument

private Document createDocument()

Creates a default configuration Document.

Returns:
the created configuration Document

createWindowOptions

private void createWindowOptions(Element root,
                                 Namespace defaultNs)

Creates the window options Element which holds the information on the application window settings.

Parameters:
root - the root Element in which to store the created window options Element
defaultNs - the default Namespace to use

createCoolBarOptions

private void createCoolBarOptions(Element root,
                                  Namespace defaultNs)

Creates the CoolBar options Element which holds the information on the application CoolBar settings.

Parameters:
root - the root Element in which to store the created CoolBar options Element
defaultNs - the default Namespace to use

createControlOptions

private void createControlOptions(Element root,
                                  Namespace defaultNs)

Creates the control options Element which holds the information on the application control settings.

Parameters:
root - the root Element in which to store the created control options Element
defaultNs - the default Namespace to use

createGeneralOptions

private void createGeneralOptions(Element root,
                                  Namespace defaultNs)

Creates the general options Element which holds general application settings.

Parameters:
root - the root Element in which to store the created general options Element
defaultNs - the default Namespace to use

createFavoriteOptions

private void createFavoriteOptions(Element root,
                                   Namespace defaultNs)

Creates the Favorite options Element which holds the information on the application Favorite settings.

Parameters:
root - the root Element in which to store the created Favorite options Element
defaultNs - the default Namespace to use

createLanguageOptions

private void createLanguageOptions(Element element,
                                   Namespace defaultNs)

Creates the language options Element which holds the language specific settings of the application.

Parameters:
element - the Element in which to store the created language options Element
defaultNs - the default Namespace to use

createCacheOptions

private void createCacheOptions(Element root,
                                Namespace defaultNs)

Creates the cache options Element which holds cache specific application settings.

Parameters:
root - the root Element in which to store the created cache options Element
defaultNs - the default Namespace to use

createArchiveOptions

private void createArchiveOptions(Element root,
                                  Namespace defaultNs)

Creates the archive options Element which holds archive specific application settings.

Parameters:
root - the root Element in which to store the created archive options Element
defaultNs - the default Namespace to use

createConnectionOptions

private void createConnectionOptions(Element root,
                                     Namespace defaultNs)

Creates the connection options Element which holds the settings for all connections established by the application.

Parameters:
root - the root Element in which to store the created connection options Element
defaultNs - the default Namespace to use

createProxyOptions

private void createProxyOptions(Element element,
                                Namespace defaultNs)

Creates the proxy server options Element which holds the settings for the proxy server to be used for all connections established by the application.

Parameters:
element - the Element in which to store the created proxy server options Element
defaultNs - the default Namespace to use

createTrayOptions

private void createTrayOptions(Element element,
                               Namespace defaultNs)

Creates the tray options Element which holds the settings for tray specific behaviour of the application.

Parameters:
element - the Element in which to store the created tray options Element
defaultNs - the default Namespace to use

createEnclosureOptions

private void createEnclosureOptions(Element root,
                                    Namespace defaultNs)

Creates the enclosure options Element which holds the settings for enclosure specific behaviour of the application.

Parameters:
root - the Element in which to store the created enclosure options Element
defaultNs - the default Namespace to use

createPodcastOptions

private void createPodcastOptions(Element element,
                                  Namespace defaultNs)

Creates the podcast options Element which holds the settings for podcast specific behaviour of the application.

Parameters:
element - the Element in which to store the created podcast options Element
defaultNs - the default Namespace to use

createBrowserOptions

private void createBrowserOptions(Element element,
                                  Namespace defaultNs)

Creates the browser options Element which holds the settings for browser specific behaviour of the application.

Parameters:
element - the Element in which to store the created browser options Element
defaultNs - the default Namespace to use

createElement

private void createElement(Element topElement,
                           String name,
                           Namespace ns)

Creates a new Element in the specified topElement using the given settings.

Parameters:
topElement - the Element to add the created Element to
name - the name of the new Rlement
ns - the Namespace of the new Element