Class AbstractFileTransformationService<T>

java.lang.Object
org.openhab.core.transform.AbstractFileTransformationService<T>
All Implemented Interfaces:
TransformationService

@NonNullByDefault public abstract class AbstractFileTransformationService<T> extends Object implements TransformationService
Deprecated.
use the TransformationRegistry instead
Base class for cacheable and localizable file based transformation TransformationService. It expects the transformation to be applied to be read from a file stored under the 'transform' folder within the configuration path. To organize the various transformations one might use subfolders.
Author:
Gaƫl L'hopital - Initial contribution, Kai Kreuzer - File caching mechanism, Markus Rathgeb - Add locale provider support
  • Field Details

    • cachedFiles

      protected final Map<String,T> cachedFiles
      Deprecated.
    • watchedDirectories

      protected final List<String> watchedDirectories
      Deprecated.
  • Constructor Details

    • AbstractFileTransformationService

      public AbstractFileTransformationService()
      Deprecated.
  • Method Details

    • activate

      protected void activate(org.osgi.framework.BundleContext context)
      Deprecated.
    • deactivate

      protected void deactivate()
      Deprecated.
    • getLocale

      protected Locale getLocale()
      Deprecated.
    • transform

      public @Nullable String transform(String filename, String source) throws TransformationException
      Deprecated.

      Transforms the input source by the according method defined in subclass to another string. It expects the transformation to be read from a file which is stored under the 'conf/transform'

      Specified by:
      transform in interface TransformationService
      Parameters:
      filename - the name of the file which contains the transformation definition. The name may contain subfoldernames as well
      source - the input to transform
      Returns:
      the transformed result or null if the transformation's output is null.
      Throws:
      TransformationException
    • internalTransform

      protected abstract @Nullable String internalTransform(T transform, String source) throws TransformationException
      Deprecated.

      Abstract method defined by subclasses to effectively operate the transformation according to its rules

      Parameters:
      transform - transformation held by the file provided to transform method
      source - the input to transform
      Returns:
      the transformed result or null if the transformation couldn't be completed for any reason.
      Throws:
      TransformationException
    • internalLoadTransform

      protected abstract T internalLoadTransform(String filename) throws TransformationException
      Deprecated.

      Abstract method defined by subclasses to effectively read the transformation source file according to their own needs.

      Parameters:
      filename - Name of the file to be read. This filename may have been transposed to a localized one
      Returns:
      An object containing the source file
      Throws:
      TransformationException - file couldn't be read for any reason
    • getLocalizedProposedFilename

      protected String getLocalizedProposedFilename(String filename, WatchService watchService)
      Deprecated.
      Returns the name of the localized transformation file if it actually exists, keeps the original in the other case
      Parameters:
      filename - name of the requested transformation file
      Returns:
      original or localized transformation file to use
    • getSourcePath

      protected String getSourcePath()
      Deprecated.
      Returns the path to the root of the transformation folder
    • getFilenames

      protected List<String> getFilenames(String[] validExtensions)
      Deprecated.
      Returns a list of all files with the given extensions in the transformation folder