1 package com.thoughtworks.xstream.io.xml; 2 3 import com.thoughtworks.xstream.io.HierarchicalStreamWriter; 4 import nu.xom.Element; 5 import nu.xom.Attribute; 6 7 public class XomWriter implements HierarchicalStreamWriter { 8 9 private Element node; 10 11 public XomWriter(Element parentElement) { 12 this.node = parentElement; 13 } 14 15 public void startNode(String name) { 16 Element newNode = new Element(name); 17 node.appendChild(newNode); 18 node = newNode; 19 } 20 21 public void addAttribute(String name, String value) { 22 node.addAttribute(new Attribute(name, value)); 23 } 24 25 public void setValue(String text) { 26 node.appendChild(text); 27 } 28 29 public void endNode() { 30 node = (Element) node.getParent(); 31 } 32 33 public void flush() { 34 } 36 37 public void close() { 38 } 40 41 public HierarchicalStreamWriter underlyingWriter() { 42 return this; 43 } 44 } 45 | Popular Tags |