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