1 9 10 package org.ozoneDB.xml.dom4j.o3impl; 11 12 import org.dom4j.Element; 13 import org.dom4j.Entity; 14 import org.dom4j.Visitor; 15 16 import java.io.IOException ; 17 import java.io.Writer ; 18 19 25 public abstract class AbstractEntity extends AbstractNode implements Entity { 26 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 return (parent != null && parent != context) 38 ? parent.getPath(context) + "/text()" 39 : "text()"; 40 } 41 42 public String getUniquePath(Element context) { 43 Element parent = getParent(); 45 return (parent != null && parent != context) 46 ? parent.getUniquePath(context) + "/text()" 47 : "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 74 75 119 | Popular Tags |