aboutsummaryrefslogtreecommitdiff
path: root/src/main/model/html/ElementNode.java
blob: 358d97c31a2874e027704b9b2b54e8fe2590802b (plain) (blame)
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
37
38
39
40
package model.html;

import org.javatuples.Pair;

import java.util.ArrayList;

/**
 * This ElementNode class represents an HTML tag and nested tags.
 */
public class ElementNode implements Node {
    public final String tag;
    public final ArrayList<Pair<String,String>> attributes;

    public final ArrayList<Node> children;

    public ElementNode(String tag, ArrayList<Pair<String, String>> attributes, ArrayList<Node> children) {
        this.tag = tag;
        this.attributes = attributes;
        this.children = children;
    }

    /**
     * Overloads the constructor for ease of use. We often don't provide children, at first.
     */
    public ElementNode(String tag, ArrayList<Pair<String, String>> attributes) {
        this(tag, attributes, new ArrayList<>());
    }

    /**
     * Overloads the constructor for ease of use. Should probably only be used for tests.
     */
    public ElementNode(String tag) {
        this(tag, new ArrayList<>(), new ArrayList<>());
    }

    // We implement this method for easy debugging.
    public String data() {
        return this.tag + " " + this.attributes.toString();
    }
}