Added some minor HTML utilities.
[jsvc.git] / src / dolda / jsvc / next / DocBuffer.java
index 2690309..d885a0b 100644 (file)
@@ -76,6 +76,18 @@ public class DocBuffer {
        return(doc.createTextNode(text));
     }
     
+    public Node asnode(Object o) {
+       if(o instanceof Node) {
+           Node n = (Node)o;
+           if(n.getOwnerDocument() != doc)
+               return(doc.importNode(n, true));
+           return(n);
+       }
+       if(o instanceof String)
+           return(text((String)o));
+       throw(new RuntimeException("Cannot convert a " + o.getClass().getName() + " to a DOM node"));
+    }
+    
     public void finalise() {
        Node n = doc;
        while(true) {