Interface RewriteRule

    • Method Detail

      • getTitle

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

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

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

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

        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.

        root - The root of the subtree to be rewritten
        finalPaths - list of nodes paths which should not be updated after this method completes
        the root node of the rewritten tree, or null if it was removed
        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.
        the rule's ranking