-
Notifications
You must be signed in to change notification settings - Fork 300
Expand file tree
/
Copy pathD2Node.java
More file actions
59 lines (49 loc) · 1.46 KB
/
D2Node.java
File metadata and controls
59 lines (49 loc) · 1.46 KB
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
55
56
57
58
59
package com.vladsch.flexmark.ext.d2;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.sequence.BasedSequence;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class D2Node extends Node {
private BasedSequence key;
//private List<BasedSequence> values;
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] { key };
}
public D2Node(BasedSequence key, List<BasedSequence> values) {
this.key = key;
//this.values = values;
for (BasedSequence value : values) {
appendChild(new D2Value(value));
}
}
public String getKey() {
return key.toString();
}
public BasedSequence getKeySequence() {
return key;
}
public void setKey(BasedSequence key) {
this.key = key;
}
public List<String> getValues() {
ArrayList<String> list = new ArrayList<>();
Node child = getFirstChild();
while (child != null) {
list.add(child.getChars().toString());
child = child.getNext();
}
return list;
}
public List<BasedSequence> getValuesSequences() {
ArrayList<BasedSequence> list = new ArrayList<>();
Node child = getFirstChild();
while (child != null) {
list.add(child.getChars());
child = child.getNext();
}
return list;
}
}