blob: b03d0b667ce0d670d00221269e8f69c291c89d0a (
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
30
31
32
33
34
35
36
|
package org.zwobble.mammoth.styles;
import com.google.common.collect.Lists;
import org.zwobble.mammoth.html.HtmlNode;
import java.util.List;
import java.util.Map;
import static org.zwobble.mammoth.util.MammothMaps.map;
public class HtmlPath {
public static HtmlPathElement element(String tagName) {
return element(tagName, map());
}
public static HtmlPathElement element(String tagName, Map<String, String> attributes) {
return new HtmlPathElement(tagName, attributes, false);
}
public static HtmlPathElement collapsibleElement(String tagName) {
return new HtmlPathElement(tagName, map(), 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;
}
}
|