SRJRCFrames
v0.1.296

de.schwarzrot.data.access.pref
Class PreferencesManager

java.lang.Object
  extended by de.schwarzrot.data.access.pref.PreferencesManager

public class PreferencesManager
extends Object

class to abstract operating system differences in preferences handling. This class is used by the PreferencesConfigure in very early application setup stage, as well as by PreferencesEntityManager the application standard to access preferences by ready configured application.

This class should be considered internal to the persistence layer. Normally there's no need to use it at application level. Use descendants of AbstractConfigBase and the transaction layer.

Windows path separator sometimes break originally java preferences, so we care about that path handling/patching. This class could be considered like the connection class from jdbc-layer. It covers all Preferences access and offers accessor creation. Those accessors could be considered the counterpart to jdbc resultset.

Node paths segments may be separated by "." or "/" or mixed by both. Main purpose of this class is to handle those mixtures and use the right path syntax for the operating system.

System preferences all go to the same root, where as user preferences are prefixed by the schema name.

Author:
Reinhard Mantey

Constructor Summary
PreferencesManager(String ApplicationName, String schemaName)
           
 
Method Summary
 void clearSystemNode(String nodePath)
           
 void clearUserNode(String nodePath)
           
protected  void flushSystemConfig()
           
protected  void flushUserConfig()
           
protected  String getPathSeparator()
           
 PreferencesAccessor getPreferencesAccessor(EntityDescriptor ed)
          convenience call.
 PreferencesAccessor getPreferencesAccessor(EntityDescriptor ed, String subPath)
          convenience call.
 PreferencesAccessor getPreferencesAccessor(String nodePath)
          convenience call.
 Preferences getSystemNode(Class<?> clazz)
           
 Preferences getSystemNode(Class<?> clazz, boolean create)
           
 Preferences getSystemNode(Class<?> clazz, String subPath)
           
 Preferences getSystemNode(Class<?> clazz, String subPath, boolean create)
           
 Preferences getSystemNode(String path)
           
 Preferences getSystemNode(String path, boolean create)
           
 Preferences getSystemNode(String path, String subPath)
           
 Preferences getSystemNode(String rawPath, String subPath, boolean create)
           
 Preferences getUserNode(Class<?> clazz)
          returns the node matching the class name from user space.
 Preferences getUserNode(Class<?> clazz, boolean create)
          returns the node matching the class name from user space.
 Preferences getUserNode(Class<?> clazz, String subPath)
          returns the child node of the given class.
 Preferences getUserNode(Class<?> clazz, String subPath, boolean create)
          returns the child node of the given class.
 Preferences getUserNode(String path)
          returns the node from user space matching the given path.
 Preferences getUserNode(String path, boolean create)
          returns the node from user space matching the given path.
 Preferences getUserNode(String path, String subPath)
          returns a childs node from node matching given path.
 Preferences getUserNode(String rawPath, String subPath, boolean create)
          returns a child node from node matching given path.
 boolean isSystemWritable()
           
protected  String pathConvert(String rawPath)
          allow usage of classnames as node-paths, so this call converts dots into slashes.
 String readProperty(String propertyPath)
          method to read a single property from preferences.
 void sync()
          could be considered as the counterpart of commit of a jdbc connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferencesManager

public PreferencesManager(String ApplicationName,
                          String schemaName)
Method Detail

clearSystemNode

public void clearSystemNode(String nodePath)

clearUserNode

public void clearUserNode(String nodePath)

getPreferencesAccessor

public PreferencesAccessor getPreferencesAccessor(EntityDescriptor ed)
convenience call. Creates an accessor for the given entity

Parameters:
ed - - EntityDescriptor holding meta information about an Entity
Returns:
a wrapped preferences node as PreferencesAccessor

getPreferencesAccessor

public PreferencesAccessor getPreferencesAccessor(EntityDescriptor ed,
                                                  String subPath)
convenience call. Creates an accessor for a child node of given entity

Parameters:
ed - - EntityDescriptor holding meta information about an Entity
subPath - - path to the referred child
Returns:
a wrapped preferences node as PreferencesAccessor

getPreferencesAccessor

public PreferencesAccessor getPreferencesAccessor(String nodePath)
convenience call. Creates an accessor for the given nodepath.

Parameters:
nodePath - - path to preferences node
Returns:
a wrapped preferences node as PreferencesAccessor

getSystemNode

public Preferences getSystemNode(Class<?> clazz)

getSystemNode

public Preferences getSystemNode(Class<?> clazz,
                                 boolean create)

getSystemNode

public Preferences getSystemNode(Class<?> clazz,
                                 String subPath)

getSystemNode

public Preferences getSystemNode(Class<?> clazz,
                                 String subPath,
                                 boolean create)

getSystemNode

public Preferences getSystemNode(String path)

getSystemNode

public Preferences getSystemNode(String path,
                                 boolean create)

getSystemNode

public Preferences getSystemNode(String path,
                                 String subPath)

getSystemNode

public Preferences getSystemNode(String rawPath,
                                 String subPath,
                                 boolean create)

getUserNode

public Preferences getUserNode(Class<?> clazz)
returns the node matching the class name from user space. Does not create the node, if it doesn't exists.

Parameters:
clazz - - classname used as path to the node
Returns:
- the Preferences node or null

getUserNode

public Preferences getUserNode(Class<?> clazz,
                               boolean create)
returns the node matching the class name from user space. If create is set to true, the node will be created if it does not exist.

Parameters:
clazz - - classname used as path to the node
create - - true - to create the node
- false - return only existing nodes
Returns:
the Preferences node or null

getUserNode

public Preferences getUserNode(Class<?> clazz,
                               String subPath)
returns the child node of the given class. It does not create a node and will return null if the node does not exist.

Parameters:
clazz - - classname used as path to the node
subPath - - the name of the child, or the path to the child
Returns:
the Preferences node or null

getUserNode

public Preferences getUserNode(Class<?> clazz,
                               String subPath,
                               boolean create)
returns the child node of the given class. If create is set to true, the node will be created if it does not already exist.

Parameters:
clazz - - classname used as path to the node
create - - true - to create the node
- false - return only existing nodes
subPath - - the name of the child, or the path to the child
Returns:
the Preferences node or null

getUserNode

public Preferences getUserNode(String path)
returns the node from user space matching the given path. This call will not create the node so it will return null for non existing nodes.

Parameters:
path - - path to the node
Returns:
the Preferences node or null

getUserNode

public Preferences getUserNode(String path,
                               boolean create)
returns the node from user space matching the given path. If create is set to true and the node does not exists, it will be created.

Parameters:
path - - path to the node
create - - true - create the node
- false - don't create the node
Returns:
the Preferences node or null

getUserNode

public Preferences getUserNode(String path,
                               String subPath)
returns a childs node from node matching given path. This call will not create the node and thus return null if the node does not exist.

Parameters:
path - - path to the parent node
subPath - - path to the child (relative to the parent)
Returns:
the Preferences node or null

getUserNode

public Preferences getUserNode(String rawPath,
                               String subPath,
                               boolean create)
returns a child node from node matching given path. subPath may be null, so this call will return the parents node denoted by rawPath. Setting create to true will create non existing nodes.

Parameters:
rawPath - - raw path denoting the parents node. Path segements may be separated any combination of ".", "/" or system dependant path separators.
subPath - - path to the child (relative to the parent)
create - - true - create non existing nodes
- false - don't create any node
Returns:
the Preferences node or null

isSystemWritable

public boolean isSystemWritable()

readProperty

public String readProperty(String propertyPath)
method to read a single property from preferences. PropertyPath should be denoted in java/linux path notation, which means, it should have '/' as path separator. Don't bother with underlaying operating system.

Parameters:
propertyPath - - the absolute path of a property, which means, the last segment is the key and the preceeding part is the path of the node.
Returns:
the value of the property or null if it does not exists

sync

public void sync()
could be considered as the counterpart of commit of a jdbc connection


flushSystemConfig

protected void flushSystemConfig()

flushUserConfig

protected void flushUserConfig()

getPathSeparator

protected String getPathSeparator()

pathConvert

protected String pathConvert(String rawPath)
allow usage of classnames as node-paths, so this call converts dots into slashes.

Parameters:
rawPath - - path to convert
Returns:
- the converted path

SRJRCFrames
v0.1.296

hosted at
Find SRJRCFrames at SourceForge.net. Fast, secure and free:
           Open Source Software download
Submit a bug or request a feature

SRJRCFrames is published according to the GNU General Public License
Copyright 2005-2012 Reinhard Mantey - some rights reserved.