1 57 58 package org.xquark.xpath.datamodel.xerces.dom; 59 60 import org.w3c.dom.*; 61 62 117 public class EntityReferenceImpl 118 extends ParentNode 119 implements EntityReference { 120 121 125 126 static final long serialVersionUID = -7381452955687102062L; 127 128 132 133 protected String name; 134 135 136 138 139 141 145 146 public EntityReferenceImpl(DocumentImpl ownerDoc, String name) { 147 super(ownerDoc); 148 this.name = name; 149 isReadOnly(true); 150 } 151 152 156 160 public short getNodeType() { 161 return Node.ENTITY_REFERENCE_NODE; 162 } 163 164 167 public String getNodeName() { 168 if (needsSyncData()) { 169 synchronizeData(); 170 } 171 return name; 172 } 173 174 176 181 public NodeList getChildNodes() { 182 synchronize(); 183 return super.getChildNodes(); 184 } 185 186 191 public Node getFirstChild() { 192 synchronize(); 193 return super.getFirstChild(); 194 } 195 196 201 public Node getLastChild() { 202 synchronize(); 203 return super.getLastChild(); 204 } 205 206 213 public int getLength() { 214 synchronize(); 215 return super.getLength(); 216 } 217 218 222 public boolean hasChildNodes() { 223 synchronize(); 224 return super.hasChildNodes(); 225 } 226 227 228 public Node item(int index) { 229 synchronize(); 230 return super.item(index); 231 } 232 233 234 239 protected void synchronize() { 240 if (firstChild != null) { 241 return; 242 } 243 DocumentType doctype; 244 NamedNodeMap entities; 245 EntityImpl entDef; 246 if (null != (doctype = getOwnerDocument().getDoctype()) && 247 null != (entities = doctype.getEntities())) { 248 249 entDef = (EntityImpl)entities.getNamedItem(getNodeName()); 250 251 if (entDef == null) 253 return; 254 255 isReadOnly(false); 257 for (Node defkid = entDef.getFirstChild(); 258 defkid != null; 259 defkid = defkid.getNextSibling()) { 260 Node newkid = defkid.cloneNode(true); 261 insertBefore(newkid,null); 262 } 263 setReadOnly(true, true); 264 } 265 } 266 267 268 277 278 304 354 355 } | Popular Tags |