| 1 | package jrw.sp; |
| 2 | |
| 3 | import java.util.*; |
| 4 | |
| 5 | public class Element extends Node { |
| 6 | public final Name name; |
| 7 | public final List<Node> children = new ArrayList<>(); |
| 8 | public final Map<Name, String> attribs = new HashMap<>(); |
| 9 | |
| 10 | public Element(Name name) { |
| 11 | this.name = name; |
| 12 | } |
| 13 | |
| 14 | public Element add(Node ch) { |
| 15 | children.add(ch); |
| 16 | return(this); |
| 17 | } |
| 18 | |
| 19 | public Element set(Name attrib, String val) { |
| 20 | attribs.put(attrib, val); |
| 21 | return(this); |
| 22 | } |
| 23 | |
| 24 | public String toString() { |
| 25 | return(String.format("#<element %s %d attr %d ch>", name, attribs.size(), children.size())); |
| 26 | } |
| 27 | } |