|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.prefs.PreferencesImpl
public class PreferencesImpl
This is an implementation of the preferences. The access to the preferences is synchronized on the instance by making (nearly) all public methods synchronized. This avoids the heavy management of a separate read/write lock. Such a lock is too heavy for the simple operations preferences support. The various getXX and putXX methods are not synchronized as they all use the get/put methods which are synchronized.
Field Summary | |
---|---|
protected ChangeSet |
changeSet
The change set keeps track of all changes. |
protected java.util.Map |
children
The child nodes. |
protected PreferencesDescription |
description
The description for this preferences. |
protected java.lang.String |
name
The name of the properties. |
protected PreferencesImpl |
parent
The parent. |
protected java.util.Map |
properties
The properties. |
protected BackingStoreManager |
storeManager
The backing store manager. |
protected boolean |
valid
Has this node been removed? |
Constructor Summary | |
---|---|
PreferencesImpl(PreferencesDescription d,
BackingStoreManager storeManager)
Construct the root node of the tree. |
|
PreferencesImpl(PreferencesImpl p,
java.lang.String name)
Construct a child node. |
Method Summary | |
---|---|
java.lang.String |
absolutePath()
|
void |
applyChanges(PreferencesImpl prefs)
Apply the changes done to the passed preferences object. |
protected void |
checkKey(java.lang.String key)
The key is not allowed to be null. |
protected void |
checkValidity()
Check if this node is still valid. |
protected void |
checkValue(java.lang.Object value)
The value is not allowed to be null. |
java.lang.String[] |
childrenNames()
|
void |
clear()
|
void |
flush()
|
java.lang.String |
get(java.lang.String key,
java.lang.String def)
|
BackingStoreManager |
getBackingStoreManager()
Return the backing store manager. |
boolean |
getBoolean(java.lang.String key,
boolean def)
|
byte[] |
getByteArray(java.lang.String key,
byte[] def)
|
ChangeSet |
getChangeSet()
Return the change set. |
java.util.Collection |
getChildren()
Return all children or an empty collection. |
PreferencesDescription |
getDescription()
Return the preferences description. |
double |
getDouble(java.lang.String key,
double def)
|
float |
getFloat(java.lang.String key,
float def)
|
int |
getInt(java.lang.String key,
int def)
|
long |
getLong(java.lang.String key,
long def)
|
protected PreferencesImpl |
getNode(java.lang.String path,
boolean saveNewlyCreatedNode,
boolean create)
Get a relative node. |
PreferencesImpl |
getOrCreateNode(java.lang.String pathName)
Get or create the node. |
java.util.Map |
getProperties()
Return the properties set. |
PreferencesImpl |
getRoot()
Get the root preferences. |
java.lang.String[] |
keys()
|
java.lang.String |
name()
|
org.osgi.service.prefs.Preferences |
node(java.lang.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(java.lang.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(java.lang.String key,
java.lang.String value)
|
void |
putBoolean(java.lang.String key,
boolean value)
|
void |
putByteArray(java.lang.String key,
byte[] value)
|
void |
putDouble(java.lang.String key,
double value)
|
void |
putFloat(java.lang.String key,
float value)
|
void |
putInt(java.lang.String key,
int value)
|
void |
putLong(java.lang.String key,
long value)
|
void |
remove(java.lang.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.util.Map properties
protected boolean valid
protected final PreferencesImpl parent
protected final java.util.Map children
protected final java.lang.String name
protected final PreferencesDescription description
protected final BackingStoreManager storeManager
protected final ChangeSet changeSet
Constructor Detail |
---|
public PreferencesImpl(PreferencesDescription d, BackingStoreManager storeManager)
d
- The unique description.storeManager
- The backing store.public PreferencesImpl(PreferencesImpl p, java.lang.String name)
p
- The parent node.name
- The node nameMethod Detail |
---|
public ChangeSet getChangeSet()
public PreferencesDescription getDescription()
public PreferencesImpl getRoot()
public java.util.Collection getChildren()
public java.util.Map getProperties()
public BackingStoreManager getBackingStoreManager()
protected void checkValidity() throws java.lang.IllegalStateException
java.lang.IllegalStateException
protected void checkKey(java.lang.String key) throws java.lang.NullPointerException
java.lang.NullPointerException
protected void checkValue(java.lang.Object value) throws java.lang.NullPointerException
java.lang.NullPointerException
public void put(java.lang.String key, java.lang.String value)
put
in interface org.osgi.service.prefs.Preferences
Preferences.put(java.lang.String, java.lang.String)
public java.lang.String get(java.lang.String key, java.lang.String def)
get
in interface org.osgi.service.prefs.Preferences
Preferences.get(java.lang.String, java.lang.String)
public void remove(java.lang.String key)
remove
in interface org.osgi.service.prefs.Preferences
Preferences.remove(java.lang.String)
public void clear() throws org.osgi.service.prefs.BackingStoreException
clear
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.clear()
public void putInt(java.lang.String key, int value)
putInt
in interface org.osgi.service.prefs.Preferences
Preferences.putInt(java.lang.String, int)
public int getInt(java.lang.String key, int def)
getInt
in interface org.osgi.service.prefs.Preferences
Preferences.getInt(java.lang.String, int)
public void putLong(java.lang.String key, long value)
putLong
in interface org.osgi.service.prefs.Preferences
Preferences.putLong(java.lang.String, long)
public long getLong(java.lang.String key, long def)
getLong
in interface org.osgi.service.prefs.Preferences
Preferences.getLong(java.lang.String, long)
public void putBoolean(java.lang.String key, boolean value)
putBoolean
in interface org.osgi.service.prefs.Preferences
Preferences.putBoolean(java.lang.String, boolean)
public boolean getBoolean(java.lang.String key, boolean def)
getBoolean
in interface org.osgi.service.prefs.Preferences
Preferences.getBoolean(java.lang.String, boolean)
public void putFloat(java.lang.String key, float value)
putFloat
in interface org.osgi.service.prefs.Preferences
Preferences.putFloat(java.lang.String, float)
public float getFloat(java.lang.String key, float def)
getFloat
in interface org.osgi.service.prefs.Preferences
Preferences.getFloat(java.lang.String, float)
public void putDouble(java.lang.String key, double value)
putDouble
in interface org.osgi.service.prefs.Preferences
Preferences.putDouble(java.lang.String, double)
public double getDouble(java.lang.String key, double def)
getDouble
in interface org.osgi.service.prefs.Preferences
Preferences.getDouble(java.lang.String, double)
public void putByteArray(java.lang.String key, byte[] value)
putByteArray
in interface org.osgi.service.prefs.Preferences
Preferences.putByteArray(java.lang.String, byte[])
public byte[] getByteArray(java.lang.String key, byte[] def)
getByteArray
in interface org.osgi.service.prefs.Preferences
Preferences.getByteArray(java.lang.String, byte[])
public java.lang.String[] keys() throws org.osgi.service.prefs.BackingStoreException
keys
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.keys()
public java.lang.String[] childrenNames() throws org.osgi.service.prefs.BackingStoreException
childrenNames
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.childrenNames()
public org.osgi.service.prefs.Preferences parent()
parent
in interface org.osgi.service.prefs.Preferences
Preferences.parent()
public org.osgi.service.prefs.Preferences node(java.lang.String pathName)
node
in interface org.osgi.service.prefs.Preferences
Preferences.node(java.lang.String)
public PreferencesImpl getOrCreateNode(java.lang.String pathName)
pathName
-
protected PreferencesImpl getNode(java.lang.String path, boolean saveNewlyCreatedNode, boolean create)
path
-
public boolean nodeExists(java.lang.String pathName) throws org.osgi.service.prefs.BackingStoreException
nodeExists
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.nodeExists(java.lang.String)
public void removeNode() throws org.osgi.service.prefs.BackingStoreException
removeNode
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.removeNode()
protected void safelyRemoveNode()
protected void removeChild(PreferencesImpl child)
public java.lang.String name()
name
in interface org.osgi.service.prefs.Preferences
Preferences.name()
public java.lang.String absolutePath()
absolutePath
in interface org.osgi.service.prefs.Preferences
Preferences.absolutePath()
public void flush() throws org.osgi.service.prefs.BackingStoreException
flush
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.flush()
public void sync() throws org.osgi.service.prefs.BackingStoreException
sync
in interface org.osgi.service.prefs.Preferences
org.osgi.service.prefs.BackingStoreException
Preferences.sync()
public void update(PreferencesImpl impl)
impl
- public void applyChanges(PreferencesImpl prefs)
prefs
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |