1 7 8 package org.dom4j.tree; 9 10 import java.io.IOException ; 11 import java.io.Writer ; 12 13 import org.dom4j.Element; 14 import org.dom4j.Entity; 15 import org.dom4j.Visitor; 16 17 26 public abstract class AbstractEntity extends AbstractNode implements Entity { 27 public AbstractEntity() { 28 } 29 30 public short getNodeType() { 31 return ENTITY_REFERENCE_NODE; 32 } 33 34 public String getPath(Element context) { 35 Element parent = getParent(); 37 38 return ((parent != null) && (parent != context)) ? (parent 39 .getPath(context) + "/text()") : "text()"; 40 } 41 42 public String getUniquePath(Element context) { 43 Element parent = getParent(); 45 46 return ((parent != null) && (parent != context)) ? (parent 47 .getUniquePath(context) + "/text()") : "text()"; 48 } 49 50 public String toString() { 51 return super.toString() + " [Entity: &" + getName() + ";]"; 52 } 53 54 public String getStringValue() { 55 return "&" + getName() + ";"; 56 } 57 58 public String asXML() { 59 return "&" + getName() + ";"; 60 } 61 62 public void write(Writer writer) throws IOException { 63 writer.write("&"); 64 writer.write(getName()); 65 writer.write(";"); 66 } 67 68 public void accept(Visitor visitor) { 69 visitor.visit(this); 70 } 71 } 72 73 109 | Popular Tags |