1 9 10 package org.ozoneDB.xml.dom4j.o3impl; 11 12 import org.dom4j.Comment; 13 import org.dom4j.Element; 14 import org.dom4j.Visitor; 15 16 import java.io.IOException ; 17 import java.io.Writer ; 18 19 25 public abstract class AbstractComment extends AbstractCharacterData implements Comment { 26 27 public AbstractComment() { 28 } 29 30 public short getNodeType() { 31 return COMMENT_NODE; 32 } 33 34 public String getPath(Element context) { 35 Element parent = getParent(); 36 return (parent != null && parent != context) 37 ? parent.getPath(context) + "/comment()" 38 : "comment()"; 39 } 40 41 public String getUniquePath(Element context) { 42 Element parent = getParent(); 43 return (parent != null && parent != context) 44 ? parent.getUniquePath(context) + "/comment()" 45 : "comment()"; 46 } 47 48 49 public String toString() { 50 return super.toString() + " [Comment: \"" + getText() + "\"]"; 51 } 52 53 public String asXML() { 54 return "<!--" + getText() + "-->"; 55 } 56 57 public void write(Writer writer) throws IOException { 58 writer.write("<!--"); 59 writer.write(getText()); 60 writer.write("-->"); 61 } 62 63 public void accept(Visitor visitor) { 64 visitor.visit(this); 65 } 66 } 67 68 69 113 | Popular Tags |