1 7 8 package org.dom4j.tree; 9 10 import java.io.IOException ; 11 import java.io.Writer ; 12 13 import org.dom4j.Comment; 14 import org.dom4j.Element; 15 import org.dom4j.Visitor; 16 17 26 public abstract class AbstractComment extends AbstractCharacterData implements 27 Comment { 28 public AbstractComment() { 29 } 30 31 public short getNodeType() { 32 return COMMENT_NODE; 33 } 34 35 public String getPath(Element context) { 36 Element parent = getParent(); 37 38 return ((parent != null) && (parent != context)) ? (parent 39 .getPath(context) + "/comment()") : "comment()"; 40 } 41 42 public String getUniquePath(Element context) { 43 Element parent = getParent(); 44 45 return ((parent != null) && (parent != context)) ? (parent 46 .getUniquePath(context) + "/comment()") : "comment()"; 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 104 | Popular Tags |