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

com.vladsch.flexmark.html2md.converter.HtmlConverterState Maven / Gradle / Ivy

There is a newer version: 4.15.102
Show newest version
package com.vladsch.flexmark.html2md.converter;

import com.vladsch.flexmark.util.html.Attributes;
import org.jsoup.nodes.Node;

import java.util.LinkedList;
import java.util.List;

public class HtmlConverterState {
    final Node myParent;
    final List myElements;
    int myIndex;
    final Attributes myAttributes;
    private LinkedList myPrePopActions;

    HtmlConverterState(Node parent) {
        myParent = parent;
        myElements = parent.childNodes();
        myIndex = 0;
        myAttributes = new Attributes();
        myPrePopActions = null;
    }

    public Node getParent() {
        return myParent;
    }

    public void addPrePopAction(Runnable action) {
        if (myPrePopActions == null) {
            myPrePopActions = new LinkedList<>();
        }
        myPrePopActions.add(action);
    }

    public void runPrePopActions() {
        if (myPrePopActions != null) {
            int iMax = myPrePopActions.size();
            for (int i = iMax; i-- > 0; ) {
                myPrePopActions.get(i).run();
            }
        }
    }

    @Override
    public String toString() {
        return "State{" +
                "myParent=" + myParent +
                ", myElements=" + myElements +
                ", myIndex=" + myIndex +
                ", myAttributes=" + myAttributes +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy