public void removeAttribute(String name) throws DOMException { IIOMetadataAttr attr = (IIOMetadataAttr) attrs.getNamedItem(name); if (attr != null) { attr.setOwnerElement(null); attrs.list.remove(attr); } }
public Attr setAttributeNode(Attr newAttr) throws DOMException { // Check if this attribute is already in use. Element owner = newAttr.getOwnerElement(); if (owner != null) { if (owner == this) { // Replacing an attribute node by itself has no effect return null; } else { throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, Messages.getString("imageio.8E")); } } String name = newAttr.getName(); Attr oldAttr = getAttributeNode(name); if (oldAttr != null) { removeAttributeNode(oldAttr); } IIOMetadataAttr iioAttr; if (newAttr instanceof IIOMetadataAttr) { iioAttr = (IIOMetadataAttr) newAttr; iioAttr.setOwnerElement(this); } else { iioAttr = new IIOMetadataAttr(name, newAttr.getValue(), this); } attrs.list.add(iioAttr); return oldAttr; }
public Attr removeAttributeNode(Attr oldAttr) throws DOMException { if (!attrs.list.remove(oldAttr)) { // Not found throw new DOMException(DOMException.NOT_FOUND_ERR, Messages.getString("imageio.8F")); } ((IIOMetadataAttr) oldAttr).setOwnerElement(null); return oldAttr; }