Package com.adobe.cq.dam.cfm.converter
Interface ContentTypeConverter
-
public interface ContentTypeConverter
Provides means to convert texts of a certain content type to another content type.
The entire conversion process uses HTML as base format. This means that you might need two conversion steps to convert a text from format A to format B: First, you convert format A to HTML. Then the HTML to format B.
For example, to convert a plain text to Markdown, use the following snippet:
String html = converter.convertToHTML(plainText, "text/plain");
String markdown = converter.convertToType(html, "text/x-markdown");Note that depending on the quality of the
ContentTypeAdapter
implementations (or the target text format) you might loose some (or all) formatting.Additional
ContentTypeAdapter
s can be provided by external bundles. To override default adapters, use the OSGi service ranking. The default adapters have a service ranking of 0.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
convertToHTML(java.lang.String text, java.lang.String type)
Converts a given text of the specified format to its HTML equivalent.java.lang.String
convertToType(java.lang.String html, java.lang.String type)
Converts the given HTML fragment to an equivalent text of the specified target format.
-
-
-
Method Detail
-
convertToHTML
java.lang.String convertToHTML(java.lang.String text, java.lang.String type) throws ContentFragmentException
Converts a given text of the specified format to its HTML equivalent.- Parameters:
text
- The texttype
- The MIME type of the text's format- Returns:
- The HTML equivalent
- Throws:
ContentFragmentException
- if the conversion failed
-
convertToType
java.lang.String convertToType(java.lang.String html, java.lang.String type) throws ContentFragmentException
Converts the given HTML fragment to an equivalent text of the specified target format.- Parameters:
html
- The original HTML fragmenttype
- The MIME type of the target format- Returns:
- The converted text
- Throws:
ContentFragmentException
- if the conversion failed
-
-