org.salespointframework.core
Class XmlPreferenceStorage

java.lang.Object
  extended by org.salespointframework.core.XmlPreferenceStorage
All Implemented Interfaces:
PreferenceStorage

public class XmlPreferenceStorage
extends java.lang.Object
implements PreferenceStorage

The default Implementation of PreferenceStorage Settings are stored into a XML file

Since:
4.0
Author:
Thomas Kissinger

Field Summary
private  org.w3c.dom.Document doc
          Document representing the persistent XML storage
private  java.lang.Object docLock
          Lock to guarantee Thread safety
private  java.lang.String fileName
          Name of file to work with
private  org.w3c.dom.Element prefNode
          XML node that contains the preference childs
private  org.w3c.dom.Element rootNode
          XML root node
private  boolean writeBack
          Writeback attribute
 
Constructor Summary
XmlPreferenceStorage()
           
 
Method Summary
 void close()
          Close storage with implicit writeback
 boolean getWriteBack()
          Returns writeback attribute
private  boolean isOpen()
          Check, if the storage is currently opened
 int loadInt(java.lang.String key)
          Load specified key as int from storage
 java.lang.String loadString(java.lang.String key)
          Load specified key as String form storage
private  boolean open()
          Opens config XML file (salespoint.config) in current working directory
 boolean remove(java.lang.String key)
          Remove specified key from storage.
private  void save()
          Writeback changes to file
 boolean save(java.lang.String key, int value)
          Save specified key and value to storage.
 boolean save(java.lang.String key, java.lang.String value)
          Save specified key and value to storage.
 void setWriteBack(boolean writeback)
          Sets writeback attribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

private org.w3c.dom.Document doc
Document representing the persistent XML storage


fileName

private java.lang.String fileName
Name of file to work with


rootNode

private org.w3c.dom.Element rootNode
XML root node


prefNode

private org.w3c.dom.Element prefNode
XML node that contains the preference childs


writeBack

private boolean writeBack
Writeback attribute


docLock

private java.lang.Object docLock
Lock to guarantee Thread safety

Constructor Detail

XmlPreferenceStorage

public XmlPreferenceStorage()
Method Detail

open

private boolean open()
Opens config XML file (salespoint.config) in current working directory

Returns:

save

private void save()
Writeback changes to file


isOpen

private boolean isOpen()
Check, if the storage is currently opened

Returns:

close

public void close()
Close storage with implicit writeback

Specified by:
close in interface PreferenceStorage

getWriteBack

public boolean getWriteBack()
Returns writeback attribute

Specified by:
getWriteBack in interface PreferenceStorage
Returns:
true, if writeback is enabled

loadInt

public int loadInt(java.lang.String key)
Load specified key as int from storage

Specified by:
loadInt in interface PreferenceStorage
Returns:
the value

loadString

public java.lang.String loadString(java.lang.String key)
Load specified key as String form storage

Specified by:
loadString in interface PreferenceStorage
Returns:
the value

save

public boolean save(java.lang.String key,
                    java.lang.String value)
Save specified key and value to storage. Overwrites value if key already exists

Specified by:
save in interface PreferenceStorage
Returns:
true, if successful

save

public boolean save(java.lang.String key,
                    int value)
Save specified key and value to storage. Overwrites value if key already exists

Specified by:
save in interface PreferenceStorage
Returns:
true, if successful

setWriteBack

public void setWriteBack(boolean writeback)
Sets writeback attribute

Specified by:
setWriteBack in interface PreferenceStorage

remove

public boolean remove(java.lang.String key)
Remove specified key from storage.

Specified by:
remove in interface PreferenceStorage
Parameters:
key - to remove
Returns:
true, if key was found and removed