/** * Runs the test case. * * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList genderList; Node genderNode; Node entText; EntityReference entReference; Node appendedChild; doc = (Document) load("staff", true); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = doc.createEntityReference("ent3"); assertNotNull("createdEntRefNotNull", entReference); appendedChild = genderNode.appendChild(entReference); entText = entReference.getFirstChild(); assertNotNull("entTextNotNull", entText); { boolean success = false; try { ((CharacterData) /*Node */ entText).deleteData(1, 3); } catch (DOMException ex) { success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); } assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); } }
/** Expand an entity reference. */ public void expandEntityRef(EntityReference n, Output dst) { String name = n.getNodeName(); NodeList value = Index.getIndexValue(this, name); if (value == null) { dst.putNode(n); } else { Copy.copyNodes(value, dst); } }
/** * Sets the name of the file that hosts the referenced entity. * * @param fileName the name of the file that hosts the referenced entity */ public void setFileName(String fileName) { entityReference.setComponent(FILE_NAME, fileName); }
/** @return the name of the file that hosts the referenced entity */ public String getFileName() { return entityReference.getComponent(FILE_NAME); }
/** * Creates a new typed reference to the specified attachment. * * @param fileName the file name * @param wikiPageReference a reference to the wiki page that holds the attachment */ public AttachmentReference(String fileName, WikiPageReference wikiPageReference) { this(wikiPageReference.getEntityReference().clone()); entityReference.setType(EntityType.ATTACHMENT); setFileName(fileName); }
/** Default constructor. */ public AttachmentReference() { this(new EntityReference()); entityReference.setType(EntityType.ATTACHMENT); }
/** * {@inheritDoc} * * @see Object#clone() */ public AttachmentReference clone() { return new AttachmentReference(entityReference.clone()); }