1 57 58 package org.enhydra.apache.xerces.dom; 59 60 import org.w3c.dom.DocumentType ; 61 import org.w3c.dom.EntityReference ; 62 import org.w3c.dom.NamedNodeMap ; 63 import org.w3c.dom.Node ; 64 import org.w3c.dom.NodeList ; 65 66 121 public class EntityReferenceImpl 122 extends ParentNode 123 implements EntityReference { 124 125 129 130 static final long serialVersionUID = -7381452955687102062L; 131 132 136 137 protected String name; 138 139 140 142 143 145 149 150 public EntityReferenceImpl(CoreDocumentImpl ownerDoc, String name) { 151 super(ownerDoc); 152 this.name = name; 153 } 156 157 161 165 public short getNodeType() { 166 return Node.ENTITY_REFERENCE_NODE; 167 } 168 169 172 public String getNodeName() { 173 if (needsSyncData()) { 174 synchronizeData(); 175 } 176 return name; 177 } 178 179 181 186 public NodeList getChildNodes() { 187 synchronize(); 188 return super.getChildNodes(); 189 } 190 191 196 public Node getFirstChild() { 197 synchronize(); 198 return super.getFirstChild(); 199 } 200 201 206 public Node getLastChild() { 207 synchronize(); 208 return super.getLastChild(); 209 } 210 211 218 public int getLength() { 219 synchronize(); 220 return super.getLength(); 221 } 222 223 227 public boolean hasChildNodes() { 228 synchronize(); 229 return super.hasChildNodes(); 230 } 231 232 233 public Node item(int index) { 234 synchronize(); 235 return super.item(index); 236 } 237 238 239 244 protected void synchronize() { 245 if (firstChild != null) { 246 return; 247 } 248 DocumentType doctype; 249 NamedNodeMap entities; 250 EntityImpl entDef; 251 if (null != (doctype = getOwnerDocument().getDoctype()) && 252 null != (entities = doctype.getEntities())) { 253 254 entDef = (EntityImpl)entities.getNamedItem(getNodeName()); 255 256 if (entDef == null) 258 return; 259 260 isReadOnly(false); 262 for (Node defkid = entDef.getFirstChild(); 263 defkid != null; 264 defkid = defkid.getNextSibling()) { 265 Node newkid = defkid.cloneNode(true); 266 insertBefore(newkid,null); 267 } 268 setReadOnly(true, true); 269 } 270 } 271 272 273 282 283 309 359 360 } | Popular Tags |