1 18 package org.apache.batik.dom; 19 20 import org.apache.batik.dom.util.DOMUtilities; 21 import org.w3c.dom.DOMException ; 22 import org.w3c.dom.EntityReference ; 23 import org.w3c.dom.Node ; 24 25 31 public abstract class AbstractEntityReference 32 extends AbstractParentChildNode 33 implements EntityReference { 34 37 protected String nodeName; 38 39 42 protected AbstractEntityReference() { 43 } 44 45 53 protected AbstractEntityReference(String name, AbstractDocument owner) 54 throws DOMException { 55 ownerDocument = owner; 56 57 if (!DOMUtilities.isValidName(name)) { 58 throw createDOMException(DOMException.INVALID_CHARACTER_ERR, 59 "xml.name", 60 new Object [] { name }); 61 } 62 nodeName = name; 63 } 64 65 69 public short getNodeType() { 70 return ENTITY_REFERENCE_NODE; 71 } 72 73 76 public void setNodeName(String v) { 77 nodeName = v; 78 } 79 80 84 public String getNodeName() { 85 return nodeName; 86 } 87 88 91 protected Node export(Node n, AbstractDocument d) { 92 super.export(n, d); 93 AbstractEntityReference ae = (AbstractEntityReference)n; 94 ae.nodeName = nodeName; 95 return n; 96 } 97 98 101 protected Node deepExport(Node n, AbstractDocument d) { 102 super.deepExport(n, d); 103 AbstractEntityReference ae = (AbstractEntityReference)n; 104 ae.nodeName = nodeName; 105 return n; 106 } 107 108 112 protected Node copyInto(Node n) { 113 super.copyInto(n); 114 AbstractEntityReference ae = (AbstractEntityReference)n; 115 ae.nodeName = nodeName; 116 return n; 117 } 118 119 123 protected Node deepCopyInto(Node n) { 124 super.deepCopyInto(n); 125 AbstractEntityReference ae = (AbstractEntityReference)n; 126 ae.nodeName = nodeName; 127 return n; 128 } 129 130 133 protected void checkChildType(Node n, boolean replace) { 134 switch (n.getNodeType()) { 135 case ELEMENT_NODE: 136 case PROCESSING_INSTRUCTION_NODE: 137 case COMMENT_NODE: 138 case TEXT_NODE: 139 case CDATA_SECTION_NODE: 140 case ENTITY_REFERENCE_NODE: 141 case DOCUMENT_FRAGMENT_NODE: 142 break; 143 default: 144 throw createDOMException 145 (DOMException.HIERARCHY_REQUEST_ERR, 146 "child.type", 147 new Object [] { new Integer (getNodeType()), 148 getNodeName(), 149 new Integer (n.getNodeType()), 150 n.getNodeName() }); 151 } 152 } 153 } 154 | Popular Tags |