diff src/fschmidt/html/HtmlNode.java @ 68:00520880ad02

add fschmidt source
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 05 Oct 2025 17:24:15 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fschmidt/html/HtmlNode.java	Sun Oct 05 17:24:15 2025 -0600
@@ -0,0 +1,32 @@
+package fschmidt.html;
+
+
+public final class HtmlNode extends HtmlTag {
+	public final Html children;
+
+	public HtmlNode(HtmlTag tag,Html children) {
+		super(tag);
+		if( tag.isEmpty() )
+			throw new RuntimeException();
+		this.children = children;
+	}
+
+	@Override public String toString() {
+		return super.toString() + children + "</" + getName() + ">";
+	}
+
+	@Override public boolean equals(Object obj) {
+		if( !super.equals(obj) )
+			return false;
+		if( !(obj instanceof HtmlNode) )
+			return false;
+		HtmlNode node = (HtmlNode)obj;
+		return children.equals(node.children);
+	}
+
+	void flattenTo(Html html) {
+		html.add( new HtmlTag(this) );
+		children.flattenTo(html);
+		html.add( new HtmlTag( "/" + getName() ) );
+	}
+}