Class AbstractPreferenceStorage

java.lang.Object
org.eclipse.core.runtime.preferences.AbstractPreferenceStorage

public abstract class AbstractPreferenceStorage extends Object
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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String[]
    Return a string array containing the names of the children for the node with the given path.
    abstract Properties
    load(String nodePath)
    Return a java.util.Properties object containing the preference key/value pairs for the preference node with the specified path, and its children.
    protected Properties
    Helper method to load a java.util.Properties file from the given input stream.
    abstract void
    removed(String nodePath)
    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 given java.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 given java.util.Properties object to the given output stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractPreferenceStorage

      public AbstractPreferenceStorage()
  • Method Details

    • load

      public abstract Properties load(String nodePath) throws BackingStoreException
      Return a java.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 or null
      Throws:
      BackingStoreException - if there was a problem loading the properties
    • save

      public abstract void save(String nodePath, Properties properties) throws BackingStoreException
      Save the given java.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 node
      properties - the java.util.Properties object to store
      Throws:
      BackingStoreException - if there was a problem saving the properties
    • loadProperties

      protected Properties loadProperties(InputStream input) throws BackingStoreException
      Helper method to load a java.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 given java.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 to
      properties - the object to store
      Throws:
      BackingStoreException - if there was a problem saving the object
    • childrenNames

      public abstract String[] childrenNames(String nodePath) throws BackingStoreException
      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

      public abstract void removed(String nodePath)
      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