Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4496652

IIOMetadataNode.setAttributeNode does not work as described

XMLWordPrintable

    • beta3
    • generic
    • generic



      Name: ipR10067 Date: 08/27/2001



      Specification of the method javax.imageio.metadata.IIOMetadataNode.setAttributeNode says:

      "public Attr setAttributeNode(Attr newAttr) throws DOMException

          Adds a new attribute node. If an attribute with that name (
          nodeName) is already present in the element, it is replaced by
          the new one.
      ...
         
          Parameters:
             newAttr - The Attr node to add to the attribute list.
      "

      The implementation (JDK 1.4.0beta2, build b77) of the method
      adds a new attribute node which can not be retrieved by getAttributeNode.

      To reproduce the bug run the following test:

      ------------ test.java ------------------------
      import javax.imageio.metadata.IIOMetadataNode;
      import org.w3c.dom.Attr;
      import org.w3c.dom.Element;


      import org.w3c.dom.NamedNodeMap;


      public class test {

          public static void main(String argv[]) {

      IIOMetadataNode elem = new IIOMetadataNode("elem");
      MyTestAttrNode attrNode = new MyTestAttrNode("attr", "value");

      elem.setAttributeNode(attrNode);


              Attr actValue = elem.getAttributeNode("attr");

              if(actValue == null) {
      System.out.println("Failed - bad attrNode");
              }


              NamedNodeMap res = elem.getAttributes();

              System.out.println((res.item(0)).getNodeName());
              System.out.println((res.item(0)).getNodeValue());

          }
      }

      class MyTestAttrNode extends IIOMetadataNode implements Attr {
          public Element owner;
          private String name;
          private String value;


          public MyTestAttrNode(String name, String value) {
              this.name = name;
              this.value = value;
          }
          public String getName() {
              return name;
          }
          public Element getOwnerElement() {
              return owner;
          }
          public boolean getSpecified() {
              return false;
          }
          public String getValue() {
              return value;
          }
          public void setValue(String value) {
              this.value = value;
          }
      }
      ------------ Logs -----------------------------
      $ java -version
      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)

      $ javac -d . test.java
      $ java test
      Failed - bad attrNode
      null
      null

      ======================================================================

      This bug affects new JCK test:
      api/javax_imageio/metadata/IIOMetadataNode/index.html#setAttributeNode
      api/javax_imageio/metadata/IIOMetadataNode/index.html#removeAttributeNode
      ======================================================================

      ======================================================================

            dricesunw Daniel Rice (Inactive)
            ipsunw Ip Ip (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: