Interface MacroRefactoring


  • @Role
    public interface MacroRefactoring
    Component dedicated to perform refactoring of existing macros.
    Since:
    13.4RC1
    Version:
    $Id: 3811f8b67ffc200b6508a777306845d02d2f00d1 $
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default Set<org.xwiki.rendering.listener.reference.ResourceReference> extractReferences​(org.xwiki.rendering.block.MacroBlock macroBlock)
      Extract references used in the macro so that they can be used for example for creating backlinks.
      Optional<org.xwiki.rendering.block.MacroBlock> replaceReference​(org.xwiki.rendering.block.MacroBlock macroBlock, org.xwiki.model.reference.DocumentReference currentDocumentReference, org.xwiki.model.reference.AttachmentReference sourceReference, org.xwiki.model.reference.AttachmentReference targetReference, boolean relative)
      Replace the given source reference by the given entity reference in the macro block.
      Optional<org.xwiki.rendering.block.MacroBlock> replaceReference​(org.xwiki.rendering.block.MacroBlock macroBlock, org.xwiki.model.reference.DocumentReference currentDocumentReference, org.xwiki.model.reference.DocumentReference sourceReference, org.xwiki.model.reference.DocumentReference targetReference, boolean relative)
      Replace the given source reference by the given entity reference in the macro block.
    • Method Detail

      • replaceReference

        Optional<org.xwiki.rendering.block.MacroBlock> replaceReference​(org.xwiki.rendering.block.MacroBlock macroBlock,
                                                                        org.xwiki.model.reference.DocumentReference currentDocumentReference,
                                                                        org.xwiki.model.reference.DocumentReference sourceReference,
                                                                        org.xwiki.model.reference.DocumentReference targetReference,
                                                                        boolean relative)
                                                                 throws MacroRefactoringException
        Replace the given source reference by the given entity reference in the macro block. The method returns an optional containing a modified macro block if it needs to be updated, else it returns an empty optional. Depending on the macro implementation, this method might lead to parsing the macro content for finding the reference, or might just modify the macro parameters.
        Parameters:
        macroBlock - the macro block in which to replace the reference.
        currentDocumentReference - the reference of the document in which the block is located
        sourceReference - the reference to replace.
        targetReference - the reference to use as replacement.
        relative - if true indicate that the reference should be resolved relatively to the current document
        Returns:
        an optional containing the new macro block with proper information if it needs to be updated, else an empty optional.
        Throws:
        MacroRefactoringException - in case of problem to parse or render the macro content.
      • replaceReference

        @Unstable
        Optional<org.xwiki.rendering.block.MacroBlock> replaceReference​(org.xwiki.rendering.block.MacroBlock macroBlock,
                                                                        org.xwiki.model.reference.DocumentReference currentDocumentReference,
                                                                        org.xwiki.model.reference.AttachmentReference sourceReference,
                                                                        org.xwiki.model.reference.AttachmentReference targetReference,
                                                                        boolean relative)
                                                                 throws MacroRefactoringException
        Replace the given source reference by the given entity reference in the macro block. The method returns an optional containing a modified macro block if it needs to be updated, else it returns an empty optional. Depending on the macro implementation, this method might lead to parsing the macro content for finding the reference, or might just modify the macro parameters.
        Parameters:
        macroBlock - the macro block in which to replace the reference.
        currentDocumentReference - the reference of the document in which the block is located
        sourceReference - the reference to replace.
        targetReference - the reference to use as replacement
        relative - if true indicate that the reference should be resolved relatively to the current document
        Returns:
        an optional containing the new macro block with proper information if it needs to be updated, else an empty optional.
        Throws:
        MacroRefactoringException - in case of problem to parse or render the macro content.
        Since:
        14.2RC1
      • extractReferences

        default Set<org.xwiki.rendering.listener.reference.ResourceReference> extractReferences​(org.xwiki.rendering.block.MacroBlock macroBlock)
                                                                                         throws MacroRefactoringException
        Extract references used in the macro so that they can be used for example for creating backlinks.
        Parameters:
        macroBlock - the macro block in which to look for references.
        Returns:
        a set of references contained in the macro, in its content or parameters.
        Throws:
        MacroRefactoringException - in case of problem to parse the macro content.
        Since:
        13.7RC1