Package org.openhab.core.transform
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.
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
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Deprecated. -
Field Summary
Modifier and TypeFieldDescriptionDeprecated.Deprecated.Fields inherited from interface org.openhab.core.transform.TransformationService
SERVICE_PROPERTY_LABEL, SERVICE_PROPERTY_NAME, TRANSFORM_FOLDER_NAME, TRANSFORM_PROFILE_SCOPE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
activate
(org.osgi.framework.BundleContext context) Deprecated.protected void
Deprecated.getFilenames
(String[] validExtensions) Deprecated.Returns a list of all files with the given extensions in the transformation folderprotected Locale
Deprecated.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 caseprotected String
Deprecated.Returns the path to the root of the transformation folderprotected abstract T
internalLoadTransform
(String filename) Deprecated.Abstract method defined by subclasses to effectively read the transformation source file according to their own needs.protected abstract @Nullable String
internalTransform
(T transform, String source) Deprecated.Abstract method defined by subclasses to effectively operate the transformation according to its rules@Nullable String
Deprecated.Transforms the inputsource
by the according method defined in subclass to another string.
-
Field Details
-
cachedFiles
Deprecated. -
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
Deprecated. -
transform
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 interfaceTransformationService
- Parameters:
filename
- the name of the file which contains the transformation definition. The name may contain subfoldernames as wellsource
- the input to transform- Returns:
- the transformed result or
null
if the transformation's output isnull
. - 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 totransform
methodsource
- the input to transform- Returns:
- the transformed result or null if the transformation couldn't be completed for any reason.
- Throws:
TransformationException
-
internalLoadTransform
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
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
Deprecated.Returns the path to the root of the transformation folder -
getFilenames
Deprecated.Returns a list of all files with the given extensions in the transformation folder
-
TransformationRegistry
instead