aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/styles/HtmlPath.java
blob: 99bdf5582f552d2ce1999fa33c09bc4e543e4021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.zwobble.mammoth.styles;

import com.google.common.collect.Lists;
import org.zwobble.mammoth.html.HtmlNode;

import java.util.List;

public class HtmlPath {
    public static HtmlPathElement element(String tagName) {
        return new HtmlPathElement(tagName, false);
    }

    public static HtmlPathElement collapsibleElement(String tagName) {
        return new HtmlPathElement(tagName, true);
    }

    private final List<HtmlPathElement> elements;

    public HtmlPath(List<HtmlPathElement> elements) {
        this.elements = elements;
    }

    public List<HtmlNode> wrap(List<HtmlNode> nodes) {
        for (HtmlPathElement element : Lists.reverse(elements)) {
            nodes = element.wrap(nodes);
        }
        return nodes;
    }
}