/** * <b>DOM</b>: Implements {@link org.w3c.dom.Node#setNodeValue(String)}. */ public void setNodeValue(String nodeValue) throws DOMException { if (isReadonly()) { throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", new Object[] {(int) getNodeType(), getNodeName() }); } String s = getNodeValue(); // Remove all the children Node n; while ((n = getFirstChild()) != null) { removeChild(n); } String val = (nodeValue == null) ? "" : nodeValue; // Create and append a new child. n = getOwnerDocument().createTextNode(val); appendChild(n); if (ownerElement != null) { ownerElement.fireDOMAttrModifiedEvent(nodeName, this, s, val, MutationEvent.MODIFICATION); } }
/** * Called when a child node is going to be removed. */ protected void nodeToBeRemoved(Node n) { setSpecified(true); }
/** * Copy the fields of the current node into the given node. * @param n a node of the type of this. */ protected Node copyInto(Node n) { super.copyInto(n); AbstractAttrNS aa = (AbstractAttrNS)n; aa.namespaceURI = namespaceURI; return n; }
/** * Checks the validity of a node to be inserted. */ protected void checkChildType(Node n, boolean replace) { switch (n.getNodeType()) { case TEXT_NODE: case ENTITY_REFERENCE_NODE: case DOCUMENT_FRAGMENT_NODE: break; default: throw createDOMException (DOMException.HIERARCHY_REQUEST_ERR, "child.type", new Object[] {(int) getNodeType(), getNodeName(), (int) n.getNodeType(), n.getNodeName() }); } }
new Object[]{localName} ); n.setOwnerElement( null ); String prefix = n.getPrefix(); fireDOMAttrModifiedEvent( n.getNodeName(), n, n.getNodeValue(), "", MutationEvent.REMOVAL );
new Object[]{localName} ); n.setOwnerElement( null ); fireDOMAttrModifiedEvent( n.getNodeName(), n, n.getNodeValue(), "", MutationEvent.REMOVAL ); return n;
/** * Exports this node to the given document. * @param n The clone node. * @param d The destination document. */ protected Node export(Node n, AbstractDocument d) { super.export(n, d); AbstractElement ae = (AbstractElement)n; if (attributes != null) { NamedNodeMap map = attributes; for (int i = map.getLength() - 1; i >= 0; i--) { AbstractAttr aa = (AbstractAttr)map.item(i); if (aa.getSpecified()) { Attr attr = (Attr)aa.deepExport(aa.cloneNode(false), d); if (aa instanceof AbstractAttrNS) { ae.setAttributeNodeNS(attr); } else { ae.setAttributeNode(attr); } } } } return n; }
/** * <b>DOM</b>: Implements * {@link org.w3c.dom.Element#setIdAttributeNode(Attr,boolean)}. */ public void setIdAttributeNode( Attr attr, boolean isId ) throws DOMException { AbstractAttr a = (AbstractAttr)attr; if (a.isReadonly()) { throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", new Object[] { a.getNodeName() }); } updateIdEntry(a, isId); a.isIdAttr = isId; }
} else { AbstractAttr a = (AbstractAttr) n; Element e = a.getOwnerElement(); a2.setNodeValue(a.getNodeValue());
/** * Adds a node to the map. */ public Node setNamedItem( String ns, String name, Node arg ) throws DOMException { if ( ns != null && ns.length() == 0 ) { ns = null; } ( (AbstractAttr)arg ).setOwnerElement( AbstractElement.this ); AbstractAttr result = (AbstractAttr)put( ns, name, arg ); if ( result != null ) { result.setOwnerElement( null ); fireDOMAttrModifiedEvent( name, result, result.getNodeValue(), "", MutationEvent.REMOVAL ); } fireDOMAttrModifiedEvent( name, (Attr)arg, "", arg.getNodeValue(), MutationEvent.ADDITION ); return result; }
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Attr#getValue()}. * @return {@link #getNodeValue()}. */ public String getValue() { return getNodeValue(); }
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Attr#getName()}. * @return {@link #getNodeName()}. */ public String getName() { return getNodeName(); }
/** * Deeply copy the fields of the current node into the given node. * @param n a node of the type of this. */ protected Node deepCopyInto(Node n) { super.deepCopyInto(n); AbstractAttrNS aa = (AbstractAttrNS)n; aa.namespaceURI = namespaceURI; return n; } }
/** * Deeply exports this node to the given document. */ protected Node deepExport(Node n, AbstractDocument d) { super.deepExport(n, d); AbstractAttrNS aa = (AbstractAttrNS)n; aa.namespaceURI = namespaceURI; return n; }
/** * Creates a new Attr object. * @param name The attribute name for validation purposes. * @param owner The owner document. * @exception DOMException * INVALID_CHARACTER_ERR: if name contains invalid characters, */ protected AbstractAttr(String name, AbstractDocument owner) throws DOMException { ownerDocument = owner; if (owner.getStrictErrorChecking() && !DOMUtilities.isValidName(name)) { throw createDOMException(DOMException.INVALID_CHARACTER_ERR, "xml.name", new Object[] { name }); } }
new Object[]{localName} ); n.setOwnerElement( null ); String prefix = n.getPrefix(); fireDOMAttrModifiedEvent( n.getNodeName(), n, n.getNodeValue(), "", MutationEvent.REMOVAL );
new Object[]{localName} ); n.setOwnerElement( null ); fireDOMAttrModifiedEvent( n.getNodeName(), n, n.getNodeValue(), "", MutationEvent.REMOVAL ); return n;
/** * Deeply exports this node to the given document. * @param n The clone node. * @param d The destination document. */ protected Node deepExport(Node n, AbstractDocument d) { super.deepExport(n, d); AbstractElement ae = (AbstractElement)n; if (attributes != null) { NamedNodeMap map = attributes; for (int i = map.getLength() - 1; i >= 0; i--) { AbstractAttr aa = (AbstractAttr)map.item(i); if (aa.getSpecified()) { Attr attr = (Attr)aa.deepExport(aa.cloneNode(false), d); if (aa instanceof AbstractAttrNS) { ae.setAttributeNodeNS(attr); } else { ae.setAttributeNode(attr); } } } } return n; }
/** * <b>DOM</b>: Implements * {@link org.w3c.dom.Element#setIdAttributeNode(Attr,boolean)}. */ public void setIdAttributeNode( Attr attr, boolean isId ) throws DOMException { AbstractAttr a = (AbstractAttr)attr; if (a.isReadonly()) { throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.node", new Object[] { a.getNodeName() }); } updateIdEntry(a, isId); a.isIdAttr = isId; }
/** * Checks the validity of a node to be inserted. */ protected void checkChildType(Node n, boolean replace) { switch (n.getNodeType()) { case TEXT_NODE: case ENTITY_REFERENCE_NODE: case DOCUMENT_FRAGMENT_NODE: break; default: throw createDOMException (DOMException.HIERARCHY_REQUEST_ERR, "child.type", new Object[] {(int) getNodeType(), getNodeName(), (int) n.getNodeType(), n.getNodeName() }); } }