示例#1
0
 public void removeAttribute(String name) throws DOMException {
   IIOMetadataAttr attr = (IIOMetadataAttr) attrs.getNamedItem(name);
   if (attr != null) {
     attr.setOwnerElement(null);
     attrs.list.remove(attr);
   }
 }
示例#2
0
  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;
  }
示例#3
0
  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;
  }