Class PreferencesModel

java.lang.Object
  extended byjava.util.Observable
      extended byPreferencesModel
All Implemented Interfaces:
java.util.EventListener, java.util.prefs.NodeChangeListener, java.util.prefs.PreferenceChangeListener

public class PreferencesModel
extends java.util.Observable
implements java.util.prefs.NodeChangeListener, java.util.prefs.PreferenceChangeListener

The model where all modifications to the preferences store are done. Uses the Observer pattern to notify the views when the model changes. This singleton class effectively adds the idea of a 'current node' to the java preferences node heirarchy.


Method Summary
 void childAdded(java.util.prefs.NodeChangeEvent evt)
           
 void childRemoved(java.util.prefs.NodeChangeEvent evt)
           
 java.util.prefs.Preferences deleteNode()
          Deletes the current node and its children
 java.util.prefs.Preferences getCurrentNode()
          Gets the current preferences node
static PreferencesModel Instance()
          Singleton accessor
 java.util.prefs.Preferences newNode(java.lang.String sNodeName)
          Creates a new node as a child of the current node
 void preferenceChange(java.util.prefs.PreferenceChangeEvent evt)
           
 void removeAttribute(java.lang.String sKey)
          Removes the attribute sKey of the current node
 void renameAttribute(java.lang.String sOldKey, java.lang.String sNewKey)
          Renames the attribute sOldKey of the current node
 void setAttribute(java.lang.String sKey, java.lang.String sValue)
          Sets the attribute sKey of the current node
 void setCurrentNode(java.util.prefs.Preferences oNode)
          Sets the current preferences node and notifies observers if the new node is not the same as the previous current node.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

Instance

public static PreferencesModel Instance()
Singleton accessor

Returns:
PreferencesModel

getCurrentNode

public java.util.prefs.Preferences getCurrentNode()
Gets the current preferences node

Returns:
java.util.prefs.Preferences

setCurrentNode

public void setCurrentNode(java.util.prefs.Preferences oNode)
Sets the current preferences node and notifies observers if the new node is not the same as the previous current node.

Parameters:
oNode - new current node

setAttribute

public void setAttribute(java.lang.String sKey,
                         java.lang.String sValue)
Sets the attribute sKey of the current node

Parameters:
sKey - node key name
sValue - node key value

removeAttribute

public void removeAttribute(java.lang.String sKey)
Removes the attribute sKey of the current node

Parameters:
sKey - node key to remove

renameAttribute

public void renameAttribute(java.lang.String sOldKey,
                            java.lang.String sNewKey)
Renames the attribute sOldKey of the current node

Parameters:
sOldKey - node key old name
sNewKey - node key new name

newNode

public java.util.prefs.Preferences newNode(java.lang.String sNodeName)
Creates a new node as a child of the current node

Parameters:
sNodeName - new node name
Returns:
java.util.prefs.Preferences the new node

deleteNode

public java.util.prefs.Preferences deleteNode()
Deletes the current node and its children

Returns:
java.util.prefs.Preferences the parent of the deleted node

childAdded

public void childAdded(java.util.prefs.NodeChangeEvent evt)
Specified by:
childAdded in interface java.util.prefs.NodeChangeListener
See Also:
NodeChangeListener.childAdded(java.util.prefs.NodeChangeEvent)

childRemoved

public void childRemoved(java.util.prefs.NodeChangeEvent evt)
Specified by:
childRemoved in interface java.util.prefs.NodeChangeListener
See Also:
NodeChangeListener.childRemoved(java.util.prefs.NodeChangeEvent)

preferenceChange

public void preferenceChange(java.util.prefs.PreferenceChangeEvent evt)
Specified by:
preferenceChange in interface java.util.prefs.PreferenceChangeListener
See Also:
PreferenceChangeListener.preferenceChange(java.util.prefs.PreferenceChangeEvent)


Copyright © 2003-2004 . All Rights Reserved.