de.tkuhn.util.prefs
Class PrefsMetaInfo

java.lang.Object
  extended by de.tkuhn.util.prefs.PrefsMetaInfo
All Implemented Interfaces:
MetaInfo

public class PrefsMetaInfo
extends java.lang.Object
implements MetaInfo

An implementation of MetaInfo using Preferences itself for storage of meta information.

Author:
Tilmann Kuhn

Field Summary
 
Fields inherited from interface de.tkuhn.util.prefs.MetaInfo
KEY_ICONRES, KEY_LONGDESC, KEY_NAME, KEY_SHORTDESC, KEY_TYPE, KEY_USEREDIT, TYPE_boolean, TYPE_byteArray, TYPE_double, TYPE_float, TYPE_int, TYPE_long, TYPE_string, TYPE_undefined
 
Constructor Summary
PrefsMetaInfo(java.util.prefs.Preferences metaNode)
          Creates a new instance of PrefsMetaInfo
 
Method Summary
 java.lang.String getMappingInfo(java.lang.String key, java.lang.String infoKey, java.lang.String defaultInfo)
          Retrieve a piece of Information stored about the mapping identified by its key inside the node this MetaInfo describes mapped to the infoKey.
 java.lang.String getNodeInfo(java.lang.String infoKey, java.lang.String defaultInfo)
          Retrieve a piece of Information stored about the node described by this MetaInfo under the given key.
 int getType(java.lang.String key)
          Get the type of the value mapped with the given key.
 boolean isUserEditable(java.lang.String key)
          Check if the value of the mapping with the given key is editable by users or by admins only.
 void setMappingInfo(java.lang.String key, java.lang.String infoKey, java.lang.String info)
          Store a piece of Information about the mapping identified by its key inside the node described by this MetaInfo.
 void setNodeInfo(java.lang.String infoKey, java.lang.String info)
          Store a piece of Information about the node described by this MetaInfo under the given key.
 void setType(java.lang.String key, int type)
          Set the type of the value mapped with the given key.
 void setUserEditable(java.lang.String key, boolean editable)
          Set if the value of the mapping with the given key should be editable by users or by admins only.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrefsMetaInfo

public PrefsMetaInfo(java.util.prefs.Preferences metaNode)
Creates a new instance of PrefsMetaInfo

Parameters:
metaNode - the Preferences node where meta information is stored.
Method Detail

getMappingInfo

public java.lang.String getMappingInfo(java.lang.String key,
                                       java.lang.String infoKey,
                                       java.lang.String defaultInfo)
Retrieve a piece of Information stored about the mapping identified by its key inside the node this MetaInfo describes mapped to the infoKey. This operation returns default if the mapping is not set or if the storage back-end is not reachable.

Specified by:
getMappingInfo in interface MetaInfo
Parameters:
key - the key of the mapping data was stored about
infoKey - the key the data was mapped to
defaultInfo - the default to be returned on missing data
Returns:
the value of the mapping or the default

getNodeInfo

public java.lang.String getNodeInfo(java.lang.String infoKey,
                                    java.lang.String defaultInfo)
Retrieve a piece of Information stored about the node described by this MetaInfo under the given key. This operation returns default if the mapping is not set or if the storage back-end is not reachable.

Specified by:
getNodeInfo in interface MetaInfo
Parameters:
infoKey - the key the data was mapped to
defaultInfo - the default to be returned on missing data
Returns:
the value of the mapping or the default

getType

public int getType(java.lang.String key)
Get the type of the value mapped with the given key. This operation returns TYPE_undefined if the type is not set of if the storage back-end is not reachable.

Specified by:
getType in interface MetaInfo
Parameters:
key - the key of the mapping
Returns:
the type of the mapping as int

isUserEditable

public boolean isUserEditable(java.lang.String key)
Check if the value of the mapping with the given key is editable by users or by admins only. This operation returns false if the flag is not set or if the storage back-end is not reachable.

Specified by:
isUserEditable in interface MetaInfo
Parameters:
key - the key of the mapping
Returns:
true if users may edit, false otherwise

setMappingInfo

public void setMappingInfo(java.lang.String key,
                           java.lang.String infoKey,
                           java.lang.String info)
Store a piece of Information about the mapping identified by its key inside the node described by this MetaInfo. Map the data to the infoKey.

Specified by:
setMappingInfo in interface MetaInfo
Parameters:
key - the key of the mapping to store data about
infoKey - key to map the data with
info - the data to be mapped

setNodeInfo

public void setNodeInfo(java.lang.String infoKey,
                        java.lang.String info)
Store a piece of Information about the node described by this MetaInfo under the given key.

Specified by:
setNodeInfo in interface MetaInfo
Parameters:
infoKey - the key to map the data with
info - the data to be mapped

setType

public void setType(java.lang.String key,
                    int type)
Set the type of the value mapped with the given key. It is the callers due to check if the contents of the mapping obey this type!

Specified by:
setType in interface MetaInfo
Parameters:
key - the key of the mapping
type - the new type of the mapping. Should be one of the predefined types.

setUserEditable

public void setUserEditable(java.lang.String key,
                            boolean editable)
Set if the value of the mapping with the given key should be editable by users or by admins only.

Specified by:
setUserEditable in interface MetaInfo
Parameters:
key - the key of the mapping
editable - the new state: true: users may edit false: admins only

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © Tilmann Kuhn