Java Code Examples for org.w3c.dom.DOMException#INUSE_ATTRIBUTE_ERR

The following examples show how to use org.w3c.dom.DOMException#INUSE_ATTRIBUTE_ERR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetAttributeNode.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 2
Source File: SetAttributeNode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 3
Source File: SetAttributeNode.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 4
Source File: SetAttributeNode.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 5
Source File: ElementImpl.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    AttrImpl newAttrImpl = (AttrImpl) newAttr;

    if (newAttrImpl.document != this.document) {
        throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, null);
    }

    if (newAttrImpl.getOwnerElement() != null) {
        throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, null);
    }

    AttrImpl oldAttrImpl = null;

    int i = indexOfAttribute(newAttr.getName());
    if (i != -1) {
        oldAttrImpl = attributes.get(i);
        attributes.remove(i);
    }

    attributes.add(newAttrImpl);
    newAttrImpl.ownerElement = this;

    return oldAttrImpl;
}
 
Example 6
Source File: SetAttributeNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 7
Source File: ElementImpl.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
    AttrImpl newAttrImpl = (AttrImpl) newAttr;

    if (newAttrImpl.document != this.document) {
        throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, null);
    }

    if (newAttrImpl.getOwnerElement() != null) {
        throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, null);
    }

    AttrImpl oldAttrImpl = null;

    int i = indexOfAttributeNS(newAttr.getNamespaceURI(), newAttr.getLocalName());
    if (i != -1) {
        oldAttrImpl = attributes.get(i);
        attributes.remove(i);
    }

    attributes.add(newAttrImpl);
    newAttrImpl.ownerElement = this;

    return oldAttrImpl;
}
 
Example 8
Source File: SetAttributeNode.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 9
Source File: SetAttributeNode.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 10
Source File: IIOMetadataNode.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 11
Source File: IIOMetadataNode.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 12
Source File: IIOMetadataNode.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 13
Source File: IIOMetadataNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 14
Source File: IIOMetadataNode.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 15
Source File: IIOMetadataNode.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 16
Source File: IIOMetadataNode.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 17
Source File: IIOMetadataNode.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 18
Source File: IIOMetadataNode.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 19
Source File: IIOMetadataNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}
 
Example 20
Source File: IIOMetadataNode.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Attr setAttributeNode(Attr newAttr) throws DOMException {
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
        if (owner == this) {
            return null;
        } else {
            throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
                                   "Attribute is already in use");
        }
    }

    IIOAttr attr;
    if (newAttr instanceof IIOAttr) {
        attr = (IIOAttr)newAttr;
        attr.setOwnerElement(this);
    } else {
        attr = new IIOAttr(this,
                           newAttr.getName(),
                           newAttr.getValue());
    }

    Attr oldAttr = getAttributeNode(attr.getName());
    if (oldAttr != null) {
        removeAttributeNode(oldAttr);
    }

    attributes.add(attr);

    return oldAttr;
}