public class PreferencesImpl extends Object implements org.osgi.service.prefs.Preferences
| Modifier and Type | Field and Description |
|---|---|
protected ChangeSet |
changeSet
The change set keeps track of all changes.
|
protected Map<String,PreferencesImpl> |
children
The child nodes.
|
protected PreferencesDescription |
description
The description for this preferences.
|
protected String |
name
The name of the properties.
|
protected PreferencesImpl |
parent
The parent.
|
protected Map<String,String> |
properties
The properties.
|
protected BackingStoreManager |
storeManager
The backing store manager.
|
protected boolean |
valid
Has this node been removed?
|
| Constructor and Description |
|---|
PreferencesImpl(PreferencesDescription d,
BackingStoreManager storeManager)
Construct the root node of the tree.
|
PreferencesImpl(PreferencesImpl p,
String name)
Construct a child node.
|
| Modifier and Type | Method and Description |
|---|---|
String |
absolutePath() |
void |
applyChanges(PreferencesImpl prefs)
Apply the changes done to the passed preferences object.
|
protected void |
checkKey(String key)
The key is not allowed to be null.
|
protected void |
checkValidity()
Check if this node is still valid.
|
protected void |
checkValue(Object value)
The value is not allowed to be null.
|
String[] |
childrenNames() |
void |
clear() |
void |
flush() |
String |
get(String key,
String def) |
BackingStoreManager |
getBackingStoreManager()
Return the backing store manager.
|
boolean |
getBoolean(String key,
boolean def) |
byte[] |
getByteArray(String key,
byte[] def) |
ChangeSet |
getChangeSet()
Return the change set.
|
Collection<PreferencesImpl> |
getChildren()
Return all children or an empty collection.
|
PreferencesDescription |
getDescription()
Return the preferences description.
|
double |
getDouble(String key,
double def) |
float |
getFloat(String key,
float def) |
int |
getInt(String key,
int def) |
long |
getLong(String key,
long def) |
protected PreferencesImpl |
getNode(String path,
boolean saveNewlyCreatedNode,
boolean create)
Get a relative node.
|
PreferencesImpl |
getOrCreateNode(String pathName)
Get or create the node.
|
Map<String,String> |
getProperties()
Return the properties set.
|
PreferencesImpl |
getRoot()
Get the root preferences.
|
boolean |
isValid() |
String[] |
keys() |
String |
name() |
org.osgi.service.prefs.Preferences |
node(String pathName)
We do not synchronize this method to avoid dead locks as this
method might call another preferences object in the hierarchy.
|
boolean |
nodeExists(String pathName)
We do not synchronize this method to avoid dead locks as this
method might call another preferences object in the hierarchy.
|
org.osgi.service.prefs.Preferences |
parent() |
void |
put(String key,
String value) |
void |
putBoolean(String key,
boolean value) |
void |
putByteArray(String key,
byte[] value) |
void |
putDouble(String key,
double value) |
void |
putFloat(String key,
float value) |
void |
putInt(String key,
int value) |
void |
putLong(String key,
long value) |
void |
remove(String key) |
protected void |
removeChild(PreferencesImpl child) |
void |
removeNode() |
protected void |
safelyRemoveNode()
Safely remove a node by resetting all properties and calling
this method on all children recursively.
|
void |
sync() |
void |
update(PreferencesImpl impl)
Update from the preferences impl.
|
protected boolean valid
protected final PreferencesImpl parent
protected final Map<String,PreferencesImpl> children
protected final String name
protected final PreferencesDescription description
protected final BackingStoreManager storeManager
protected final ChangeSet changeSet
public PreferencesImpl(PreferencesDescription d, BackingStoreManager storeManager)
d - The unique description.storeManager - The backing store.public PreferencesImpl(PreferencesImpl p, String name)
p - The parent node.name - The node namepublic ChangeSet getChangeSet()
public PreferencesDescription getDescription()
public PreferencesImpl getRoot()
public Collection<PreferencesImpl> getChildren()
public BackingStoreManager getBackingStoreManager()
protected void checkValidity()
throws IllegalStateException
IllegalStateExceptionprotected void checkKey(String key) throws NullPointerException
NullPointerExceptionprotected void checkValue(Object value) throws NullPointerException
NullPointerExceptionpublic boolean isValid()
public void put(String key, String value)
put in interface org.osgi.service.prefs.PreferencesPreferences.put(java.lang.String, java.lang.String)public String get(String key, String def)
get in interface org.osgi.service.prefs.PreferencesPreferences.get(java.lang.String, java.lang.String)public void remove(String key)
remove in interface org.osgi.service.prefs.PreferencesPreferences.remove(java.lang.String)public void clear()
throws org.osgi.service.prefs.BackingStoreException
clear in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.clear()public void putInt(String key, int value)
putInt in interface org.osgi.service.prefs.PreferencesPreferences.putInt(java.lang.String, int)public int getInt(String key, int def)
getInt in interface org.osgi.service.prefs.PreferencesPreferences.getInt(java.lang.String, int)public void putLong(String key, long value)
putLong in interface org.osgi.service.prefs.PreferencesPreferences.putLong(java.lang.String, long)public long getLong(String key, long def)
getLong in interface org.osgi.service.prefs.PreferencesPreferences.getLong(java.lang.String, long)public void putBoolean(String key, boolean value)
putBoolean in interface org.osgi.service.prefs.PreferencesPreferences.putBoolean(java.lang.String, boolean)public boolean getBoolean(String key, boolean def)
getBoolean in interface org.osgi.service.prefs.PreferencesPreferences.getBoolean(java.lang.String, boolean)public void putFloat(String key, float value)
putFloat in interface org.osgi.service.prefs.PreferencesPreferences.putFloat(java.lang.String, float)public float getFloat(String key, float def)
getFloat in interface org.osgi.service.prefs.PreferencesPreferences.getFloat(java.lang.String, float)public void putDouble(String key, double value)
putDouble in interface org.osgi.service.prefs.PreferencesPreferences.putDouble(java.lang.String, double)public double getDouble(String key, double def)
getDouble in interface org.osgi.service.prefs.PreferencesPreferences.getDouble(java.lang.String, double)public void putByteArray(String key, byte[] value)
putByteArray in interface org.osgi.service.prefs.PreferencesPreferences.putByteArray(java.lang.String, byte[])public byte[] getByteArray(String key, byte[] def)
getByteArray in interface org.osgi.service.prefs.PreferencesPreferences.getByteArray(java.lang.String, byte[])public String[] keys() throws org.osgi.service.prefs.BackingStoreException
keys in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.keys()public String[] childrenNames() throws org.osgi.service.prefs.BackingStoreException
childrenNames in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.childrenNames()public org.osgi.service.prefs.Preferences parent()
parent in interface org.osgi.service.prefs.PreferencesPreferences.parent()public org.osgi.service.prefs.Preferences node(String pathName)
node in interface org.osgi.service.prefs.PreferencesPreferences.node(java.lang.String)public PreferencesImpl getOrCreateNode(String pathName)
pathName - protected PreferencesImpl getNode(String path, boolean saveNewlyCreatedNode, boolean create)
path - public boolean nodeExists(String pathName) throws org.osgi.service.prefs.BackingStoreException
nodeExists in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.nodeExists(java.lang.String)public void removeNode()
throws org.osgi.service.prefs.BackingStoreException
removeNode in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.removeNode()protected void safelyRemoveNode()
protected void removeChild(PreferencesImpl child)
public String name()
name in interface org.osgi.service.prefs.PreferencesPreferences.name()public String absolutePath()
absolutePath in interface org.osgi.service.prefs.PreferencesPreferences.absolutePath()public void flush()
throws org.osgi.service.prefs.BackingStoreException
flush in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.flush()public void sync()
throws org.osgi.service.prefs.BackingStoreException
sync in interface org.osgi.service.prefs.Preferencesorg.osgi.service.prefs.BackingStoreExceptionPreferences.sync()public void update(PreferencesImpl impl)
impl - public void applyChanges(PreferencesImpl prefs)
prefs - Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.