-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTagNode.java
More file actions
50 lines (45 loc) · 961 Bytes
/
TagNode.java
File metadata and controls
50 lines (45 loc) · 961 Bytes
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
package structures;
/**
* This class encapsulates a tag node with fields for tag/text, first child and sibling.
*
* @author Sesh Venugopal
*
*/
public class TagNode {
/**
* Tag or text. If tag, only the tag name is stored,
* but NOT the '<' or '>'. For example, if the tag
* is "<em>", then only "em" is stored.
*/
String tag;
/**
* First child of this node
*/
TagNode firstChild;
/**
* Sibling of this node
*/
TagNode sibling;
/**
* Initializes this tag node with tag/txt, first child, and sibling
*
* @param tag Tag or text
* @param firstChild First child
* @param sibling Sibling
*/
public TagNode(String tag, TagNode firstChild, TagNode sibling) {
this.tag = tag;
this.firstChild = firstChild;
this.sibling = sibling;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
if (firstChild != null) {
return "<" + tag + ">";
} else {
return tag;
}
}
}