/** Factory constructor. */ public EntityReferenceImpl(CoreDocumentImpl ownerDoc, String name) { super(ownerDoc); this.name = name; isReadOnly(true); needsSyncChildren(true); }
/** * NON-DOM: sets the node and its children value. * <P> * Note: make sure that entity reference and its kids could be set readonly. */ public void setReadOnly(boolean readOnly, boolean deep) { if (needsSyncData()) { synchronizeData(); } if (deep) { if (needsSyncChildren()) { synchronizeChildren(); } // Recursively set kids for (ChildNode mykid = firstChild; mykid != null; mykid = mykid.nextSibling) { mykid.setReadOnly(readOnly,true); } } isReadOnly(readOnly); } // setReadOnly(boolean,boolean)
/** * EntityReference's children are a reflection of those defined in the * named Entity. This method creates them if they haven't been created yet. * This doesn't support editing the Entity though, since this only called * once for all. */ protected void synchronizeChildren() { // no need to synchronize again needsSyncChildren(false); DocumentType doctype; NamedNodeMap entities; EntityImpl entDef; if (null != (doctype = getOwnerDocument().getDoctype()) && null != (entities = doctype.getEntities())) { entDef = (EntityImpl)entities.getNamedItem(getNodeName()); // No Entity by this name, stop here. if (entDef == null) return; // If entity's definition exists, clone its kids isReadOnly(false); for (Node defkid = entDef.getFirstChild(); defkid != null; defkid = defkid.getNextSibling()) { Node newkid = defkid.cloneNode(true); insertBefore(newkid, null); } setReadOnly(true, true); } }