blob: a1ad90c5deedea88d43ff671f7345b8dad4dba6d (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package model.html;
import model.util.Node;
import org.javatuples.Pair;
import java.util.ArrayList;
import java.util.Optional;
public class ElementNode implements Node {
private String tag;
private ArrayList<Pair<String,String>> attributes;
private ArrayList<Node> children;
/**
* EFFECTS: Constructs a new ElementNode from the arguments provided.
* MODIFIES: this
*/
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.
* EFFECTS: Constructs a new ElementNode from the arguments provided.
* MODIFIES: this
*/
public ElementNode(String tag, ArrayList<Pair<String, String>> attributes) {
this(tag, attributes, new ArrayList<Node>());
}
/**
* EFFECTS: Adds a child to the children ArrayList.
* MODIFIES: this
*/
public void addChild(Node child) {
this.children.add(child);
}
public String getTag() {
return this.tag;
}
public ArrayList<Node> getChildren() {
return this.children;
}
// We implement this method for easy debugging.
public String getData() {
return getTag();
}
}
|