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
FieldsFields inherited from interface org.openhab.core.transform.TransformationService
SERVICE_PROPERTY_LABEL, SERVICE_PROPERTY_NAME, TRANSFORM_FOLDER_NAME, TRANSFORM_PROFILE_SCOPE -
Constructor Summary
ConstructorsConstructorDescriptionScriptTransformationService(TransformationRegistry transformationRegistry, ConfigDescriptionRegistry configDescRegistry, ScriptEngineManager scriptEngineManager, Map<String, Object> config) -
Method Summary
Modifier and TypeMethodDescriptionvoidadded(Transformation element) Notifies the listener that a single element has been added.void@Nullable ConfigDescriptiongetConfigDescription(URI uri, @Nullable Locale locale) Provides aConfigDescriptionfor the given URI.getConfigDescriptions(@Nullable Locale locale) Provides a collection ofConfigDescriptions.@Nullable Collection<ParameterOption>getParameterOptions(URI uri, String param, @Nullable String context, @Nullable Locale locale) Provides a collection ofParameterOptions.voidremoved(Transformation element) Notifies the listener that a single element has been removed.@Nullable StringTransforms the inputsourceby means of the givenfunctionand returns the transformed output.voidupdated(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:TransformationServiceTransforms the inputsourceby means of the givenfunctionand returns the transformed output. The transformation may returnnullto express its operation resulted in anulloutput. In case of any error aTransformationExceptionshould be thrown.- Specified by:
transformin interfaceTransformationService- Parameters:
function- the function to be used to transform the inputsource- the input to be transformed- Returns:
- the transformed result or
nullif the transformation's output isnull. - Throws:
TransformationException- if any error occurs
-
added
Description copied from interface:RegistryChangeListenerNotifies the listener that a single element has been added.- Specified by:
addedin interfaceRegistryChangeListener<Transformation>- Parameters:
element- the element that has been added
-
removed
Description copied from interface:RegistryChangeListenerNotifies the listener that a single element has been removed.- Specified by:
removedin interfaceRegistryChangeListener<Transformation>- Parameters:
element- the element that has been removed
-
updated
Description copied from interface:RegistryChangeListenerNotifies the listener that a single element has been updated.- Specified by:
updatedin 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:ConfigOptionProviderProvides a collection ofParameterOptions.- Specified by:
getParameterOptionsin 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
nullotherwise
-
getConfigDescriptions
Description copied from interface:ConfigDescriptionProviderProvides a collection ofConfigDescriptions.- Specified by:
getConfigDescriptionsin interfaceConfigDescriptionProvider- Parameters:
locale- locale- Returns:
- the configuration descriptions provided by this provider (not null, could be empty)
-
getConfigDescription
Description copied from interface:ConfigDescriptionProviderProvides aConfigDescriptionfor the given URI.- Specified by:
getConfigDescriptionin interfaceConfigDescriptionProvider- Parameters:
uri- uri of the config descriptionlocale- locale- Returns:
- config description or null if no config description could be found
-