當前位置: 首頁>>代碼示例>>Java>>正文


Java IIOMetadataNode.setAttributeNode方法代碼示例

本文整理匯總了Java中javax.imageio.metadata.IIOMetadataNode.setAttributeNode方法的典型用法代碼示例。如果您正苦於以下問題:Java IIOMetadataNode.setAttributeNode方法的具體用法?Java IIOMetadataNode.setAttributeNode怎麽用?Java IIOMetadataNode.setAttributeNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.metadata.IIOMetadataNode的用法示例。


在下文中一共展示了IIOMetadataNode.setAttributeNode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test1

import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
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");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:SetAttributeNode.java

示例2: test2

import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
public static void test2() {
    String name = "attr";
    String oldValue = "old value";
    String newValue = "new value";
    Attr retAttr;

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, oldValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, newValue);

    retAttr = parent.setAttributeNode(attrNode1);
    retAttr = parent.setAttributeNode(attrNode2);

    String actName = retAttr.getNodeName();
    String actValue = retAttr.getValue();

    if (!actName.equals(name) || !actValue.equals(oldValue)) {
        throw new RuntimeException("Test 2 failed: Invalid attribute " +
                                   "returned: " +
                                   "(name: " + actName +
                                   ", value: " + actValue + ")");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:SetAttributeNode.java

示例3: test4

import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:SetAttributeNode.java

示例4: test3

import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:SetAttributeNode.java


注:本文中的javax.imageio.metadata.IIOMetadataNode.setAttributeNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。