All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vladsch.flexmark.ast.util.HeadingCollectingVisitor Maven / Gradle / Ivy

There is a newer version: 4.15.102
Show newest version
package com.vladsch.flexmark.ast.util;

import com.vladsch.flexmark.ast.Heading;
import com.vladsch.flexmark.util.ast.BlockNodeVisitor;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.ast.NodeVisitor;
import com.vladsch.flexmark.util.ast.VisitHandler;

import java.util.ArrayList;

public class HeadingCollectingVisitor {
    final private ArrayList headings = new ArrayList<>();
    final private NodeVisitor myVisitor;

    public HeadingCollectingVisitor() {
        myVisitor = new BlockNodeVisitor(
                new VisitHandler<>(Heading.class, headings::add)
        );
    }

    public void collect(Node node) {
        myVisitor.visit(node);
    }

    public ArrayList collectAndGetHeadings(Node node) {
        myVisitor.visit(node);
        return headings;
    }

    public ArrayList getHeadings() {
        return headings;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy