Interface RewriteRule

    • Method Detail

      • getTitle

        default String getTitle()
        The title for this rule.
        Returns:
        the title
      • getId

        String getId()
        Returns the unique identifier for this Rule.
        Returns:
        the id
      • matches

        boolean matches​(@NotNull
                        @NotNull Node root)
                 throws RepositoryException
        Returns true if this rule matches the given subtree.
        Parameters:
        root - The root of the subtree to be checked for a match
        Returns:
        true if this rule applies, false otherwise
        Throws:
        RepositoryException - if reading the repository fails
      • applyTo

        @Nullable
        @Nullable Node applyTo​(@NotNull
                               @NotNull Node root,
                               @NotNull
                               @NotNull Set<String> finalPaths)
                        throws RewriteException,
                               RepositoryException

        Applies this rule to the subtree rooted at the specified root node. The implementation of this method may either modify the properties and nodes contained in that tree, or replace it by adding a new child to the parent of root. In the latter case, the implementation is responsible for removing the original subtree (without saving).

        Repository modifications are made but not saved.

        Rewrite rules must not rewrite trees in a circular fashion, as this might lead to infinite loops.

        Optionally, the implementation can indicate which nodes of the resulting tree are final and therefore safe for the algorithm to skip in subsequent traversals of the tree. Add the paths of final nodes to the specified set.

        Parameters:
        root - The root of the subtree to be rewritten
        finalPaths - list of nodes paths which should not be updated after this method completes
        Returns:
        the root node of the rewritten tree, or null if it was removed
        Throws:
        RewriteException - if the rewrite operation failed or cannot be completed
        RepositoryException - if the node updates cannot be saved
      • getRanking

        default int getRanking()
        Ranking of this Rule relative to others that may also match a given node.
        Returns:
        the rule's ranking