jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java
author yan
Fri, 15 Aug 2014 13:02:46 +0400
changeset 26350 3fb50df97199
parent 23306 679ac7841e8d
permissions -rw-r--r--
8054878: javadoc issues in javax.imageio Summary: Fix javadoc missing @exception issues in javax.imageio Reviewed-by: prr Contributed-by: prhinduja@gmail.com
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Equivalent to <code>getNamedItem(localName)</code>.
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Equivalent to <code>setNamedItem(arg)</code>.
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Equivalent to <code>removeNamedItem(localName)</code>.
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) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        if (index < 0 || index > nodes.size()) {
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * the <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * href="../../../../api/org/w3c/dom/Element.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * <code>org.w3c.dom.Element</code></a> interface and additionally allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 * for the storage of non-textual objects via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * <code>getUserObject</code> and <code>setUserObject</code> methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * <p> This class is not intended to be used for general XML
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * processing. In particular, <code>Element</code> nodes created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 * within the Image I/O API are not compatible with those created by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 * Sun's standard implementation of the <code>org.w3.dom</code> API.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 * In particular, the implementation is tuned for simple uses and may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * not perform well for intensive processing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * <p> Namespaces are ignored in this implementation.  The terms "tag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * name" and "node name" are always considered to be synonymous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 * <em>Note:</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * The DOM Level 3 specification added a number of new methods to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * {@code Node}, {@code Element} and {@code Attr} interfaces that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * of value to the {@code IIOMetadataNode} implementation or specification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * Calling such methods on an {@code IIOMetadataNode}, or an {@code Attr}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * instance returned from an {@code IIOMetadataNode} will result in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * {@code DOMException} being thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * @see IIOMetadata#getAsTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 * @see IIOMetadata#setFromTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 * @see IIOMetadata#mergeTree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
public class IIOMetadataNode implements Element, NodeList {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * The name of the node as a <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    private String nodeName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * The value of the node as a <code>String</code>.  The Image I/O
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * API typically does not make use of the node value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    private String nodeValue = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * The <code>Object</code> value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    private Object userObject = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * The parent node of this node, or <code>null</code> if this node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * forms the root of its own tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    private IIOMetadataNode parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * The number of child nodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    private int numChildren = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * The first (leftmost) child node of this node, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * <code>null</code> if this node is a leaf node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    private IIOMetadataNode firstChild = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * The last (rightmost) child node of this node, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * <code>null</code> if this node is a leaf node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    private IIOMetadataNode lastChild = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * The next (right) sibling node of this node, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <code>null</code> if this node is its parent's last child node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    private IIOMetadataNode nextSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * The previous (left) sibling node of this node, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * <code>null</code> if this node is its parent's first child node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    private IIOMetadataNode previousSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * A <code>List</code> of <code>IIOAttr</code> nodes representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   288
    private List<IIOAttr> attributes = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Constructs an empty <code>IIOMetadataNode</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public IIOMetadataNode() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * Constructs an <code>IIOMetadataNode</code> with a given node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @param nodeName the name of the node, as a <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public IIOMetadataNode(String nodeName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        this.nodeName = nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * Check that the node is either <code>null</code> or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * <code>IIOMetadataNode</code>.
26350
3fb50df97199 8054878: javadoc issues in javax.imageio
yan
parents: 23306
diff changeset
   308
     *
3fb50df97199 8054878: javadoc issues in javax.imageio
yan
parents: 23306
diff changeset
   309
     * @throws DOMException if {@code node} is not {@code null} and not an
3fb50df97199 8054878: javadoc issues in javax.imageio
yan
parents: 23306
diff changeset
   310
     * instance of {@code IIOMetadataNode}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private void checkNode(Node node) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (node == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        if (!(node instanceof IIOMetadataNode)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            throw new IIODOMException(DOMException.WRONG_DOCUMENT_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                                      "Node not an IIOMetadataNode!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    // Methods from Node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Returns the node name associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @return the node name, as a <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    public String getNodeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        return nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Returns the value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @return the node value, as a <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    public String getNodeValue(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        return nodeValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * Sets the <code>String</code> value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    public void setNodeValue(String nodeValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        this.nodeValue = nodeValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Returns the node type, which is always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * <code>ELEMENT_NODE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @return the <code>short</code> value <code>ELEMENT_NODE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    public short getNodeType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        return ELEMENT_NODE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * Returns the parent of this node.  A <code>null</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * indicates that the node is the root of its own tree.  To add a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * node to an existing tree, use one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * <code>insertBefore</code>, <code>replaceChild</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * <code>appendChild</code> methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @return the parent, as a <code>Node</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @see #insertBefore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @see #replaceChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @see #appendChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public Node getParentNode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Returns a <code>NodeList</code> that contains all children of this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * If there are no children, this is a <code>NodeList</code> containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * no nodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @return the children as a <code>NodeList</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public NodeList getChildNodes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * Returns the first child of this node, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * the node has no children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @return the first child, as a <code>Node</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    public Node getFirstChild() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        return firstChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Returns the last child of this node, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * the node has no children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @return the last child, as a <code>Node</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public Node getLastChild() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        return lastChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Returns the previous sibling of this node, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * if this node has no previous sibling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return the previous sibling, as a <code>Node</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    public Node getPreviousSibling() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * Returns the next sibling of this node, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * the node has no next sibling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @return the next sibling, as a <code>Node</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    public Node getNextSibling() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        return nextSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * Returns a <code>NamedNodeMap</code> containing the attributes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @return a <code>NamedNodeMap</code> containing the attributes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public NamedNodeMap getAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        return new IIONamedNodeMap(attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * Returns <code>null</code>, since <code>IIOMetadataNode</code>s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * do not belong to any <code>Document</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @return <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    public Document getOwnerDocument() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * Inserts the node <code>newChild</code> before the existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * child node <code>refChild</code>. If <code>refChild</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * <code>null</code>, insert <code>newChild</code> at the end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * the list of children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @param newChild the <code>Node</code> to insert.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @param refChild the reference <code>Node</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @return the node being inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @exception IllegalArgumentException if <code>newChild</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public Node insertBefore(Node newChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                             Node refChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        if (newChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            throw new IllegalArgumentException("newChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        checkNode(newChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        checkNode(refChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        IIOMetadataNode newChildNode = (IIOMetadataNode)newChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        IIOMetadataNode refChildNode = (IIOMetadataNode)refChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        // Siblings, can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        IIOMetadataNode previous = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        IIOMetadataNode next = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        if (refChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            previous = this.lastChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            next = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            this.lastChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            previous = refChildNode.previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            next = refChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        if (previous != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            previous.nextSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            next.previousSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        newChildNode.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        newChildNode.previousSibling = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        newChildNode.nextSibling = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        // N.B.: O.K. if refChild == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        if (this.firstChild == refChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            this.firstChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        ++numChildren;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Replaces the child node <code>oldChild</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * <code>newChild</code> in the list of children, and returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * <code>oldChild</code> node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @param newChild the <code>Node</code> to insert.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @param oldChild the <code>Node</code> to be replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @return the node replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @exception IllegalArgumentException if <code>newChild</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    public Node replaceChild(Node newChild,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                             Node oldChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (newChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            throw new IllegalArgumentException("newChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        checkNode(newChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        checkNode(oldChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        IIOMetadataNode newChildNode = (IIOMetadataNode)newChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        IIOMetadataNode oldChildNode = (IIOMetadataNode)oldChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        IIOMetadataNode previous = oldChildNode.previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        IIOMetadataNode next = oldChildNode.nextSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        if (previous != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            previous.nextSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            next.previousSibling = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        newChildNode.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        newChildNode.previousSibling = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        newChildNode.nextSibling = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        if (firstChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            firstChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (lastChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            lastChild = newChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        oldChildNode.parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        oldChildNode.previousSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        oldChildNode.nextSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        return oldChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * Removes the child node indicated by <code>oldChild</code> from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * the list of children, and returns it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @param oldChild the <code>Node</code> to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @return the node removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @exception IllegalArgumentException if <code>oldChild</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    public Node removeChild(Node oldChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        if (oldChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            throw new IllegalArgumentException("oldChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        checkNode(oldChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        IIOMetadataNode oldChildNode = (IIOMetadataNode)oldChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        IIOMetadataNode previous = oldChildNode.previousSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        IIOMetadataNode next = oldChildNode.nextSibling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        if (previous != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            previous.nextSibling = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        if (next != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            next.previousSibling = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        if (this.firstChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            this.firstChild = next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        if (this.lastChild == oldChildNode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            this.lastChild = previous;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        oldChildNode.parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        oldChildNode.previousSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        oldChildNode.nextSibling = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        --numChildren;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        return oldChildNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * Adds the node <code>newChild</code> to the end of the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * children of this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * @param newChild the <code>Node</code> to insert.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * @return the node added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * @exception IllegalArgumentException if <code>newChild</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    public Node appendChild(Node newChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        if (newChild == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            throw new IllegalArgumentException("newChild == null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        checkNode(newChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        // insertBefore will increment numChildren
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        return insertBefore(newChild, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * Returns <code>true</code> if this node has child nodes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * @return <code>true</code> if this node has children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    public boolean hasChildNodes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        return numChildren > 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * Returns a duplicate of this node.  The duplicate node has no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * parent (<code>getParentNode</code> returns <code>null</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * If a shallow clone is being performed (<code>deep</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * <code>false</code>), the new node will not have any children or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * siblings.  If a deep clone is being performed, the new node
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * will form the root of a complete cloned subtree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @param deep if <code>true</code>, recursively clone the subtree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * under the specified node; if <code>false</code>, clone only the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * node itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @return the duplicate node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    public Node cloneNode(boolean deep) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        IIOMetadataNode newNode = new IIOMetadataNode(this.nodeName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        newNode.setUserObject(getUserObject());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        // Attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        if (deep) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            for (IIOMetadataNode child = firstChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                 child != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                 child = child.nextSibling) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                newNode.appendChild(child.cloneNode(true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        return newNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * Does nothing, since <code>IIOMetadataNode</code>s do not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * contain <code>Text</code> children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    public void normalize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * Returns <code>false</code> since DOM features are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * @return <code>false</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * @param feature a <code>String</code>, which is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * @param version a <code>String</code>, which is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    public boolean isSupported(String feature, String version) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * Returns <code>null</code>, since namespaces are not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    public String getNamespaceURI() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * Returns <code>null</code>, since namespaces are not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @return <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @see #setPrefix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    public String getPrefix() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * Does nothing, since namespaces are not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * @param prefix a <code>String</code>, which is ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * @see #getPrefix
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    public void setPrefix(String prefix) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * Equivalent to <code>getNodeName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * @return the node name, as a <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    public String getLocalName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        return nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    // Methods from Element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * Equivalent to <code>getNodeName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     *
8943
48b572acbbe8 7026407: Broken </code> in javax.imageio.metadata.IIOMetadataNode.getTagName()
prr
parents: 5506
diff changeset
   731
     * @return the node name, as a <code>String</code>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    public String getTagName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        return nodeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * Retrieves an attribute value by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @param name The name of the attribute to retrieve.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * @return The <code>Attr</code> value as a string, or the empty string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * if that attribute does not have a specified or default value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    public String getAttribute(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        Attr attr = getAttributeNode(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        if (attr == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        return attr.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * Equivalent to <code>getAttribute(localName)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * @see #setAttributeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    public String getAttributeNS(String namespaceURI, String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        return getAttribute(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    public void setAttribute(String name, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        // Name must be valid unicode chars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        boolean valid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        char[] chs = name.toCharArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        for (int i=0;i<chs.length;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            if (chs[i] >= 0xfffe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                valid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        if (!valid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            throw new IIODOMException(DOMException.INVALID_CHARACTER_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                                      "Attribute name is illegal!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        removeAttribute(name, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        attributes.add(new IIOAttr(this, name, value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * Equivalent to <code>setAttribute(qualifiedName, value)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * @see #getAttributeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    public void setAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                               String qualifiedName, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        setAttribute(qualifiedName, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    public void removeAttribute(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        removeAttribute(name, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    private void removeAttribute(String name, boolean checkPresent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        int numAttributes = attributes.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        for (int i = 0; i < numAttributes; i++) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   795
            IIOAttr attr = attributes.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            if (name.equals(attr.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                attr.setOwnerElement(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                attributes.remove(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        // If we get here, the attribute doesn't exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        if (checkPresent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            throw new IIODOMException(DOMException.NOT_FOUND_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                                      "No such attribute!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * Equivalent to <code>removeAttribute(localName)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    public void removeAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                                  String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        removeAttribute(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    public Attr getAttributeNode(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        Node node = getAttributes().getNamedItem(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        return (Attr)node;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * Equivalent to <code>getAttributeNode(localName)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * @see #setAttributeNodeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
   public Attr getAttributeNodeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                                   String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        return getAttributeNode(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    public Attr setAttributeNode(Attr newAttr) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        Element owner = newAttr.getOwnerElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        if (owner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            if (owner == this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                                       "Attribute is already in use");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        IIOAttr attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        if (newAttr instanceof IIOAttr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
            attr = (IIOAttr)newAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            attr.setOwnerElement(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            attr = new IIOAttr(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                               newAttr.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                               newAttr.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        Attr oldAttr = getAttributeNode(attr.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        if (oldAttr != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            removeAttributeNode(oldAttr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        attributes.add(attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        return oldAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * Equivalent to <code>setAttributeNode(newAttr)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * @see #getAttributeNodeNS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    public Attr setAttributeNodeNS(Attr newAttr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        return setAttributeNode(newAttr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    public Attr removeAttributeNode(Attr oldAttr) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        removeAttribute(oldAttr.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        return oldAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    public NodeList getElementsByTagName(String name) {
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   879
        List<Node> l = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        getElementsByTagName(name, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        return new IIONodeList(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
23306
679ac7841e8d 8034998: Fix raw and unchecked lint warnings in javax.imageio
henryjen
parents: 22657
diff changeset
   884
    private void getElementsByTagName(String name, List<Node> l) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        if (nodeName.equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            l.add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        Node child = getFirstChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        while (child != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            ((IIOMetadataNode)child).getElementsByTagName(name, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            child = child.getNextSibling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * Equivalent to <code>getElementsByTagName(localName)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    public NodeList getElementsByTagNameNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                                           String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        return getElementsByTagName(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    public boolean hasAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        return attributes.size() > 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    public boolean hasAttribute(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        return getAttributeNode(name) != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * Equivalent to <code>hasAttribute(localName)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    public boolean hasAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                                  String localName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        return hasAttribute(localName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    // Methods from NodeList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    public int getLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        return numChildren;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    public Node item(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        if (index < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        Node child = getFirstChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        while (child != null && index-- > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            child = child.getNextSibling();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        return child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * Returns the <code>Object</code> value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * @return the user <code>Object</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * @see #setUserObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    public Object getUserObject() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        return userObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * Sets the value associated with this node.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * @param userObject the user <code>Object</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * @see #getUserObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    public void setUserObject(Object userObject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        this.userObject = userObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    // Start of dummy methods for DOM L3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
    public void setIdAttribute(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                               boolean isId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                               throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    public void setIdAttributeNS(String namespaceURI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                                 String localName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                                 boolean isId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                                 throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    public void setIdAttributeNode(Attr idAttr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                                   boolean isId)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                                   throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    public TypeInfo getSchemaTypeInfo() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    public Object setUserData(String key,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                              Object data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                              UserDataHandler handler) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
    public Object getUserData(String key) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    public Object getFeature(String feature, String version)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                              throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    public boolean isSameNode(Node node) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    public boolean isEqualNode(Node node) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
    public String lookupNamespaceURI(String prefix) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    public boolean isDefaultNamespace(String namespaceURI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                                               throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    public String lookupPrefix(String namespaceURI) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    public String getTextContent() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
    public void setTextContent(String textContent) throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    public short compareDocumentPosition(Node other)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                                         throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * This DOM Level 3 method is not supported for {@code IIOMetadataNode}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     * and will throw a {@code DOMException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @throws DOMException - always.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    public String getBaseURI() throws DOMException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                               "Method not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
    //End of dummy methods for DOM L3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
}