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 SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidstatic @Nullable TransformationServicegetTransformationService(@Nullable org.osgi.framework.BundleContext context, String transformationType) Deprecated.static @Nullable TransformationServicegetTransformationService(String serviceName) 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- 
TransformationHelperpublic TransformationHelper(org.osgi.framework.BundleContext bundleContext) 
 
- 
- 
Method Details- 
deactivatepublic void deactivate()
- 
setTransformationServicepublic void setTransformationService(org.osgi.framework.ServiceReference<TransformationService> ref) 
- 
unsetTransformationServicepublic void unsetTransformationService(org.osgi.framework.ServiceReference<TransformationService> ref) 
- 
isTransformdetermines 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 null
- transformationType- 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 services
- transformationString- the pattern that contains the transformation instructions
- state- 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
 
- 
transformpublic 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 instructions
- state- 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
 
- 
transformpublic static @Nullable String transform(TransformationService service, String function, String format, String state) throws TransformationException Transforms a state string using a transformation service- Parameters:
- service- the- TransformationServiceto be used
- function- the function containing the transformation instruction
- format- the format the state should be converted to before transformation
- state- 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