Class DefaultEditorFormatService
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.DefaultEditorFormatService
-
- All Implemented Interfaces:
EditorFormatService
public class DefaultEditorFormatService extends Object implements EditorFormatService
-
-
Constructor Summary
Constructors Constructor Description DefaultEditorFormatService(Marshaller<MacroDefinition> editorMacroMarshaller, Marshaller<Link> editorLinkMarshaller, Marshaller<EmbeddedImage> editorEmbeddedImageMarshaller, Unmarshaller<MacroDefinition> editorMacroUnmarshaller, Unmarshaller<Link> editorLinkUnmarshaller, Unmarshaller<EmbeddedImage> editorEmbeddedImageUnmarshaller, FragmentTransformer editorToStorageFragmentTransformer, FragmentTransformer storageToEditorFragmentTransformer, XmlEventReaderFactory xmlEventReaderFactory, ExceptionThrowingMigrator wikiToEditorHtmlMigrator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EmbeddedImage
convertEditToEmbeddedImage(String editFragment, ConversionContext context)
Returns aEmbeddedImage
from the suppliededitFragment
.Link
convertEditToLink(String editFragment, ConversionContext context)
Returns aMacroDefinition
from the suppliededitFragment
.MacroDefinition
convertEditToMacroDefinition(String editFragment, ConversionContext context)
Returns aMacroDefinition
from the suppliededitFragment
.String
convertEditToStorage(String editFragment, ConversionContext context)
Returns an storage format fragment for the suppliededitFragment
.String
convertEmbeddedImageToEdit(EmbeddedImage embeddedImage, ConversionContext context)
Returns an edit format fragment for the suppliedembeddedImage
.String
convertLinkToEdit(Link link, ConversionContext context)
Returns an edit format fragment for the suppliedlink
.String
convertMacroDefinitionToEdit(MacroDefinition macroDefinition, ConversionContext context)
Returns an edit format fragment for the suppliedmacroDefinition
.String
convertStorageToEdit(String storageFragment, ConversionContext context)
Returns an edit format fragment for the suppliedstorageFragment
.String
convertWikiToEdit(String wikiContent, ConversionContext context)
Returns the XHTML edit format equivalent of the suppliedwikiContent
(Wiki markup).
-
-
-
Constructor Detail
-
DefaultEditorFormatService
public DefaultEditorFormatService(Marshaller<MacroDefinition> editorMacroMarshaller, Marshaller<Link> editorLinkMarshaller, Marshaller<EmbeddedImage> editorEmbeddedImageMarshaller, Unmarshaller<MacroDefinition> editorMacroUnmarshaller, Unmarshaller<Link> editorLinkUnmarshaller, Unmarshaller<EmbeddedImage> editorEmbeddedImageUnmarshaller, FragmentTransformer editorToStorageFragmentTransformer, FragmentTransformer storageToEditorFragmentTransformer, XmlEventReaderFactory xmlEventReaderFactory, ExceptionThrowingMigrator wikiToEditorHtmlMigrator)
-
-
Method Detail
-
convertWikiToEdit
public String convertWikiToEdit(String wikiContent, ConversionContext context) throws XhtmlException
Description copied from interface:EditorFormatService
Returns the XHTML edit format equivalent of the suppliedwikiContent
(Wiki markup).- Specified by:
convertWikiToEdit
in interfaceEditorFormatService
- Parameters:
wikiContent
- to be converted.context
- for the conversion.- Returns:
- the XHTML storage format equivalent.
- Throws:
XhtmlException
- if there are any problems during the conversion.
-
convertStorageToEdit
public String convertStorageToEdit(String storageFragment, ConversionContext context) throws XMLStreamException, XhtmlException
Description copied from interface:EditorFormatService
Returns an edit format fragment for the suppliedstorageFragment
.- Specified by:
convertStorageToEdit
in interfaceEditorFormatService
- Parameters:
storageFragment
- to be converted (for example the body of a macro).context
- for the conversion.- Returns:
- the edit format fragment (HTML rather than XML).
- Throws:
XMLStreamException
- if there was a problem reading the storage fragment.XhtmlException
- if there was a problem creating the edit fragment.
-
convertEditToStorage
public String convertEditToStorage(String editFragment, ConversionContext context) throws XMLStreamException, XhtmlException
Description copied from interface:EditorFormatService
Returns an storage format fragment for the suppliededitFragment
.- Specified by:
convertEditToStorage
in interfaceEditorFormatService
- Parameters:
editFragment
- to be converted (for example the body of a macro).context
- for the conversion.- Returns:
- the storage format fragment.
- Throws:
XMLStreamException
- if there was a problem reading the edit fragment.XhtmlException
- if there was a problem creating the storage fragment.
-
convertMacroDefinitionToEdit
public String convertMacroDefinitionToEdit(MacroDefinition macroDefinition, ConversionContext context) throws XhtmlException
Description copied from interface:EditorFormatService
Returns an edit format fragment for the suppliedmacroDefinition
.The body of the macro definition is expected to be in storage format. It will be transformed to editor format as part of the conversion carried out in this method.
- Specified by:
convertMacroDefinitionToEdit
in interfaceEditorFormatService
- Parameters:
macroDefinition
- that describes the macro. The body of this macro definition (returned byMacroDefinition.getBody()
is expected to be in storage format.context
- for the conversion.- Returns:
- the edit format fragment (HTML rather than XML).
- Throws:
XhtmlException
- if there was a problem creating the fragment.
-
convertLinkToEdit
public String convertLinkToEdit(Link link, ConversionContext context) throws XhtmlException
Description copied from interface:EditorFormatService
Returns an edit format fragment for the suppliedlink
.- Specified by:
convertLinkToEdit
in interfaceEditorFormatService
- Parameters:
link
- that describes the link.context
- for the conversion.- Returns:
- the edit format fragment.
- Throws:
XhtmlException
- if there was a problem creating the fragment.
-
convertEmbeddedImageToEdit
public String convertEmbeddedImageToEdit(EmbeddedImage embeddedImage, ConversionContext context) throws XhtmlException
Description copied from interface:EditorFormatService
Returns an edit format fragment for the suppliedembeddedImage
.- Specified by:
convertEmbeddedImageToEdit
in interfaceEditorFormatService
- Parameters:
embeddedImage
- that describes the resource (such as an image).context
- for the conversion.- Returns:
- the edit format fragment.
- Throws:
XhtmlException
- if there was a problem creating the fragment.
-
convertEditToMacroDefinition
public MacroDefinition convertEditToMacroDefinition(String editFragment, ConversionContext context) throws XMLStreamException, XhtmlException
Description copied from interface:EditorFormatService
Returns aMacroDefinition
from the suppliededitFragment
.- Specified by:
convertEditToMacroDefinition
in interfaceEditorFormatService
- Parameters:
editFragment
- which should be the edit format definition of the macro (as XML rather than HTML).context
- for the conversion.- Returns:
- the MacroDefinition.
- Throws:
XMLStreamException
- if there was a problem reading the edit fragment.XhtmlException
- if there was a problem creating the MacroDefinition.
-
convertEditToLink
public Link convertEditToLink(String editFragment, ConversionContext context) throws XMLStreamException, XhtmlException
Description copied from interface:EditorFormatService
Returns aMacroDefinition
from the suppliededitFragment
.- Specified by:
convertEditToLink
in interfaceEditorFormatService
- Parameters:
editFragment
- which should be the edit format definition of the link (as XML rather than HTML).context
- for the conversion.- Returns:
- the MacroDefinition.
- Throws:
XMLStreamException
- if there was a problem reading the edit fragment.XhtmlException
- if there was a problem creating the Link.
-
convertEditToEmbeddedImage
public EmbeddedImage convertEditToEmbeddedImage(String editFragment, ConversionContext context) throws XMLStreamException, XhtmlException
Description copied from interface:EditorFormatService
Returns aEmbeddedImage
from the suppliededitFragment
.- Specified by:
convertEditToEmbeddedImage
in interfaceEditorFormatService
- Parameters:
editFragment
- which should be the edit format definition of the embedded image (as XHTML rather than HTML).context
- for the conversion.- Returns:
- the EmbeddedImage represented by the supplied editFragment.
- Throws:
XMLStreamException
- if there was a problem reading the edit fragment.XhtmlException
- if there was a problem creating the EmbeddedImage.
-
-