Class ScriptTransformationService
- java.lang.Object
-
- org.openhab.core.automation.module.script.ScriptTransformationService
-
- All Implemented Interfaces:
RegistryChangeListener<TransformationConfiguration>
,TransformationService
@NonNullByDefault public class ScriptTransformationService extends Object implements TransformationService, RegistryChangeListener<TransformationConfiguration>
TheScriptTransformationService
implements aTransformationService
using any available script language- Author:
- Jan N. Klug - Initial contribution
-
-
Field Summary
Fields Modifier and Type Field Description static String
OPENHAB_TRANSFORMATION_SCRIPT
static String
SUPPORTED_CONFIGURATION_TYPE
-
Fields inherited from interface org.openhab.core.transform.TransformationService
TRANSFORM_FOLDER_NAME, TRANSFORM_PROFILE_SCOPE
-
-
Constructor Summary
Constructors Constructor Description ScriptTransformationService(TransformationConfigurationRegistry transformationConfigurationRegistry, ScriptEngineManager scriptEngineManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
added(TransformationConfiguration element)
Notifies the listener that a single element has been added.void
deactivate()
void
removed(TransformationConfiguration element)
Notifies the listener that a single element has been removed.@Nullable String
transform(String function, String source)
Transforms the inputsource
by means of the givenfunction
and returns the transformed output.void
updated(TransformationConfiguration oldElement, TransformationConfiguration element)
Notifies the listener that a single element has been updated.
-
-
-
Field Detail
-
OPENHAB_TRANSFORMATION_SCRIPT
public static final String OPENHAB_TRANSFORMATION_SCRIPT
- See Also:
- Constant Field Values
-
SUPPORTED_CONFIGURATION_TYPE
public static final String SUPPORTED_CONFIGURATION_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ScriptTransformationService
public ScriptTransformationService(TransformationConfigurationRegistry transformationConfigurationRegistry, ScriptEngineManager scriptEngineManager)
-
-
Method Detail
-
deactivate
public void deactivate()
-
transform
public @Nullable String transform(String function, String source) throws TransformationException
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 anTransformationException
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
public void added(TransformationConfiguration element)
Description copied from interface:RegistryChangeListener
Notifies the listener that a single element has been added.- Specified by:
added
in interfaceRegistryChangeListener<TransformationConfiguration>
- Parameters:
element
- the element that has been added
-
removed
public void removed(TransformationConfiguration element)
Description copied from interface:RegistryChangeListener
Notifies the listener that a single element has been removed.- Specified by:
removed
in interfaceRegistryChangeListener<TransformationConfiguration>
- Parameters:
element
- the element that has been removed
-
updated
public void updated(TransformationConfiguration oldElement, TransformationConfiguration element)
Description copied from interface:RegistryChangeListener
Notifies the listener that a single element has been updated.- Specified by:
updated
in interfaceRegistryChangeListener<TransformationConfiguration>
- Parameters:
oldElement
- the element that has been updatedelement
- the new element
-
-