Class ScriptTransformationService
java.lang.Object
org.openhab.core.automation.module.script.ScriptTransformationService
- All Implemented Interfaces:
- ScriptDependencyTracker.Listener,- RegistryChangeListener<Transformation>,- ConfigDescriptionProvider,- ConfigOptionProvider,- TransformationService
@NonNullByDefault
public class ScriptTransformationService
extends Object
implements TransformationService, ScriptDependencyTracker.Listener, ConfigOptionProvider, ConfigDescriptionProvider, RegistryChangeListener<Transformation>
The 
ScriptTransformationService implements a TransformationService using any available script
 language- Author:
- Jan N. Klug - Initial contribution, Florian Hotze - Implement script dependency tracking
- 
Field SummaryFieldsFields inherited from interface org.openhab.core.transform.TransformationServiceSERVICE_PROPERTY_LABEL, SERVICE_PROPERTY_NAME, TRANSFORM_FOLDER_NAME, TRANSFORM_PROFILE_SCOPE
- 
Constructor SummaryConstructorsConstructorDescriptionScriptTransformationService(TransformationRegistry transformationRegistry, ConfigDescriptionRegistry configDescRegistry, ScriptEngineManager scriptEngineManager, Map<String, Object> config) 
- 
Method SummaryModifier 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.voidonDependencyChange(String scriptId) Called by the dependency tracker when a registered dependency changesvoidremoved(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- 
ScriptTransformationServicepublic ScriptTransformationService(TransformationRegistry transformationRegistry, ConfigDescriptionRegistry configDescRegistry, ScriptEngineManager scriptEngineManager, Map<String, Object> config) 
 
- 
- 
Method Details- 
deactivatepublic void deactivate()
- 
transformDescription 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 interface- TransformationService
- Parameters:
- function- the function to be used to transform the input
- source- the input to be transformed
- Returns:
- the transformed result or nullif the transformation's output isnull.
- Throws:
- TransformationException- if any error occurs
 
- 
addedDescription copied from interface:RegistryChangeListenerNotifies the listener that a single element has been added.- Specified by:
- addedin interface- RegistryChangeListener<Transformation>
- Parameters:
- element- the element that has been added
 
- 
removedDescription copied from interface:RegistryChangeListenerNotifies the listener that a single element has been removed.- Specified by:
- removedin interface- RegistryChangeListener<Transformation>
- Parameters:
- element- the element that has been removed
 
- 
updatedDescription copied from interface:RegistryChangeListenerNotifies the listener that a single element has been updated.- Specified by:
- updatedin interface- RegistryChangeListener<Transformation>
- Parameters:
- oldElement- the element that has been updated
- element- the new element
 
- 
getParameterOptionspublic @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 interface- ConfigOptionProvider
- Parameters:
- uri- the uri of the config description
- param- the parameter name for which the requested options shall be returned
- context- the defined context of the parameter
- locale- the locale in which the result is expected
- Returns:
- the configuration options provided by this provider if any or nullotherwise
 
- 
getConfigDescriptionsDescription copied from interface:ConfigDescriptionProviderProvides a collection ofConfigDescriptions.- Specified by:
- getConfigDescriptionsin interface- ConfigDescriptionProvider
- Parameters:
- locale- locale
- Returns:
- the configuration descriptions provided by this provider (not null, could be empty)
 
- 
getConfigDescriptionDescription copied from interface:ConfigDescriptionProviderProvides aConfigDescriptionfor the given URI.- Specified by:
- getConfigDescriptionin interface- ConfigDescriptionProvider
- Parameters:
- uri- uri of the config description
- locale- locale
- Returns:
- config description or null if no config description could be found
 
- 
onDependencyChangeDescription copied from interface:ScriptDependencyTracker.ListenerCalled by the dependency tracker when a registered dependency changes- Specified by:
- onDependencyChangein interface- ScriptDependencyTracker.Listener
- Parameters:
- scriptId- the identifier of the script whose dependency changed
 
 
-