Class AbstractPreferenceStorage
java.lang.Object
org.eclipse.core.runtime.preferences.AbstractPreferenceStorage
Abstract class which can be used to help provide an alternate storage
mechanism for Eclipse preferences. Clients can over-ride this class and
implement the appropriate methods to read/persist preferences.
- Since:
- 3.5
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract String[]
childrenNames
(String nodePath) Return a string array containing the names of the children for the node with the given path.abstract Properties
Return ajava.util.Properties
object containing the preference key/value pairs for the preference node with the specified path, and its children.protected Properties
loadProperties
(InputStream input) Helper method to load ajava.util.Properties
file from the given input stream.abstract void
Callback to inform the client that the preference node with the specified path has been deleted and the client should react accordingly and make the appropriate changes to the storage.abstract void
save
(String nodePath, Properties properties) Save the givenjava.util.Properties
object which represents preference key/value pairs for the preference node represented by the given path.protected void
saveProperties
(OutputStream output, Properties properties) Helper method to save the givenjava.util.Properties
object to the given output stream.
-
Constructor Details
-
AbstractPreferenceStorage
public AbstractPreferenceStorage()
-
-
Method Details
-
load
Return ajava.util.Properties
object containing the preference key/value pairs for the preference node with the specified path, and its children.The table keys consist of an optional child node path and separator, followed by the property key. The table values are the values of the properties.
[childNodePath/]propertyKey=propertyValue
Note: Whether they are absolute or relative, the paths in the returned Properties object are always interpreted as relative to the node specified by nodePath.
- Parameters:
nodePath
- the absolute path of the preference node- Returns:
- a
java.util.Properties
object ornull
- Throws:
BackingStoreException
- if there was a problem loading the properties
-
save
Save the givenjava.util.Properties
object which represents preference key/value pairs for the preference node represented by the given path.Clients are reminded that if the given properties object is empty then the preference node has been removed and they should react accordingly (e.g. for instance by removing the file on disk)
- Parameters:
nodePath
- the absolute path of the preference nodeproperties
- thejava.util.Properties
object to store- Throws:
BackingStoreException
- if there was a problem saving the properties
-
loadProperties
Helper method to load ajava.util.Properties
file from the given input stream. The stream will be closed on completion of the operation.- Parameters:
input
- the stream to load from- Returns:
- the
java.util.Properties
object loaded from the stream - Throws:
BackingStoreException
- if there was a problem loading the file
-
saveProperties
protected void saveProperties(OutputStream output, Properties properties) throws BackingStoreException Helper method to save the givenjava.util.Properties
object to the given output stream. The stream will be closed at the end of the operation.- Parameters:
output
- the stream to store the object toproperties
- the object to store- Throws:
BackingStoreException
- if there was a problem saving the object
-
childrenNames
Return a string array containing the names of the children for the node with the given path. If there are no children then an empty array is returned. One example where this method is commonly called, is at the scope root when discovering the initial children.- Parameters:
nodePath
- the path for the preference node- Returns:
- the array of children names
- Throws:
BackingStoreException
- if there was a problem retrieving the child names
-
removed
Callback to inform the client that the preference node with the specified path has been deleted and the client should react accordingly and make the appropriate changes to the storage. (e.g. delete the file/information associated with that node)- Parameters:
nodePath
- the absolute path of the preference node
-