Added basic HTML generation and response handling.
[jrw.git] / src / jrw / sp / Element.java
diff --git a/src/jrw/sp/Element.java b/src/jrw/sp/Element.java
new file mode 100644 (file)
index 0000000..e33e6a3
--- /dev/null
@@ -0,0 +1,27 @@
+package jrw.sp;
+
+import java.util.*;
+
+public class Element extends Node {
+    public final Name name;
+    public final List<Node> children = new ArrayList<>();
+    public final Map<Name, String> attribs = new HashMap<>();
+
+    public Element(Name name) {
+       this.name = name;
+    }
+
+    public Element add(Node ch) {
+       children.add(ch);
+       return(this);
+    }
+
+    public Element set(Name attrib, String val) {
+       attribs.put(attrib, val);
+       return(this);
+    }
+
+    public String toString() {
+       return(String.format("#<element %s %d attr %d ch>", name, attribs.size(), children.size()));
+    }
+}