Interface PersistenceStrategy


public interface PersistenceStrategy
Interface implemented by classes that can read and write configuration properties. Implementations should be mappable to the file extension, or some unique key, that is the format it supports reading from and writing to. While this was built for writing to disk, that is not a hard requirement on new implementations.

This interface should not be used to obtain an arbitrary instance, as implementations may greatly vary, and no data validation is performed to alert the consumer of the service what is or is not supported. Filter results using the STRATEGY_EXTENSION service property.

This interface is for internal use only.

This code is experimental. While this interface is functional and tested, it may change or be removed in a future version of the library.

  • Field Details

    • STRATEGY_EXTENSION

      static final String STRATEGY_EXTENSION
      Service property key to get the file extension a particular strategy can operate upon.
      See Also:
  • Method Details

    • getExtension

      String getExtension()
      Gets the extension handled by this strategy.
      Returns:
      the extension (without the prefix .) handled by this strategy
    • read

      Dictionary<String,Object> read(InputStream inputStream) throws IOException
      Reads the configuration properties from an InputStream. The stream will not be closed automatically.
      Parameters:
      inputStream - input stream where the properties will be read from
      Returns:
      the properties read
      Throws:
      IOException - thrown if the properties couldn't be read
    • write

      void write(OutputStream outputStream, Dictionary<String,Object> properties) throws IOException
      Writes the configuration properties to an OutputStream. The stream will not be closed automatically.
      Parameters:
      outputStream - output stream where the properties will be written
      properties - properties to write
      Throws:
      IOException - thrown if the properties couldn't be written