src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadataNode.java
author serb
Mon, 09 Jul 2018 16:36:05 +0300
changeset 51010 29be48779807
parent 47216 71c04702a3d5
permissions -rw-r--r--
8201611: Broken links in java.desktop javadoc Reviewed-by: prr, kaddepalli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22657
654c573cb341 8033616: Fix serial lint warnings in javax.imageio.*
darcy
parents: 14342
diff changeset
     2
 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.imageio.metadata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import org.w3c.dom.Attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import org.w3c.dom.Document;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import org.w3c.dom.Element;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import org.w3c.dom.DOMException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import org.w3c.dom.NamedNodeMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import org.w3c.dom.Node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import org.w3c.dom.NodeList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import org.w3c.dom.TypeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import org.w3c.dom.UserDataHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
class IIODOMException extends DOMException {
22657
654c573cb341 8033616: Fix serial lint warnings in javax.imageio.*
darcy
parents: 14342
diff changeset
    44
    private static final long serialVersionUID = -4369510142067447468L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public IIODOMException(short code, String message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        super(code, message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
class IIONamedNodeMap implements NamedNodeMap {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
    53
    List<? extends Node> nodes;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
    55
    public IIONamedNodeMap(List<? extends Node> nodes) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        this.nodes = nodes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public int getLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        return nodes.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public Node getNamedItem(String name) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
    64
        Iterator<? extends Node> iter = nodes.iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        while (iter.hasNext()) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
    66
            Node node = iter.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            if (name.equals(node.getNodeName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                return node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public Node item(int index) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
    76
        Node node = nodes.get(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public Node removeNamedItem(java.lang.String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                               "This NamedNodeMap is read-only!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public Node setNamedItem(Node arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                               "This NamedNodeMap is read-only!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
    91
     * Equivalent to {@code getNamedItem(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public Node getNamedItemNS(String namespaceURI, String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        return getNamedItem(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
    98
     * Equivalent to {@code setNamedItem(arg)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public Node setNamedItemNS(Node arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return setNamedItem(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   105
     * Equivalent to {@code removeNamedItem(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public Node removeNamedItemNS(String namespaceURI, String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        return removeNamedItem(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
class IIONodeList implements NodeList {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   114
    List<? extends Node> nodes;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   116
    public IIONodeList(List<? extends Node> nodes) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        this.nodes = nodes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public int getLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return nodes.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public Node item(int index) {
41794
e30c6574b042 8167281: IIOMetadataNode bugs in getElementsByTagName and NodeList.item methods
jdv
parents: 35667
diff changeset
   125
        if (index < 0 || index >= nodes.size()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   128
        return nodes.get(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
class IIOAttr extends IIOMetadataNode implements Attr {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    Element owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    String value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public IIOAttr(Element owner, String name, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        this.owner = owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        this.value = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public String getNodeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public short getNodeType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return ATTRIBUTE_NODE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public boolean getSpecified() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public String getValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public String getNodeValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public void setValue(String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        this.value = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public void setNodeValue(String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        this.value = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public Element getOwnerElement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        return owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public void setOwnerElement(Element owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        this.owner = owner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /** This method is new in the DOM L3 for Attr interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Could throw DOMException here, but its probably OK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * to always return false. One reason for this, is we have no good
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * way to document this exception, since this class, IIOAttr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * is not a public class. The rest of the methods that throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * DOMException are publically documented as such on IIOMetadataNode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @return false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public boolean isId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * A class representing a node in a meta-data tree, which implements
51010
29be48779807 8201611: Broken links in java.desktop javadoc
serb
parents: 47216
diff changeset
   201
 * the {@link Element org.w3c.dom.Element} interface and additionally allows
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * for the storage of non-textual objects via the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   203
 * {@code getUserObject} and {@code setUserObject} methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * <p> This class is not intended to be used for general XML
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   206
 * processing. In particular, {@code Element} nodes created
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * within the Image I/O API are not compatible with those created by
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   208
 * Sun's standard implementation of the {@code org.w3.dom} API.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 * In particular, the implementation is tuned for simple uses and may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 * not perform well for intensive processing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * <p> Namespaces are ignored in this implementation.  The terms "tag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 * name" and "node name" are always considered to be synonymous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * <em>Note:</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * The DOM Level 3 specification added a number of new methods to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 * {@code Node}, {@code Element} and {@code Attr} interfaces that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * of value to the {@code IIOMetadataNode} implementation or specification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * Calling such methods on an {@code IIOMetadataNode}, or an {@code Attr}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * instance returned from an {@code IIOMetadataNode} will result in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * {@code DOMException} being thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * @see IIOMetadata#getAsTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 * @see IIOMetadata#setFromTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * @see IIOMetadata#mergeTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
public class IIOMetadataNode implements Element, NodeList {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   232
     * The name of the node as a {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private String nodeName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   237
     * The value of the node as a {@code String}.  The Image I/O
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * API typically does not make use of the node value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    private String nodeValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   243
     * The {@code Object} value associated with this node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    private Object userObject = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   248
     * The parent node of this node, or {@code null} if this node
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * forms the root of its own tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private IIOMetadataNode parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * The number of child nodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    private int numChildren = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * The first (leftmost) child node of this node, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   260
     * {@code null} if this node is a leaf node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    private IIOMetadataNode firstChild = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * The last (rightmost) child node of this node, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   266
     * {@code null} if this node is a leaf node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    private IIOMetadataNode lastChild = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * The next (right) sibling node of this node, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   272
     * {@code null} if this node is its parent's last child node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    private IIOMetadataNode nextSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * The previous (left) sibling node of this node, or
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   278
     * {@code null} if this node is its parent's first child node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    private IIOMetadataNode previousSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   283
     * A {@code List} of {@code IIOAttr} nodes representing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   286
    private List<IIOAttr> attributes = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   289
     * Constructs an empty {@code IIOMetadataNode}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    public IIOMetadataNode() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   294
     * Constructs an {@code IIOMetadataNode} with a given node
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   297
     * @param nodeName the name of the node, as a {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    public IIOMetadataNode(String nodeName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        this.nodeName = nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   304
     * Check that the node is either {@code null} or an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   305
     * {@code IIOMetadataNode}.
26350
3fb50df97199 8054878: javadoc issues in javax.imageio
yan
parents: 23306
diff changeset
   306
     *
3fb50df97199 8054878: javadoc issues in javax.imageio
yan
parents: 23306
diff changeset
   307
     * @throws DOMException if {@code node} is not {@code null} and not an
3fb50df97199 8054878: javadoc issues in javax.imageio
yan
parents: 23306
diff changeset
   308
     * instance of {@code IIOMetadataNode}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    private void checkNode(Node node) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        if (node == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        if (!(node instanceof IIOMetadataNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            throw new IIODOMException(DOMException.WRONG_DOCUMENT_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                                      "Node not an IIOMetadataNode!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    // Methods from Node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * Returns the node name associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   325
     * @return the node name, as a {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public String getNodeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * Returns the value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   334
     * @return the node value, as a {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public String getNodeValue(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        return nodeValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   341
     * Sets the {@code String} value associated with this node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    public void setNodeValue(String nodeValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        this.nodeValue = nodeValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * Returns the node type, which is always
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   349
     * {@code ELEMENT_NODE}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   351
     * @return the {@code short} value {@code ELEMENT_NODE}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    public short getNodeType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        return ELEMENT_NODE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   358
     * Returns the parent of this node.  A {@code null} value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * indicates that the node is the root of its own tree.  To add a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * node to an existing tree, use one of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   361
     * {@code insertBefore}, {@code replaceChild}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   362
     * {@code appendChild} methods.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   364
     * @return the parent, as a {@code Node}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @see #insertBefore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @see #replaceChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @see #appendChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    public Node getParentNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        return parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   375
     * Returns a {@code NodeList} that contains all children of this node.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   376
     * If there are no children, this is a {@code NodeList} containing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * no nodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   379
     * @return the children as a {@code NodeList}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    public NodeList getChildNodes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   386
     * Returns the first child of this node, or {@code null} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * the node has no children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   389
     * @return the first child, as a {@code Node}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   390
     * {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public Node getFirstChild() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        return firstChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   397
     * Returns the last child of this node, or {@code null} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * the node has no children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   400
     * @return the last child, as a {@code Node}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   401
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    public Node getLastChild() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return lastChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   408
     * Returns the previous sibling of this node, or {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * if this node has no previous sibling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   411
     * @return the previous sibling, as a {@code Node}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   412
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public Node getPreviousSibling() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        return previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   419
     * Returns the next sibling of this node, or {@code null} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * the node has no next sibling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   422
     * @return the next sibling, as a {@code Node}, or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   423
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    public Node getNextSibling() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        return nextSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   430
     * Returns a {@code NamedNodeMap} containing the attributes of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   433
     * @return a {@code NamedNodeMap} containing the attributes of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    public NamedNodeMap getAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        return new IIONamedNodeMap(attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   441
     * Returns {@code null}, since {@code IIOMetadataNode}s
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   442
     * do not belong to any {@code Document}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   444
     * @return {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public Document getOwnerDocument() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   451
     * Inserts the node {@code newChild} before the existing
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   452
     * child node {@code refChild}. If {@code refChild} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   453
     * {@code null}, insert {@code newChild} at the end of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * the list of children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   456
     * @param newChild the {@code Node} to insert.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   457
     * @param refChild the reference {@code Node}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @return the node being inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   461
     * @exception IllegalArgumentException if {@code newChild} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   462
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    public Node insertBefore(Node newChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                             Node refChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        if (newChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            throw new IllegalArgumentException("newChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        checkNode(newChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        checkNode(refChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        IIOMetadataNode newChildNode = (IIOMetadataNode)newChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        IIOMetadataNode refChildNode = (IIOMetadataNode)refChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        // Siblings, can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        IIOMetadataNode previous = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        IIOMetadataNode next = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        if (refChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            previous = this.lastChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            next = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            this.lastChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            previous = refChildNode.previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            next = refChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        if (previous != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            previous.nextSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            next.previousSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        newChildNode.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        newChildNode.previousSibling = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        newChildNode.nextSibling = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        // N.B.: O.K. if refChild == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        if (this.firstChild == refChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            this.firstChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        ++numChildren;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        return newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   510
     * Replaces the child node {@code oldChild} with
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   511
     * {@code newChild} in the list of children, and returns the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   512
     * {@code oldChild} node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   514
     * @param newChild the {@code Node} to insert.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   515
     * @param oldChild the {@code Node} to be replaced.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @return the node replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   519
     * @exception IllegalArgumentException if {@code newChild} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   520
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    public Node replaceChild(Node newChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                             Node oldChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        if (newChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            throw new IllegalArgumentException("newChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        checkNode(newChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        checkNode(oldChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        IIOMetadataNode newChildNode = (IIOMetadataNode)newChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        IIOMetadataNode oldChildNode = (IIOMetadataNode)oldChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        IIOMetadataNode previous = oldChildNode.previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        IIOMetadataNode next = oldChildNode.nextSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        if (previous != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            previous.nextSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            next.previousSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        newChildNode.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        newChildNode.previousSibling = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        newChildNode.nextSibling = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (firstChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            firstChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        if (lastChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            lastChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        oldChildNode.parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        oldChildNode.previousSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        oldChildNode.nextSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        return oldChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   563
     * Removes the child node indicated by {@code oldChild} from
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * the list of children, and returns it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   566
     * @param oldChild the {@code Node} to be removed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @return the node removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   570
     * @exception IllegalArgumentException if {@code oldChild} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   571
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    public Node removeChild(Node oldChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        if (oldChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            throw new IllegalArgumentException("oldChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        checkNode(oldChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        IIOMetadataNode oldChildNode = (IIOMetadataNode)oldChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        IIOMetadataNode previous = oldChildNode.previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        IIOMetadataNode next = oldChildNode.nextSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        if (previous != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            previous.nextSibling = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            next.previousSibling = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        if (this.firstChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            this.firstChild = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        if (this.lastChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            this.lastChild = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        oldChildNode.parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        oldChildNode.previousSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        oldChildNode.nextSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        --numChildren;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        return oldChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   607
     * Adds the node {@code newChild} to the end of the list of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * children of this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   610
     * @param newChild the {@code Node} to insert.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * @return the node added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   614
     * @exception IllegalArgumentException if {@code newChild} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   615
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    public Node appendChild(Node newChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        if (newChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            throw new IllegalArgumentException("newChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        checkNode(newChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        // insertBefore will increment numChildren
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        return insertBefore(newChild, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   628
     * Returns {@code true} if this node has child nodes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   630
     * @return {@code true} if this node has children.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    public boolean hasChildNodes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        return numChildren > 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * Returns a duplicate of this node.  The duplicate node has no
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   638
     * parent ({@code getParentNode} returns {@code null}).
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   639
     * If a shallow clone is being performed ({@code deep} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   640
     * {@code false}), the new node will not have any children or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * siblings.  If a deep clone is being performed, the new node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * will form the root of a complete cloned subtree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   644
     * @param deep if {@code true}, recursively clone the subtree
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   645
     * under the specified node; if {@code false}, clone only the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * node itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * @return the duplicate node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    public Node cloneNode(boolean deep) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        IIOMetadataNode newNode = new IIOMetadataNode(this.nodeName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        newNode.setUserObject(getUserObject());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        // Attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        if (deep) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            for (IIOMetadataNode child = firstChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                 child != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                 child = child.nextSibling) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                newNode.appendChild(child.cloneNode(true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        return newNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   667
     * Does nothing, since {@code IIOMetadataNode}s do not
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   668
     * contain {@code Text} children.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    public void normalize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   674
     * Returns {@code false} since DOM features are not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   677
     * @return {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   679
     * @param feature a {@code String}, which is ignored.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   680
     * @param version a {@code String}, which is ignored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    public boolean isSupported(String feature, String version) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   687
     * Returns {@code null}, since namespaces are not supported.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    public String getNamespaceURI() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   694
     * Returns {@code null}, since namespaces are not supported.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   696
     * @return {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @see #setPrefix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    public String getPrefix() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * Does nothing, since namespaces are not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   707
     * @param prefix a {@code String}, which is ignored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * @see #getPrefix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    public void setPrefix(String prefix) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   715
     * Equivalent to {@code getNodeName}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   717
     * @return the node name, as a {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    public String getLocalName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        return nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    // Methods from Element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   727
     * Equivalent to {@code getNodeName}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   729
     * @return the node name, as a {@code String}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    public String getTagName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        return nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * Retrieves an attribute value by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * @param name The name of the attribute to retrieve.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   738
     * @return The {@code Attr} value as a string, or the empty string
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * if that attribute does not have a specified or default value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    public String getAttribute(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        Attr attr = getAttributeNode(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        if (attr == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        return attr.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   750
     * Equivalent to {@code getAttribute(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * @see #setAttributeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    public String getAttributeNS(String namespaceURI, String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        return getAttribute(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    public void setAttribute(String name, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        // Name must be valid unicode chars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        boolean valid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        char[] chs = name.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        for (int i=0;i<chs.length;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            if (chs[i] >= 0xfffe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                valid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        if (!valid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            throw new IIODOMException(DOMException.INVALID_CHARACTER_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                                      "Attribute name is illegal!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        removeAttribute(name, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        attributes.add(new IIOAttr(this, name, value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   777
     * Equivalent to {@code setAttribute(qualifiedName, value)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @see #getAttributeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    public void setAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                               String qualifiedName, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        setAttribute(qualifiedName, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    public void removeAttribute(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        removeAttribute(name, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    private void removeAttribute(String name, boolean checkPresent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        int numAttributes = attributes.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        for (int i = 0; i < numAttributes; i++) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   793
            IIOAttr attr = attributes.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            if (name.equals(attr.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                attr.setOwnerElement(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                attributes.remove(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        // If we get here, the attribute doesn't exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        if (checkPresent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            throw new IIODOMException(DOMException.NOT_FOUND_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                                      "No such attribute!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   809
     * Equivalent to {@code removeAttribute(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    public void removeAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                                  String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        removeAttribute(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    public Attr getAttributeNode(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        Node node = getAttributes().getNamedItem(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        return (Attr)node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   822
     * Equivalent to {@code getAttributeNode(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * @see #setAttributeNodeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
   public Attr getAttributeNodeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                                   String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        return getAttributeNode(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    public Attr setAttributeNode(Attr newAttr) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        Element owner = newAttr.getOwnerElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        if (owner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            if (owner == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                                       "Attribute is already in use");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        IIOAttr attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        if (newAttr instanceof IIOAttr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            attr = (IIOAttr)newAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            attr.setOwnerElement(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            attr = new IIOAttr(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                               newAttr.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                               newAttr.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        Attr oldAttr = getAttributeNode(attr.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        if (oldAttr != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            removeAttributeNode(oldAttr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        attributes.add(attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        return oldAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   863
     * Equivalent to {@code setAttributeNode(newAttr)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * @see #getAttributeNodeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    public Attr setAttributeNodeNS(Attr newAttr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        return setAttributeNode(newAttr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    public Attr removeAttributeNode(Attr oldAttr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        removeAttribute(oldAttr.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        return oldAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    public NodeList getElementsByTagName(String name) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   877
        List<Node> l = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        getElementsByTagName(name, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        return new IIONodeList(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   882
    private void getElementsByTagName(String name, List<Node> l) {
41794
e30c6574b042 8167281: IIOMetadataNode bugs in getElementsByTagName and NodeList.item methods
jdv
parents: 35667
diff changeset
   883
        if (nodeName.equals(name) || "*".equals(name)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            l.add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        Node child = getFirstChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        while (child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            ((IIOMetadataNode)child).getElementsByTagName(name, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            child = child.getNextSibling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   895
     * Equivalent to {@code getElementsByTagName(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    public NodeList getElementsByTagNameNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                                           String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        return getElementsByTagName(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    public boolean hasAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        return attributes.size() > 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    public boolean hasAttribute(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        return getAttributeNode(name) != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   911
     * Equivalent to {@code hasAttribute(localName)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    public boolean hasAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                                  String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        return hasAttribute(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    // Methods from NodeList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    public int getLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        return numChildren;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    public Node item(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        if (index < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        Node child = getFirstChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        while (child != null && index-- > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            child = child.getNextSibling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        return child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   937
     * Returns the {@code Object} value associated with this node.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   939
     * @return the user {@code Object}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * @see #setUserObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    public Object getUserObject() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        return userObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * Sets the value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   950
     * @param userObject the user {@code Object}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * @see #getUserObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    public void setUserObject(Object userObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        this.userObject = userObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    // Start of dummy methods for DOM L3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   963
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    public void setIdAttribute(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                               boolean isId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                               throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   975
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    public void setIdAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                                 String localName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                                 boolean isId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                                 throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
   988
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    public void setIdAttributeNode(Attr idAttr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                                   boolean isId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                                   throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1000
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
    public TypeInfo getSchemaTypeInfo() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1010
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    public Object setUserData(String key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                              Object data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                              UserDataHandler handler) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1022
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
    public Object getUserData(String key) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1032
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    public Object getFeature(String feature, String version)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                              throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1043
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    public boolean isSameNode(Node node) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1053
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    public boolean isEqualNode(Node node) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1063
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
    public String lookupNamespaceURI(String prefix) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1073
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    public boolean isDefaultNamespace(String namespaceURI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                                               throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1084
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
    public String lookupPrefix(String namespaceURI) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1094
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
    public String getTextContent() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1104
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
    public void setTextContent(String textContent) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1114
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    public short compareDocumentPosition(Node other)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                                         throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * and will throw a {@code DOMException}.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 26353
diff changeset
  1125
     * @throws DOMException always.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    public String getBaseURI() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    //End of dummy methods for DOM L3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
}