Package org.openhab.core.transform
Class TransformationHelper
java.lang.Object
org.openhab.core.transform.TransformationHelper
- Author:
- Kai Kreuzer - Initial contribution, Jan N. Klug - Refactored to OSGi service
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic @Nullable TransformationServicegetTransformationService(String serviceName) static @Nullable TransformationServicegetTransformationService(@Nullable org.osgi.framework.BundleContext context, String transformationType) Deprecated.static booleanisTransform(String pattern) determines whether a pattern refers to a transformation servicevoidsetTransformationService(org.osgi.framework.ServiceReference<TransformationService> ref) static @Nullable StringTransforms a state string using transformation functions within a given pattern.static @Nullable Stringtransform(TransformationService service, String function, String format, String state) Transforms a state string using a transformation servicestatic @Nullable StringDeprecated.Usetransform(String, String)insteadvoidunsetTransformationService(org.osgi.framework.ServiceReference<TransformationService> ref)
-
Field Details
-
FUNCTION_VALUE_DELIMITER
- See Also:
-
EXTRACT_TRANSFORMFUNCTION_PATTERN
-
-
Constructor Details
-
TransformationHelper
public TransformationHelper(org.osgi.framework.BundleContext bundleContext)
-
-
Method Details
-
deactivate
public void deactivate() -
setTransformationService
public void setTransformationService(org.osgi.framework.ServiceReference<TransformationService> ref) -
unsetTransformationService
public void unsetTransformationService(org.osgi.framework.ServiceReference<TransformationService> ref) -
isTransform
determines whether a pattern refers to a transformation service- Parameters:
pattern- the pattern to check- Returns:
- true, if the pattern contains a transformation
-
getTransformationService
-
getTransformationService
@Deprecated public static @Nullable TransformationService getTransformationService(@Nullable org.osgi.framework.BundleContext context, String transformationType) Deprecated.usegetTransformationService(String)insteadReturn the transformation service that provides a given transformation type (e.g. REGEX, XSLT, etc.)- Parameters:
context- the bundle context which can be nulltransformationType- the desired transformation type- Returns:
- a service instance or null, if none could be found
-
transform
@Deprecated public static @Nullable String transform(org.osgi.framework.BundleContext context, String transformationString, String state) throws TransformationException Deprecated.Usetransform(String, String)insteadTransforms a state string using transformation functions within a given pattern.- Parameters:
context- a valid bundle context, required for accessing the servicestransformationString- the pattern that contains the transformation instructionsstate- the state to be formatted before being passed into the transformation function- Returns:
- the result of the transformation. If no transformation was done,
nullis returned - Throws:
TransformationException- if transformation service is not available or the transformation failed
-
transform
public static @Nullable String transform(String transformationString, String state) throws TransformationException Transforms a state string using transformation functions within a given pattern.- Parameters:
transformationString- the pattern that contains the transformation instructionsstate- the state to be formatted before being passed into the transformation function- Returns:
- the result of the transformation. If no transformation was done,
nullis returned - Throws:
TransformationException- if transformation service is not available or the transformation failed
-
transform
public static @Nullable String transform(TransformationService service, String function, String format, String state) throws TransformationException Transforms a state string using a transformation service- Parameters:
service- theTransformationServiceto be usedfunction- the function containing the transformation instructionformat- the format the state should be converted to before transformationstate- the state to be formatted before being passed into the transformation function- Returns:
- the result of the transformation. If no transformation was done,
nullis returned - Throws:
TransformationException- if transformation service fails or the state cannot be formatted according to the format
-
getTransformationService(String)instead