Class ScriptTransformationService
java.lang.Object
org.openhab.core.automation.module.script.ScriptTransformationService
- All Implemented Interfaces:
RegistryChangeListener<Transformation>
,ConfigDescriptionProvider
,ConfigOptionProvider
,TransformationService
@NonNullByDefault
public class ScriptTransformationService
extends Object
implements TransformationService, ConfigOptionProvider, ConfigDescriptionProvider, RegistryChangeListener<Transformation>
The
ScriptTransformationService
implements a TransformationService
using any available script
language- Author:
- Jan N. Klug - Initial contribution
-
Field Summary
Fields inherited from interface org.openhab.core.transform.TransformationService
SERVICE_PROPERTY_LABEL, SERVICE_PROPERTY_NAME, TRANSFORM_FOLDER_NAME, TRANSFORM_PROFILE_SCOPE
-
Constructor Summary
ConstructorDescriptionScriptTransformationService
(TransformationRegistry transformationRegistry, ConfigDescriptionRegistry configDescRegistry, ScriptEngineManager scriptEngineManager, Map<String, Object> config) -
Method Summary
Modifier and TypeMethodDescriptionvoid
added
(Transformation element) Notifies the listener that a single element has been added.void
@Nullable ConfigDescription
getConfigDescription
(URI uri, @Nullable Locale locale) Provides aConfigDescription
for the given URI.getConfigDescriptions
(@Nullable Locale locale) Provides a collection ofConfigDescription
s.@Nullable Collection
<ParameterOption> getParameterOptions
(URI uri, String param, @Nullable String context, @Nullable Locale locale) Provides a collection ofParameterOption
s.void
removed
(Transformation element) Notifies the listener that a single element has been removed.@Nullable String
Transforms the inputsource
by means of the givenfunction
and returns the transformed output.void
updated
(Transformation oldElement, Transformation element) Notifies the listener that a single element has been updated.
-
Field Details
-
SCRIPT_TYPE_PROPERTY_NAME
- See Also:
-
OPENHAB_TRANSFORMATION_SCRIPT
- See Also:
-
-
Constructor Details
-
ScriptTransformationService
public ScriptTransformationService(TransformationRegistry transformationRegistry, ConfigDescriptionRegistry configDescRegistry, ScriptEngineManager scriptEngineManager, Map<String, Object> config)
-
-
Method Details
-
deactivate
public void deactivate() -
transform
Description copied from interface:TransformationService
Transforms the inputsource
by means of the givenfunction
and returns the transformed output. The transformation may returnnull
to express its operation resulted in anull
output. In case of any error aTransformationException
should be thrown.- Specified by:
transform
in interfaceTransformationService
- Parameters:
function
- the function to be used to transform the inputsource
- the input to be transformed- Returns:
- the transformed result or
null
if the transformation's output isnull
. - Throws:
TransformationException
- if any error occurs
-
added
Description copied from interface:RegistryChangeListener
Notifies the listener that a single element has been added.- Specified by:
added
in interfaceRegistryChangeListener<Transformation>
- Parameters:
element
- the element that has been added
-
removed
Description copied from interface:RegistryChangeListener
Notifies the listener that a single element has been removed.- Specified by:
removed
in interfaceRegistryChangeListener<Transformation>
- Parameters:
element
- the element that has been removed
-
updated
Description copied from interface:RegistryChangeListener
Notifies the listener that a single element has been updated.- Specified by:
updated
in interfaceRegistryChangeListener<Transformation>
- Parameters:
oldElement
- the element that has been updatedelement
- the new element
-
getParameterOptions
public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable String context, @Nullable Locale locale) Description copied from interface:ConfigOptionProvider
Provides a collection ofParameterOption
s.- Specified by:
getParameterOptions
in interfaceConfigOptionProvider
- Parameters:
uri
- the uri of the config descriptionparam
- the parameter name for which the requested options shall be returnedcontext
- the defined context of the parameterlocale
- the locale in which the result is expected- Returns:
- the configuration options provided by this provider if any or
null
otherwise
-
getConfigDescriptions
Description copied from interface:ConfigDescriptionProvider
Provides a collection ofConfigDescription
s.- Specified by:
getConfigDescriptions
in interfaceConfigDescriptionProvider
- Parameters:
locale
- locale- Returns:
- the configuration descriptions provided by this provider (not null, could be empty)
-
getConfigDescription
Description copied from interface:ConfigDescriptionProvider
Provides aConfigDescription
for the given URI.- Specified by:
getConfigDescription
in interfaceConfigDescriptionProvider
- Parameters:
uri
- uri of the config descriptionlocale
- locale- Returns:
- config description or null if no config description could be found
-