src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java
author joehw
Wed, 28 Nov 2018 10:30:15 -0800
changeset 52721 732bec44c89e
parent 48409 5ab69533994b
child 58411 cece74021580
permissions -rw-r--r--
8213117: adoptNode corrupts attribute values Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     1
/*
52721
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
     2
 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     3
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
     4
/*
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
     5
 * Licensed to the Apache Software Foundation (ASF) under one or more
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
     6
 * contributor license agreements.  See the NOTICE file distributed with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
     7
 * this work for additional information regarding copyright ownership.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
     8
 * The ASF licenses this file to You under the Apache License, Version 2.0
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
     9
 * (the "License"); you may not use this file except in compliance with
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    10
 * the License.  You may obtain a copy of the License at
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    11
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    12
 *      http://www.apache.org/licenses/LICENSE-2.0
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    13
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    18
 * limitations under the License.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    19
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    20
package com.sun.org.apache.xerces.internal.dom;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    21
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    22
import com.sun.org.apache.xerces.internal.impl.Constants;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    23
import com.sun.org.apache.xerces.internal.util.URI;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    24
import com.sun.org.apache.xerces.internal.util.XML11Char;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    25
import com.sun.org.apache.xerces.internal.util.XMLChar;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
    26
import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    27
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    28
import java.io.IOException;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    29
import java.io.ObjectInputStream;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    30
import java.io.ObjectOutputStream;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    31
import java.io.ObjectStreamField;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    32
import java.lang.reflect.Constructor;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    33
import java.util.HashMap;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    34
import java.util.Hashtable;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    35
import java.util.Map;
47312
d4f959806fe9 8187593: Cleanup: removing SecuritySupport files
joehw
parents: 47216
diff changeset
    36
import jdk.xml.internal.SecuritySupport;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    37
import org.w3c.dom.Attr;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    38
import org.w3c.dom.CDATASection;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    39
import org.w3c.dom.Comment;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    40
import org.w3c.dom.DOMConfiguration;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    41
import org.w3c.dom.DOMException;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    42
import org.w3c.dom.DOMImplementation;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    43
import org.w3c.dom.Document;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    44
import org.w3c.dom.DocumentFragment;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    45
import org.w3c.dom.DocumentType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    46
import org.w3c.dom.Element;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    47
import org.w3c.dom.Entity;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    48
import org.w3c.dom.EntityReference;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    49
import org.w3c.dom.NamedNodeMap;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    50
import org.w3c.dom.Node;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    51
import org.w3c.dom.NodeList;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    52
import org.w3c.dom.Notation;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    53
import org.w3c.dom.ProcessingInstruction;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    54
import org.w3c.dom.Text;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    55
import org.w3c.dom.UserDataHandler;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    56
import org.w3c.dom.events.Event;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    57
import org.w3c.dom.events.EventListener;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    58
import org.w3c.dom.ls.DOMImplementationLS;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    59
import org.w3c.dom.ls.LSSerializer;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    60
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    61
/**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    62
 * The Document interface represents the entire HTML or XML document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    63
 * Conceptually, it is the root of the document tree, and provides the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    64
 * primary access to the document's data.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    65
 * <P>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    66
 * Since elements, text nodes, comments, processing instructions,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    67
 * etc. cannot exist outside the context of a Document, the Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    68
 * interface also contains the factory methods needed to create these
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    69
 * objects. The Node objects created have a ownerDocument attribute
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    70
 * which associates them with the Document within whose context they
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    71
 * were created.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    72
 * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    73
 * The CoreDocumentImpl class only implements the DOM Core. Additional modules
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    74
 * are supported by the more complete DocumentImpl subclass.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    75
 * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    76
 * <b>Note:</b> When any node in the document is serialized, the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    77
 * entire document is serialized along with it.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    78
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    79
 * @xerces.internal
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    80
 *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    81
 * @author Arnaud  Le Hors, IBM
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    82
 * @author Joe Kesselman, IBM
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    83
 * @author Andy Clark, IBM
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    84
 * @author Ralf Pfeiffer, IBM
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    85
 * @since  PR-DOM-Level-1-19980818.
52721
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
    86
 * @LastModified: Nov 2018
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    87
 */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    88
public class CoreDocumentImpl
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    89
        extends ParentNode implements Document {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    90
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    91
    /**
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    92
     * TODO:: 1. Change XML11Char method names similar to XMLChar. That will
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    93
     * prevent lot of dirty version checking code.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    94
     *
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    95
     * 2. IMO during cloneNode qname/isXMLName check should not be made.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
    96
     */
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    97
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    98
    // Constants
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
    99
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   100
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   101
    /** Serialization version. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   102
    static final long serialVersionUID = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   103
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   104
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   105
    // Data
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   106
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   107
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   108
    // document information
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   109
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   110
    /** Document type. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   111
    protected DocumentTypeImpl docType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   112
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   113
    /** Document element. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   114
    protected ElementImpl docElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   115
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   116
    /** NodeListCache free list */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   117
    transient NodeListCache fFreeNLCache;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   118
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   119
    /**Experimental DOM Level 3 feature: Document encoding */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   120
    protected String encoding;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   121
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   122
    /**Experimental DOM Level 3 feature: Document actualEncoding */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   123
    protected String actualEncoding;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   124
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   125
    /**Experimental DOM Level 3 feature: Document version */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   126
    protected String version;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   127
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   128
    /**Experimental DOM Level 3 feature: Document standalone */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   129
    protected boolean standalone;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   130
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   131
    /**Experimental DOM Level 3 feature: documentURI */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   132
    protected String fDocumentURI;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   133
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   134
    //Revisit :: change to a better data structure.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   135
    /** Table for user data attached to this document nodes. */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   136
    private Map<Node, Map<String, UserDataRecord>> nodeUserData;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   137
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   138
    /** Identifiers. */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   139
    protected Map<String, Node> identifiers;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   140
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   141
    // DOM Level 3: normalizeDocument
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   142
    transient DOMNormalizer domNormalizer = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   143
    transient DOMConfigurationImpl fConfiguration = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   144
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   145
    // support of XPath API
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   146
    transient Object fXPathEvaluator = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   147
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   148
    /** Table for quick check of child insertion. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   149
    private final static int[] kidOK;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   150
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   151
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   152
     * Number of alterations made to this document since its creation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   153
     * Serves as a "dirty bit" so that live objects such as NodeList can
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   154
     * recognize when an alteration has been made and discard its cached
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   155
     * state information.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   156
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   157
     * Any method that alters the tree structure MUST cause or be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   158
     * accompanied by a call to changed(), to inform it that any outstanding
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   159
     * NodeLists may have to be updated.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   160
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   161
     * (Required because NodeList is simultaneously "live" and integer-
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   162
     * indexed -- a bad decision in the DOM's design.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   163
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   164
     * Note that changes which do not affect the tree's structure -- changing
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   165
     * the node's name, for example -- do _not_ have to call changed().
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   166
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   167
     * Alternative implementation would be to use a cryptographic
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   168
     * Digest value rather than a count. This would have the advantage that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   169
     * "harmless" changes (those producing equal() trees) would not force
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   170
     * NodeList to resynchronize. Disadvantage is that it's slightly more prone
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   171
     * to "false negatives", though that's the difference between "wildly
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   172
     * unlikely" and "absurdly unlikely". IF we start maintaining digests,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   173
     * we should consider taking advantage of them.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   174
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   175
     * Note: This used to be done a node basis, so that we knew what
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   176
     * subtree changed. But since only DeepNodeList really use this today,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   177
     * the gain appears to be really small compared to the cost of having
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   178
     * an int on every (parent) node plus having to walk up the tree all the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   179
     * way to the root to mark the branch as changed everytime a node is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   180
     * changed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   181
     * So we now have a single counter global to the document. It means that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   182
     * some objects may flush their cache more often than necessary, but this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   183
     * makes nodes smaller and only the document needs to be marked as changed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   184
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   185
    protected int changes = 0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   186
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   187
    // experimental
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   188
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   189
    /** Allow grammar access. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   190
    protected boolean allowGrammarAccess;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   191
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   192
    /** Bypass error checking. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   193
    protected boolean errorChecking = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   194
    /** Ancestor checking */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   195
    protected boolean ancestorChecking = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   196
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   197
    //Did version change at any point when the document was created ?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   198
    //this field helps us to optimize when normalizingDocument.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   199
    protected boolean xmlVersionChanged = false ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   200
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   201
    /** The following are required for compareDocumentPosition
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   202
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   203
    // Document number.   Documents are ordered across the implementation using
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   204
    // positive integer values.  Documents are assigned numbers on demand.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   205
    private int documentNumber=0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   206
    // Node counter and table.  Used to assign numbers to nodes for this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   207
    // document.  Node number values are negative integers.  Nodes are
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   208
    // assigned numbers on demand.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   209
    private int nodeCounter = 0;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   210
    private Map<Node, Integer> nodeTable;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   211
    private boolean xml11Version = false; //by default 1.0
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   212
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   213
    // Static initialization
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   214
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   215
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   216
    static {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   217
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   218
        kidOK = new int[13];
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   219
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   220
        kidOK[DOCUMENT_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   221
        1 << ELEMENT_NODE | 1 << PROCESSING_INSTRUCTION_NODE |
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   222
        1 << COMMENT_NODE | 1 << DOCUMENT_TYPE_NODE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   223
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   224
        kidOK[DOCUMENT_FRAGMENT_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   225
        kidOK[ENTITY_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   226
        kidOK[ENTITY_REFERENCE_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   227
        kidOK[ELEMENT_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   228
        1 << ELEMENT_NODE | 1 << PROCESSING_INSTRUCTION_NODE |
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   229
        1 << COMMENT_NODE | 1 << TEXT_NODE |
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   230
        1 << CDATA_SECTION_NODE | 1 << ENTITY_REFERENCE_NODE ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   231
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   232
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   233
        kidOK[ATTRIBUTE_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   234
        1 << TEXT_NODE | 1 << ENTITY_REFERENCE_NODE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   235
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   236
        kidOK[DOCUMENT_TYPE_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   237
        kidOK[PROCESSING_INSTRUCTION_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   238
        kidOK[COMMENT_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   239
        kidOK[TEXT_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   240
        kidOK[CDATA_SECTION_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   241
        kidOK[NOTATION_NODE] =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   242
        0;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   243
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   244
    } // static
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   245
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   246
    /**
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   247
     * @serialField docType DocumentTypeImpl document type
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   248
     * @serialField docElement ElementImpl document element
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   249
     * @serialField fFreeNLCache NodeListCache NodeListCache free list
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   250
     * @serialField encoding String Document encoding
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   251
     * @serialField actualEncoding String Document actualEncoding
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   252
     * @serialField version String Document version
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   253
     * @serialField standalone boolean Document standalone
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   254
     * @serialField fDocumentURI String Document URI
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   255
     * @serialField userData Hashtable user data attached to the nodes. Note that
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   256
     * it was original called "userData". It has been changed to nodeUserData to
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   257
     * avoid confusion with those that are actually values of the map.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   258
     * @serialField identifiers Hashtable identifiers
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   259
     * @serialField changes int flag indicates whether the node has changed
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   260
     * @serialField allowGrammarAccess boolean Allow grammar access
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   261
     * @serialField errorChecking boolean Bypass error checking
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   262
     * @serialField ancestorChecking boolean Ancestor checking
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   263
     * @serialField xmlVersionChanged boolean Indicate whether the version has changed
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   264
     * @serialField documentNumber int Document number
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   265
     * @serialField nodeCounter int Node counter
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   266
     * @serialField nodeTable Hashtable Node table
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   267
     * @serialField xml11Version boolean XML version
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   268
     */
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   269
    private static final ObjectStreamField[] serialPersistentFields =
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   270
        new ObjectStreamField[] {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   271
            new ObjectStreamField("docType", DocumentTypeImpl.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   272
            new ObjectStreamField("docElement", ElementImpl.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   273
            new ObjectStreamField("fFreeNLCache", NodeListCache.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   274
            new ObjectStreamField("encoding", String.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   275
            new ObjectStreamField("actualEncoding", String.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   276
            new ObjectStreamField("version", String.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   277
            new ObjectStreamField("standalone", boolean.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   278
            new ObjectStreamField("fDocumentURI", String.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   279
            new ObjectStreamField("userData", Hashtable.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   280
            new ObjectStreamField("identifiers", Hashtable.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   281
            new ObjectStreamField("changes", int.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   282
            new ObjectStreamField("allowGrammarAccess", boolean.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   283
            new ObjectStreamField("errorChecking", boolean.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   284
            new ObjectStreamField("ancestorChecking", boolean.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   285
            new ObjectStreamField("xmlVersionChanged", boolean.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   286
            new ObjectStreamField("documentNumber", int.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   287
            new ObjectStreamField("nodeCounter", int.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   288
            new ObjectStreamField("nodeTable", Hashtable.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   289
            new ObjectStreamField("xml11Version", boolean.class),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   290
        };
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   291
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   292
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   293
    // Constructors
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   294
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   295
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   296
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   297
     * NON-DOM: Actually creating a Document is outside the DOM's spec,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   298
     * since it has to operate in terms of a particular implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   299
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   300
    public CoreDocumentImpl() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   301
        this(false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   302
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   303
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   304
    /** Constructor. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   305
    public CoreDocumentImpl(boolean grammarAccess) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   306
        super(null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   307
        ownerDocument = this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   308
        allowGrammarAccess = grammarAccess;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   309
        String systemProp = SecuritySupport.getSystemProperty(Constants.SUN_DOM_PROPERTY_PREFIX+Constants.SUN_DOM_ANCESTOR_CHECCK);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   310
        if (systemProp != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   311
            if (systemProp.equalsIgnoreCase("false")) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   312
                ancestorChecking = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   313
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   314
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   315
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   316
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   317
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   318
     * For DOM2 support.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   319
     * The createDocument factory method is in DOMImplementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   320
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   321
    public CoreDocumentImpl(DocumentType doctype) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   322
        this(doctype, false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   323
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   324
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   325
    /** For DOM2 support. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   326
    public CoreDocumentImpl(DocumentType doctype, boolean grammarAccess) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   327
        this(grammarAccess);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   328
        if (doctype != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   329
            DocumentTypeImpl doctypeImpl;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   330
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   331
                doctypeImpl = (DocumentTypeImpl) doctype;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   332
            } catch (ClassCastException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   333
                String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   334
                throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   335
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   336
            doctypeImpl.ownerDocument = this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   337
            appendChild(doctype);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   338
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   339
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   340
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   341
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   342
    // Node methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   343
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   344
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   345
    // even though ownerDocument refers to this in this implementation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   346
    // the DOM Level 2 spec says it must be null, so make it appear so
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   347
    final public Document getOwnerDocument() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   348
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   349
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   350
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   351
    /** Returns the node type. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   352
    public short getNodeType() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   353
        return Node.DOCUMENT_NODE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   354
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   355
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   356
    /** Returns the node name. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   357
    public String getNodeName() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   358
        return "#document";
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   359
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   360
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   361
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   362
     * Deep-clone a document, including fixing ownerDoc for the cloned
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   363
     * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   364
     * protection. I've chosen to implement it by calling importNode
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   365
     * which is DOM Level 2.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   366
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   367
     * @return org.w3c.dom.Node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   368
     * @param deep boolean, iff true replicate children
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   369
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   370
    public Node cloneNode(boolean deep) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   371
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   372
        CoreDocumentImpl newdoc = new CoreDocumentImpl();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   373
        callUserDataHandlers(this, newdoc, UserDataHandler.NODE_CLONED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   374
        cloneNode(newdoc, deep);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   375
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   376
        return newdoc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   377
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   378
    } // cloneNode(boolean):Node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   379
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   380
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   381
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   382
     * internal method to share code with subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   383
     **/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   384
    protected void cloneNode(CoreDocumentImpl newdoc, boolean deep) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   385
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   386
        // clone the children by importing them
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   387
        if (needsSyncChildren()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   388
            synchronizeChildren();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   389
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   390
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   391
        if (deep) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   392
            Map<Node, String> reversedIdentifiers = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   393
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   394
            if (identifiers != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   395
                // Build a reverse mapping from element to identifier.
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   396
                reversedIdentifiers = new HashMap<>(identifiers.size());
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   397
                for (String elementId : identifiers.keySet()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   398
                    reversedIdentifiers.put(identifiers.get(elementId), elementId);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   399
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   400
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   401
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   402
            // Copy children into new document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   403
            for (ChildNode kid = firstChild; kid != null;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   404
                    kid = kid.nextSibling) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   405
                newdoc.appendChild(newdoc.importNode(kid, true, true,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   406
                        reversedIdentifiers));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   407
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   408
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   409
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   410
        // experimental
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   411
        newdoc.allowGrammarAccess = allowGrammarAccess;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   412
        newdoc.errorChecking = errorChecking;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   413
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   414
    } // cloneNode(CoreDocumentImpl,boolean):void
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   415
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   416
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   417
     * Since a Document may contain at most one top-level Element child,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   418
     * and at most one DocumentType declaraction, we need to subclass our
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   419
     * add-children methods to implement this constraint.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   420
     * Since appendChild() is implemented as insertBefore(,null),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   421
     * altering the latter fixes both.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   422
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   423
     * While I'm doing so, I've taken advantage of the opportunity to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   424
     * cache documentElement and docType so we don't have to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   425
     * search for them.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   426
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   427
     * REVISIT: According to the spec it is not allowed to alter neither the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   428
     * document element nor the document type in any way
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   429
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   430
    public Node insertBefore(Node newChild, Node refChild)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   431
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   432
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   433
        // Only one such child permitted
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   434
        int type = newChild.getNodeType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   435
        if (errorChecking) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   436
            if((type == Node.ELEMENT_NODE && docElement != null) ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   437
            (type == Node.DOCUMENT_TYPE_NODE && docType != null)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   438
                String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   439
                throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   440
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   441
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   442
        // Adopt orphan doctypes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   443
        if (newChild.getOwnerDocument() == null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   444
        newChild instanceof DocumentTypeImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   445
            ((DocumentTypeImpl) newChild).ownerDocument = this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   446
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   447
        super.insertBefore(newChild,refChild);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   448
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   449
        // If insert succeeded, cache the kid appropriately
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   450
        if (type == Node.ELEMENT_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   451
            docElement = (ElementImpl)newChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   452
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   453
        else if (type == Node.DOCUMENT_TYPE_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   454
            docType = (DocumentTypeImpl)newChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   455
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   456
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   457
        return newChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   458
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   459
    } // insertBefore(Node,Node):Node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   460
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   461
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   462
     * Since insertBefore caches the docElement (and, currently, docType),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   463
     * removeChild has to know how to undo the cache
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   464
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   465
     * REVISIT: According to the spec it is not allowed to alter neither the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   466
     * document element nor the document type in any way
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   467
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   468
    public Node removeChild(Node oldChild) throws DOMException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   469
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   470
        super.removeChild(oldChild);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   471
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   472
        // If remove succeeded, un-cache the kid appropriately
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   473
        int type = oldChild.getNodeType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   474
        if(type == Node.ELEMENT_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   475
            docElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   476
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   477
        else if (type == Node.DOCUMENT_TYPE_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   478
            docType = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   479
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   480
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   481
        return oldChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   482
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   483
    }   // removeChild(Node):Node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   484
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   485
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   486
     * Since we cache the docElement (and, currently, docType),
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   487
     * replaceChild has to update the cache
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   488
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   489
     * REVISIT: According to the spec it is not allowed to alter neither the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   490
     * document element nor the document type in any way
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   491
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   492
    public Node replaceChild(Node newChild, Node oldChild)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   493
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   494
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   495
        // Adopt orphan doctypes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   496
        if (newChild.getOwnerDocument() == null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   497
        newChild instanceof DocumentTypeImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   498
            ((DocumentTypeImpl) newChild).ownerDocument = this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   499
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   500
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   501
        if (errorChecking &&((docType != null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   502
            oldChild.getNodeType() != Node.DOCUMENT_TYPE_NODE &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   503
            newChild.getNodeType() == Node.DOCUMENT_TYPE_NODE)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   504
            || (docElement != null &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   505
            oldChild.getNodeType() != Node.ELEMENT_NODE &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   506
            newChild.getNodeType() == Node.ELEMENT_NODE))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   507
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   508
            throw new DOMException(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   509
                    DOMException.HIERARCHY_REQUEST_ERR,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   510
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   511
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   512
        super.replaceChild(newChild, oldChild);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   513
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   514
        int type = oldChild.getNodeType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   515
        if(type == Node.ELEMENT_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   516
            docElement = (ElementImpl)newChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   517
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   518
        else if (type == Node.DOCUMENT_TYPE_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   519
            docType = (DocumentTypeImpl)newChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   520
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   521
        return oldChild;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   522
    }   // replaceChild(Node,Node):Node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   523
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   524
    /*
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   525
     * Get Node text content
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   526
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   527
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   528
    public String getTextContent() throws DOMException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   529
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   530
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   531
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   532
    /*
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   533
     * Set Node text content
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   534
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   535
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   536
    public void setTextContent(String textContent)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   537
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   538
        // no-op
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   539
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   540
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   541
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   542
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   543
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   544
    public Object getFeature(String feature, String version) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   545
        return super.getFeature(feature, version);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   546
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   547
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   548
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   549
    // Document methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   550
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   551
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   552
    // factory methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   553
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   554
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   555
     * Factory method; creates an Attribute having this Document as its
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   556
     * OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   557
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   558
     * @param name The name of the attribute. Note that the attribute's value is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   559
     * _not_ established at the factory; remember to set it!
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   560
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   561
     * @throws DOMException(INVALID_NAME_ERR)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   562
     * if the attribute name is not acceptable.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   563
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   564
    public Attr createAttribute(String name)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   565
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   566
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   567
        if (errorChecking && !isXMLName(name,xml11Version)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   568
            String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   569
                DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   570
                            DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   571
                            "INVALID_CHARACTER_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   572
                            null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   573
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   574
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   575
        return new AttrImpl(this, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   576
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   577
    } // createAttribute(String):Attr
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   578
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   579
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   580
     * Factory method; creates a CDATASection having this Document as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   581
     * its OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   582
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   583
     * @param data The initial contents of the CDATA
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   584
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   585
     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents. (HTML
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   586
     * not yet implemented.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   587
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   588
    public CDATASection createCDATASection(String data)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   589
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   590
        return new CDATASectionImpl(this, data);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   591
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   592
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   593
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   594
     * Factory method; creates a Comment having this Document as its
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   595
     * OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   596
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   597
     * @param data The initial contents of the Comment. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   598
    public Comment createComment(String data) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   599
        return new CommentImpl(this, data);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   600
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   601
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   602
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   603
     * Factory method; creates a DocumentFragment having this Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   604
     * as its OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   605
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   606
    public DocumentFragment createDocumentFragment() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   607
        return new DocumentFragmentImpl(this);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   608
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   609
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   610
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   611
     * Factory method; creates an Element having this Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   612
     * as its OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   613
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   614
     * @param tagName The name of the element type to instantiate. For
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   615
     * XML, this is case-sensitive. For HTML, the tagName parameter may
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   616
     * be provided in any case, but it must be mapped to the canonical
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   617
     * uppercase form by the DOM implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   618
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   619
     * @throws DOMException(INVALID_NAME_ERR) if the tag name is not
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   620
     * acceptable.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   621
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   622
    public Element createElement(String tagName)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   623
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   624
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   625
        if (errorChecking && !isXMLName(tagName,xml11Version)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   626
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   627
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   628
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   629
        return new ElementImpl(this, tagName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   630
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   631
    } // createElement(String):Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   632
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   633
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   634
     * Factory method; creates an EntityReference having this Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   635
     * as its OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   636
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   637
     * @param name The name of the Entity we wish to refer to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   638
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   639
     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   640
     * nonstandard entities are not permitted. (HTML not yet
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   641
     * implemented.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   642
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   643
    public EntityReference createEntityReference(String name)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   644
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   645
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   646
        if (errorChecking && !isXMLName(name,xml11Version)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   647
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   648
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   649
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   650
        return new EntityReferenceImpl(this, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   651
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   652
    } // createEntityReference(String):EntityReference
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   653
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   654
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   655
     * Factory method; creates a ProcessingInstruction having this Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   656
     * as its OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   657
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   658
     * @param target The target "processor channel"
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   659
     * @param data Parameter string to be passed to the target.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   660
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   661
     * @throws DOMException(INVALID_NAME_ERR) if the target name is not
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   662
     * acceptable.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   663
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   664
     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents. (HTML
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   665
     * not yet implemented.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   666
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   667
    public ProcessingInstruction createProcessingInstruction(String target,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   668
            String data)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   669
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   670
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   671
        if (errorChecking && !isXMLName(target,xml11Version)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   672
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   673
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   674
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   675
        return new ProcessingInstructionImpl(this, target, data);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   676
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   677
    } // createProcessingInstruction(String,String):ProcessingInstruction
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   678
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   679
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   680
     * Factory method; creates a Text node having this Document as its
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   681
     * OwnerDoc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   682
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   683
     * @param data The initial contents of the Text.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   684
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   685
    public Text createTextNode(String data) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   686
        return new TextImpl(this, data);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   687
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   688
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   689
    // other document methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   690
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   691
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   692
     * For XML, this provides access to the Document Type Definition.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   693
     * For HTML documents, and XML documents which don't specify a DTD,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   694
     * it will be null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   695
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   696
    public DocumentType getDoctype() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   697
        if (needsSyncChildren()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   698
            synchronizeChildren();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   699
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   700
        return docType;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   701
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   702
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   703
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   704
     * Convenience method, allowing direct access to the child node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   705
     * which is considered the root of the actual document content. For
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   706
     * HTML, where it is legal to have more than one Element at the top
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   707
     * level of the document, we pick the one with the tagName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   708
     * "HTML". For XML there should be only one top-level
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   709
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   710
     * (HTML not yet supported.)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   711
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   712
    public Element getDocumentElement() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   713
        if (needsSyncChildren()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   714
            synchronizeChildren();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   715
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   716
        return docElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   717
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   718
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   719
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   720
     * Return a <em>live</em> collection of all descendent Elements (not just
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   721
     * immediate children) having the specified tag name.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   722
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   723
     * @param tagname The type of Element we want to gather. "*" will be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   724
     * taken as a wildcard, meaning "all elements in the document."
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   725
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   726
     * @see DeepNodeListImpl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   727
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   728
    public NodeList getElementsByTagName(String tagname) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   729
        return new DeepNodeListImpl(this,tagname);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   730
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   731
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   732
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   733
     * Retrieve information describing the abilities of this particular
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   734
     * DOM implementation. Intended to support applications that may be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   735
     * using DOMs retrieved from several different sources, potentially
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   736
     * with different underlying representations.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   737
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   738
    public DOMImplementation getImplementation() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   739
        // Currently implemented as a singleton, since it's hardcoded
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   740
        // information anyway.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   741
        return CoreDOMImplementationImpl.getDOMImplementation();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   742
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   743
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   744
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   745
    // Public methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   746
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   747
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   748
    // properties
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   749
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   750
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   751
     * Sets whether the DOM implementation performs error checking
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   752
     * upon operations. Turning off error checking only affects
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   753
     * the following DOM checks:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   754
     * <ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   755
     * <li>Checking strings to make sure that all characters are
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   756
     *     legal XML characters
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   757
     * <li>Hierarchy checking such as allowed children, checks for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   758
     *     cycles, etc.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   759
     * </ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   760
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   761
     * Turning off error checking does <em>not</em> turn off the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   762
     * following checks:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   763
     * <ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   764
     * <li>Read only checks
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   765
     * <li>Checks related to DOM events
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   766
     * </ul>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   767
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   768
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   769
    public void setErrorChecking(boolean check) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   770
        errorChecking = check;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   771
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   772
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   773
    /*
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   774
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   775
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   776
    public void setStrictErrorChecking(boolean check) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   777
        errorChecking = check;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   778
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   779
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   780
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   781
     * Returns true if the DOM implementation performs error checking.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   782
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   783
    public boolean getErrorChecking() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   784
        return errorChecking;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   785
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   786
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   787
    /*
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   788
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   789
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   790
    public boolean getStrictErrorChecking() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   791
        return errorChecking;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   792
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   793
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   794
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   795
     * DOM Level 3 CR - Experimental. (Was getActualEncoding)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   796
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   797
     * An attribute specifying the encoding used for this document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   798
     * at the time of the parsing. This is <code>null</code> when
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   799
     * it is not known, such as when the <code>Document</code> was
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   800
     * created in memory.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   801
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   802
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   803
    public String getInputEncoding() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   804
        return actualEncoding;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   805
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   806
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   807
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   808
     * DOM Internal
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   809
     * (Was a DOM L3 Core WD public interface method setActualEncoding )
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   810
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   811
     * An attribute specifying the actual encoding of this document. This is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   812
     * <code>null</code> otherwise.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   813
     * <br> This attribute represents the property [character encoding scheme]
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   814
     * defined in .
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   815
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   816
    public void setInputEncoding(String value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   817
        actualEncoding = value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   818
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   819
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   820
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   821
     * DOM Internal
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   822
     * (Was a DOM L3 Core WD public interface method setXMLEncoding )
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   823
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   824
     * An attribute specifying, as part of the XML declaration,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   825
     * the encoding of this document. This is null when unspecified.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   826
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   827
    public void setXmlEncoding(String value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   828
        encoding = value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   829
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   830
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   831
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   832
     * @deprecated This method is internal and only exists for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   833
     * compatibility with older applications. New applications
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   834
     * should never call this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   835
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 33349
diff changeset
   836
    @Deprecated
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   837
    public void setEncoding(String value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   838
        setXmlEncoding(value);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   839
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   840
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   841
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   842
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   843
     * The encoding of this document (part of XML Declaration)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   844
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   845
    public String getXmlEncoding() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   846
        return encoding;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   847
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   848
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   849
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   850
     * @deprecated This method is internal and only exists for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   851
     * compatibility with older applications. New applications
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   852
     * should never call this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   853
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 33349
diff changeset
   854
    @Deprecated
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   855
    public String getEncoding() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   856
        return getXmlEncoding();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   857
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   858
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   859
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   860
     * DOM Level 3 CR - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   861
     * version - An attribute specifying, as part of the XML declaration,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   862
     * the version number of this document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   863
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   864
    public void setXmlVersion(String value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   865
        if(value.equals("1.0") || value.equals("1.1")){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   866
            //we need to change the flag value only --
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   867
            // when the version set is different than already set.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   868
            if(!getXmlVersion().equals(value)){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   869
                xmlVersionChanged = true ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   870
                //change the normalization value back to false
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   871
                isNormalized(false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   872
                version = value;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   873
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   874
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   875
        else{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   876
            //NOT_SUPPORTED_ERR: Raised if the vesion is set to a value that is not supported by
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   877
            //this document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   878
            //we dont support any other XML version
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   879
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   880
            throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   881
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   882
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   883
        if((getXmlVersion()).equals("1.1")){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   884
            xml11Version = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   885
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   886
        else{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   887
            xml11Version = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   888
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   889
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   890
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   891
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   892
     * @deprecated This method is internal and only exists for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   893
     * compatibility with older applications. New applications
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   894
     * should never call this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   895
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 33349
diff changeset
   896
    @Deprecated
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   897
    public void setVersion(String value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   898
        setXmlVersion(value);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   899
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   900
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   901
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   902
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   903
     * The version of this document (part of XML Declaration)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   904
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   905
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   906
    public String getXmlVersion() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   907
        return (version == null)?"1.0":version;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   908
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   909
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   910
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   911
     * @deprecated This method is internal and only exists for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   912
     * compatibility with older applications. New applications
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   913
     * should never call this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   914
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 33349
diff changeset
   915
    @Deprecated
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   916
    public String getVersion() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   917
        return getXmlVersion();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   918
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   919
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   920
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   921
     * DOM Level 3 CR - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   922
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   923
     * Xmlstandalone - An attribute specifying, as part of the XML declaration,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   924
     * whether this document is standalone
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   925
     * @exception DOMException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   926
     *    NOT_SUPPORTED_ERR: Raised if this document does not support the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   927
     *   "XML" feature.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   928
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   929
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   930
    public void setXmlStandalone(boolean value)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   931
            throws DOMException {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
   932
        standalone = value;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   933
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   934
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   935
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   936
     * @deprecated This method is internal and only exists for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   937
     * compatibility with older applications. New applications
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   938
     * should never call this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   939
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 33349
diff changeset
   940
    @Deprecated
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   941
    public void setStandalone(boolean value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   942
        setXmlStandalone(value);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   943
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   944
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   945
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   946
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   947
     * standalone that specifies whether this document is standalone
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   948
     * (part of XML Declaration)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   949
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   950
    public boolean getXmlStandalone() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   951
        return standalone;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   952
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   953
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   954
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   955
     * @deprecated This method is internal and only exists for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   956
     * compatibility with older applications. New applications
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   957
     * should never call this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   958
     */
45490
dc68478b53b9 8181153: Fix lint warnings in JAXP repo: dep-ann
joehw
parents: 33349
diff changeset
   959
    @Deprecated
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   960
    public boolean getStandalone() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   961
        return getXmlStandalone();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   962
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   963
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   964
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   965
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   966
     * The location of the document or <code>null</code> if undefined.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   967
     * <br>Beware that when the <code>Document</code> supports the feature
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   968
     * "HTML" , the href attribute of the HTML BASE element takes precedence
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   969
     * over this attribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   970
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   971
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   972
    public String getDocumentURI(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   973
        return fDocumentURI;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   974
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   975
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   976
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   977
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   978
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   979
     * Renaming node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   980
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   981
    public Node renameNode(Node n,String namespaceURI,String name)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   982
    throws DOMException{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   983
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   984
        if (errorChecking && n.getOwnerDocument() != this && n != this) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   985
            String msg = DOMMessageFormatter.formatMessage(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   986
                    DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   987
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   988
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   989
        switch (n.getNodeType()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   990
            case ELEMENT_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   991
                ElementImpl el = (ElementImpl) n;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   992
                if (el instanceof ElementNSImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   993
                    ((ElementNSImpl) el).rename(namespaceURI, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   994
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   995
                    // fire user data NODE_RENAMED event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   996
                    callUserDataHandlers(el, null, UserDataHandler.NODE_RENAMED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   997
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   998
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
   999
                    if (namespaceURI == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1000
                        if (errorChecking) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1001
                            int colon1 = name.indexOf(':');
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1002
                            if(colon1 != -1){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1003
                                String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1004
                                    DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1005
                                                DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1006
                                                "NAMESPACE_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1007
                                                null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1008
                                throw new DOMException(DOMException.NAMESPACE_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1009
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1010
                            if (!isXMLName(name,xml11Version)) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1011
                                String msg = DOMMessageFormatter.formatMessage(
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1012
                                        DOMMessageFormatter.DOM_DOMAIN,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1013
                                        "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1014
                                throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1015
                                        msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1016
                            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1017
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1018
                        el.rename(name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1019
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1020
                        // fire user data NODE_RENAMED event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1021
                        callUserDataHandlers(el, null,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1022
                                UserDataHandler.NODE_RENAMED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1023
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1024
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1025
                        // we need to create a new object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1026
                        ElementNSImpl nel =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1027
                            new ElementNSImpl(this, namespaceURI, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1028
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1029
                        // register event listeners on new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1030
                        copyEventListeners(el, nel);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1031
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1032
                        // remove user data from old node
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1033
                        Map<String, UserDataRecord> data = removeUserDataTable(el);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1034
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1035
                        // remove old node from parent if any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1036
                        Node parent = el.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1037
                        Node nextSib = el.getNextSibling();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1038
                        if (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1039
                            parent.removeChild(el);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1040
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1041
                        // move children to new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1042
                        Node child = el.getFirstChild();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1043
                        while (child != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1044
                            el.removeChild(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1045
                            nel.appendChild(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1046
                            child = el.getFirstChild();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1047
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1048
                        // move specified attributes to new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1049
                        nel.moveSpecifiedAttributes(el);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1050
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1051
                        // attach user data to new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1052
                        setUserDataTable(nel, data);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1053
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1054
                        // and fire user data NODE_RENAMED event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1055
                        callUserDataHandlers(el, nel,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1056
                                UserDataHandler.NODE_RENAMED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1057
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1058
                        // insert new node where old one was
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1059
                        if (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1060
                            parent.insertBefore(nel, nextSib);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1061
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1062
                        el = nel;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1063
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1064
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1065
                // fire ElementNameChanged event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1066
                renamedElement((Element) n, el);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1067
                return el;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1068
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1069
            case ATTRIBUTE_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1070
                AttrImpl at = (AttrImpl) n;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1071
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1072
                // dettach attr from element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1073
                Element el = at.getOwnerElement();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1074
                if (el != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1075
                    el.removeAttributeNode(at);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1076
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1077
                if (n instanceof AttrNSImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1078
                    ((AttrNSImpl) at).rename(namespaceURI, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1079
                    // reattach attr to element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1080
                    if (el != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1081
                        el.setAttributeNodeNS(at);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1082
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1083
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1084
                    // fire user data NODE_RENAMED event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1085
                    callUserDataHandlers(at, null, UserDataHandler.NODE_RENAMED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1086
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1087
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1088
                    if (namespaceURI == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1089
                        at.rename(name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1090
                        // reattach attr to element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1091
                        if (el != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1092
                            el.setAttributeNode(at);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1093
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1094
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1095
                        // fire user data NODE_RENAMED event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1096
                        callUserDataHandlers(at, null, UserDataHandler.NODE_RENAMED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1097
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1098
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1099
                        // we need to create a new object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1100
                        AttrNSImpl nat = new AttrNSImpl(this, namespaceURI, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1101
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1102
                        // register event listeners on new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1103
                        copyEventListeners(at, nat);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1104
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1105
                        // remove user data from old node
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1106
                        Map<String, UserDataRecord> data = removeUserDataTable(at);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1107
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1108
                        // move children to new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1109
                        Node child = at.getFirstChild();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1110
                        while (child != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1111
                            at.removeChild(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1112
                            nat.appendChild(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1113
                            child = at.getFirstChild();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1114
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1115
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1116
                        // attach user data to new node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1117
                        setUserDataTable(nat, data);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1118
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1119
                        // and fire user data NODE_RENAMED event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1120
                        callUserDataHandlers(at, nat, UserDataHandler.NODE_RENAMED);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1121
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1122
                        // reattach attr to element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1123
                        if (el != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1124
                            el.setAttributeNode(nat);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1125
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1126
                        at = nat;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1127
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1128
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1129
                // fire AttributeNameChanged event
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1130
                renamedAttrNode((Attr) n, at);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1131
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1132
                return at;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1133
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1134
            default: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1135
                String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1136
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1137
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1138
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1139
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1140
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1141
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1142
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1143
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1144
     *  DOM Level 3 WD - Experimental
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1145
     *  Normalize document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1146
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1147
    public void normalizeDocument(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1148
        // No need to normalize if already normalized.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1149
        if (isNormalized() && !isNormalizeDocRequired()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1150
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1151
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1152
        if (needsSyncChildren()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1153
            synchronizeChildren();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1154
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1155
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1156
        if (domNormalizer == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1157
            domNormalizer = new DOMNormalizer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1158
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1159
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1160
        if (fConfiguration == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1161
            fConfiguration =  new DOMConfigurationImpl();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1162
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1163
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1164
            fConfiguration.reset();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1165
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1166
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1167
        domNormalizer.normalizeDocument(this, fConfiguration);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1168
        isNormalized(true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1169
        //set the XMLversion changed value to false -- once we have finished
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1170
        //doing normalization
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1171
        xmlVersionChanged = false ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1172
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1173
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1174
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1175
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1176
     * DOM Level 3 CR - Experimental
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1177
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1178
     *  The configuration used when <code>Document.normalizeDocument</code> is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1179
     * invoked.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1180
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1181
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1182
    public DOMConfiguration getDomConfig(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1183
        if (fConfiguration == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1184
            fConfiguration = new DOMConfigurationImpl();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1185
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1186
        return fConfiguration;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1187
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1188
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1189
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1190
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1191
     * Returns the absolute base URI of this node or null if the implementation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1192
     * wasn't able to obtain an absolute URI. Note: If the URI is malformed, a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1193
     * null is returned.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1194
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1195
     * @return The absolute base URI of this node or null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1196
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1197
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1198
    public String getBaseURI() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1199
        if (fDocumentURI != null && fDocumentURI.length() != 0 ) {// attribute value is always empty string
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1200
            try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1201
                return new URI(fDocumentURI).toString();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1202
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1203
            catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1204
                // REVISIT: what should happen in this case?
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1205
                return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1206
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1207
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1208
        return fDocumentURI;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1209
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1210
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1211
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1212
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1213
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1214
    public void setDocumentURI(String documentURI){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1215
        fDocumentURI = documentURI;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1216
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1217
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1218
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1219
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1220
    // DOM L3 LS
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1221
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1222
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1223
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1224
     * Indicates whether the method load should be synchronous or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1225
     * asynchronous. When the async attribute is set to <code>true</code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1226
     * the load method returns control to the caller before the document has
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1227
     * completed loading. The default value of this property is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1228
     * <code>false</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1229
     * <br>Setting the value of this attribute might throw NOT_SUPPORTED_ERR
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1230
     * if the implementation doesn't support the mode the attribute is being
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1231
     * set to. Should the DOM spec define the default value of this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1232
     * property? What if implementing both async and sync IO is impractical
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1233
     * in some systems?  2001-09-14. default is <code>false</code> but we
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1234
     * need to check with Mozilla and IE.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1235
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1236
    public boolean getAsync() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1237
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1238
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1239
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1240
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1241
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1242
     * Indicates whether the method load should be synchronous or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1243
     * asynchronous. When the async attribute is set to <code>true</code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1244
     * the load method returns control to the caller before the document has
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1245
     * completed loading. The default value of this property is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1246
     * <code>false</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1247
     * <br>Setting the value of this attribute might throw NOT_SUPPORTED_ERR
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1248
     * if the implementation doesn't support the mode the attribute is being
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1249
     * set to. Should the DOM spec define the default value of this
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1250
     * property? What if implementing both async and sync IO is impractical
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1251
     * in some systems?  2001-09-14. default is <code>false</code> but we
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1252
     * need to check with Mozilla and IE.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1253
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1254
    public void setAsync(boolean async) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1255
        if (async) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1256
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1257
            throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1258
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1259
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1260
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1261
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1262
     * If the document is currently being loaded as a result of the method
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1263
     * <code>load</code> being invoked the loading and parsing is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1264
     * immediately aborted. The possibly partial result of parsing the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1265
     * document is discarded and the document is cleared.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1266
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1267
    public void abort() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1268
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1269
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1270
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1271
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1272
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1273
     * Replaces the content of the document with the result of parsing the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1274
     * given URI. Invoking this method will either block the caller or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1275
     * return to the caller immediately depending on the value of the async
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1276
     * attribute. Once the document is fully loaded a "load" event (as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1277
     * defined in [<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331'>DOM Level 3 Events</a>]
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1278
     * , except that the <code>Event.targetNode</code> will be the document,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1279
     * not an element) will be dispatched on the document. If an error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1280
     * occurs, an implementation dependent "error" event will be dispatched
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1281
     * on the document. If this method is called on a document that is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1282
     * currently loading, the current load is interrupted and the new URI
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1283
     * load is initiated.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1284
     * <br> When invoking this method the parameters used in the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1285
     * <code>DOMParser</code> interface are assumed to have their default
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1286
     * values with the exception that the parameters <code>"entities"</code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1287
     * , <code>"normalize-characters"</code>,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1288
     * <code>"check-character-normalization"</code> are set to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1289
     * <code>"false"</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1290
     * <br> The result of a call to this method is the same the result of a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1291
     * call to <code>DOMParser.parseWithContext</code> with an input stream
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1292
     * referencing the URI that was passed to this call, the document as the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1293
     * context node, and the action <code>ACTION_REPLACE_CHILDREN</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1294
     * @param uri The URI reference for the XML file to be loaded. If this is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1295
     *  a relative URI, the base URI used by the implementation is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1296
     *  implementation dependent.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1297
     * @return If async is set to <code>true</code> <code>load</code> returns
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1298
     *   <code>true</code> if the document load was successfully initiated.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1299
     *   If an error occurred when initiating the document load,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1300
     *   <code>load</code> returns <code>false</code>.If async is set to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1301
     *   <code>false</code> <code>load</code> returns <code>true</code> if
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1302
     *   the document was successfully loaded and parsed. If an error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1303
     *   occurred when either loading or parsing the URI, <code>load</code>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1304
     *   returns <code>false</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1305
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1306
    public boolean load(String uri) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1307
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1308
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1309
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1310
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1311
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1312
     * Replace the content of the document with the result of parsing the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1313
     * input string, this method is always synchronous.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1314
     * @param source A string containing an XML document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1315
     * @return <code>true</code> if parsing the input string succeeded
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1316
     *   without errors, otherwise <code>false</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1317
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1318
    public boolean loadXML(String source) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1319
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1320
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1321
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1322
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1323
     * DOM Level 3 WD - Experimental.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1324
     * Save the document or the given node and all its descendants to a string
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1325
     * (i.e. serialize the document or node).
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1326
     * <br>The parameters used in the <code>LSSerializer</code> interface are
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1327
     * assumed to have their default values when invoking this method.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1328
     * <br> The result of a call to this method is the same the result of a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1329
     * call to <code>LSSerializer.writeToString</code> with the document as
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1330
     * the node to write.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1331
     * @param node Specifies what to serialize, if this parameter is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1332
     *   <code>null</code> the whole document is serialized, if it's
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1333
     *   non-null the given node is serialized.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1334
     * @return The serialized document or <code>null</code> in case an error
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1335
     *   occurred.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1336
     * @exception DOMException
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1337
     *   WRONG_DOCUMENT_ERR: Raised if the node passed in as the node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1338
     *   parameter is from an other document.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1339
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1340
    public String saveXML(Node node)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1341
            throws DOMException {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1342
        if (errorChecking && node != null
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1343
                && this != node.getOwnerDocument()) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1344
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1345
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1346
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1347
        DOMImplementationLS domImplLS = (DOMImplementationLS) DOMImplementationImpl.getDOMImplementation();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1348
        LSSerializer xmlWriter = domImplLS.createLSSerializer();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1349
        if (node == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1350
            node = this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1351
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1352
        return xmlWriter.writeToString(node);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1353
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1354
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1355
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1356
     * Sets whether the DOM implementation generates mutation events upon
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1357
     * operations.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1358
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1359
    void setMutationEvents(boolean set) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1360
        // does nothing by default - overidden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1361
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1362
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1363
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1364
     * Returns true if the DOM implementation generates mutation events.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1365
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1366
    boolean getMutationEvents() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1367
        // does nothing by default - overriden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1368
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1369
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1370
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1371
    // non-DOM factory methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1372
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1373
     * NON-DOM Factory method; creates a DocumentType having this Document as
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1374
     * its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1375
     * information unspecified.)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1376
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1377
     * @param name The name of the Entity we wish to provide a value for.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1378
     *
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1379
     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where DTDs
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1380
     * are not permitted. (HTML not yet implemented.)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1381
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1382
    public DocumentType createDocumentType(String qualifiedName,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1383
            String publicID,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1384
            String systemID)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1385
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1386
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1387
        return new DocumentTypeImpl(this, qualifiedName, publicID, systemID);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1388
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1389
    } // createDocumentType(String):DocumentType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1390
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1391
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1392
     * NON-DOM Factory method; creates an Entity having this Document as its
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1393
     * OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1394
     * information unspecified.)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1395
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1396
     * @param name The name of the Entity we wish to provide a value for.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1397
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1398
     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1399
     * nonstandard entities are not permitted. (HTML not yet implemented.)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1400
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1401
    public Entity createEntity(String name)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1402
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1403
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1404
        if (errorChecking && !isXMLName(name, xml11Version)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1405
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1406
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1407
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1408
        return new EntityImpl(this, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1409
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1410
    } // createEntity(String):Entity
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1411
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1412
    /**
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1413
     * NON-DOM Factory method; creates a Notation having this Document as its
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1414
     * OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1415
     * information unspecified.)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1416
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1417
     * @param name The name of the Notation we wish to describe
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1418
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1419
     * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1420
     * notations are not permitted. (HTML not yet implemented.)
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1421
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1422
    public Notation createNotation(String name)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1423
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1424
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1425
        if (errorChecking && !isXMLName(name, xml11Version)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1426
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1427
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1428
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1429
        return new NotationImpl(this, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1430
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1431
    } // createNotation(String):Notation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1432
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1433
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1434
     * NON-DOM Factory method: creates an element definition. Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1435
     * definitions hold default attribute values.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1436
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1437
    public ElementDefinitionImpl createElementDefinition(String name)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1438
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1439
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1440
        if (errorChecking && !isXMLName(name, xml11Version)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1441
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1442
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1443
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1444
        return new ElementDefinitionImpl(this, name);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1445
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1446
    } // createElementDefinition(String):ElementDefinitionImpl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1447
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1448
    // other non-DOM methods
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1449
    /**
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1450
     * NON-DOM: Get the number associated with this document. Used to order
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1451
     * documents in the implementation.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1452
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1453
    protected int getNodeNumber() {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1454
        if (documentNumber == 0) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1455
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1456
            CoreDOMImplementationImpl cd = (CoreDOMImplementationImpl) CoreDOMImplementationImpl.getDOMImplementation();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1457
            documentNumber = cd.assignDocumentNumber();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1458
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1459
        return documentNumber;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1460
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1461
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1462
    /**
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1463
     * NON-DOM: Get a number associated with a node created with respect to this
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1464
     * document. Needed for compareDocumentPosition when nodes are disconnected.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1465
     * This is only used on demand.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1466
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1467
    protected int getNodeNumber(Node node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1468
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1469
        // Check if the node is already in the hash
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1470
        // If so, retrieve the node number
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1471
        // If not, assign a number to the node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1472
        // Node numbers are negative, from -1 to -n
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1473
        int num;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1474
        if (nodeTable == null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1475
            nodeTable = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1476
            num = --nodeCounter;
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 45490
diff changeset
  1477
            nodeTable.put(node, num);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1478
        } else {
47712
bde0215f1f70 8181151: Fix lint warnings in JAXP repo: cast
joehw
parents: 47312
diff changeset
  1479
            Integer n = nodeTable.get(node);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1480
            if (n == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1481
                num = --nodeCounter;
45853
bfa06be36a17 8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents: 45490
diff changeset
  1482
                nodeTable.put(node, num);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1483
            } else {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1484
                num = n.intValue();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1485
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1486
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1487
        return num;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1488
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1489
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1490
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1491
     * Copies a node from another document to this document. The new nodes are
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1492
     * created using this document's factory methods and are populated with the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1493
     * data from the source's accessor methods defined by the DOM interfaces.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1494
     * Its behavior is otherwise similar to that of cloneNode.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1495
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1496
     * According to the DOM specifications, document nodes cannot be imported
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1497
     * and a NOT_SUPPORTED_ERR exception is thrown if attempted.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1498
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1499
    public Node importNode(Node source, boolean deep)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1500
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1501
        return importNode(source, deep, false, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1502
    } // importNode(Node,boolean):Node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1503
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1504
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1505
     * Overloaded implementation of DOM's importNode method. This method
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1506
     * provides the core functionality for the public importNode and cloneNode
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1507
     * methods.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1508
     *
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1509
     * The reversedIdentifiers parameter is provided for cloneNode to preserve
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1510
     * the document's identifiers. The Map has Elements as the keys and
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1511
     * their identifiers as the values. When an element is being imported, a
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1512
     * check is done for an associated identifier. If one exists, the identifier
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1513
     * is registered with the new, imported element. If reversedIdentifiers is
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1514
     * null, the parameter is not applied.
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1515
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1516
    private Node importNode(Node source, boolean deep, boolean cloningDoc,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1517
            Map<Node, String> reversedIdentifiers)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1518
            throws DOMException {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1519
        Node newnode = null;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1520
        Map<String, UserDataRecord> userData = null;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1521
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1522
        // Sigh. This doesn't work; too many nodes have private data that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1523
        // would have to be manually tweaked. May be able to add local
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1524
        // shortcuts to each nodetype. Consider ?????
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1525
        // if(source instanceof NodeImpl &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1526
        //  !(source instanceof DocumentImpl))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1527
        // {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1528
        //  // Can't clone DocumentImpl since it invokes us...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1529
        //  newnode=(NodeImpl)source.cloneNode(false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1530
        //  newnode.ownerDocument=this;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1531
        // }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1532
        // else
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1533
        if (source instanceof NodeImpl) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1534
            userData = ((NodeImpl) source).getUserDataRecord();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1535
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1536
        int type = source.getNodeType();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1537
        switch (type) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1538
            case ELEMENT_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1539
                Element newElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1540
                boolean domLevel20 = source.getOwnerDocument().getImplementation().hasFeature("XML", "2.0");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1541
                // Create element according to namespace support/qualification.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1542
                if(domLevel20 == false || source.getLocalName() == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1543
                    newElement = createElement(source.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1544
                else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1545
                    newElement = createElementNS(source.getNamespaceURI(),
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1546
                            source.getNodeName());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1547
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1548
                // Copy element's attributes, if any.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1549
                NamedNodeMap sourceAttrs = source.getAttributes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1550
                if (sourceAttrs != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1551
                    int length = sourceAttrs.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1552
                    for (int index = 0; index < length; index++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1553
                        Attr attr = (Attr)sourceAttrs.item(index);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1554
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1555
                        // NOTE: this methods is used for both importingNode
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1556
                        // and cloning the document node. In case of the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1557
                        // clonning default attributes should be copied.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1558
                        // But for importNode defaults should be ignored.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1559
                        if (attr.getSpecified() || cloningDoc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1560
                            Attr newAttr = (Attr)importNode(attr, true, cloningDoc,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1561
                                    reversedIdentifiers);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1562
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1563
                            // Attach attribute according to namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1564
                            // support/qualification.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1565
                            if (domLevel20 == false ||
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1566
                            attr.getLocalName() == null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1567
                                newElement.setAttributeNode(newAttr);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1568
                            else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1569
                                newElement.setAttributeNodeNS(newAttr);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1570
                            }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1571
                        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1572
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1573
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1574
                // Register element identifier.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1575
                if (reversedIdentifiers != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1576
                    // Does element have an associated identifier?
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1577
                    String elementId = reversedIdentifiers.get(source);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1578
                    if (elementId != null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1579
                        if (identifiers == null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1580
                            identifiers = new HashMap<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1581
                        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1582
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1583
                        identifiers.put(elementId, newElement);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1584
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1585
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1586
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1587
                newnode = newElement;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1588
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1589
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1590
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1591
            case ATTRIBUTE_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1592
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1593
                if( source.getOwnerDocument().getImplementation().hasFeature("XML", "2.0") ){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1594
                    if (source.getLocalName() == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1595
                        newnode = createAttribute(source.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1596
                    } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1597
                        newnode = createAttributeNS(source.getNamespaceURI(),
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1598
                                source.getNodeName());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1599
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1600
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1601
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1602
                    newnode = createAttribute(source.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1603
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1604
                // if source is an AttrImpl from this very same implementation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1605
                // avoid creating the child nodes if possible
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1606
                if (source instanceof AttrImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1607
                    AttrImpl attr = (AttrImpl) source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1608
                    if (attr.hasStringValue()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1609
                        AttrImpl newattr = (AttrImpl) newnode;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1610
                        newattr.setValue(attr.getValue());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1611
                        deep = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1612
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1613
                    else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1614
                        deep = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1615
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1616
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1617
                else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1618
                    // According to the DOM spec the kids carry the value.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1619
                    // However, there are non compliant implementations out
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1620
                    // there that fail to do so. To avoid ending up with no
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1621
                    // value at all, in this case we simply copy the text value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1622
                    // directly.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1623
                    if (source.getFirstChild() == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1624
                        newnode.setNodeValue(source.getNodeValue());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1625
                        deep = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1626
                    } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1627
                        deep = true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1628
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1629
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1630
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1631
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1632
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1633
            case TEXT_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1634
                newnode = createTextNode(source.getNodeValue());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1635
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1636
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1637
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1638
            case CDATA_SECTION_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1639
                newnode = createCDATASection(source.getNodeValue());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1640
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1641
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1642
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1643
            case ENTITY_REFERENCE_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1644
                newnode = createEntityReference(source.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1645
                // the subtree is created according to this doc by the method
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1646
                // above, so avoid carrying over original subtree
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1647
                deep = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1648
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1649
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1650
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1651
            case ENTITY_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1652
                Entity srcentity = (Entity)source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1653
                EntityImpl newentity =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1654
                (EntityImpl)createEntity(source.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1655
                newentity.setPublicId(srcentity.getPublicId());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1656
                newentity.setSystemId(srcentity.getSystemId());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1657
                newentity.setNotationName(srcentity.getNotationName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1658
                // Kids carry additional value,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1659
                // allow deep import temporarily
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1660
                newentity.isReadOnly(false);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1661
                newnode = newentity;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1662
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1663
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1664
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1665
            case PROCESSING_INSTRUCTION_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1666
                newnode = createProcessingInstruction(source.getNodeName(),
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1667
                        source.getNodeValue());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1668
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1669
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1670
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1671
            case COMMENT_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1672
                newnode = createComment(source.getNodeValue());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1673
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1674
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1675
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1676
            case DOCUMENT_TYPE_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1677
                // unless this is used as part of cloning a Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1678
                // forbid it for the sake of being compliant to the DOM spec
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1679
                if (!cloningDoc) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1680
                    String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1681
                    throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1682
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1683
                DocumentType srcdoctype = (DocumentType)source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1684
                DocumentTypeImpl newdoctype = (DocumentTypeImpl)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1685
                createDocumentType(srcdoctype.getNodeName(),
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1686
                        srcdoctype.getPublicId(),
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1687
                        srcdoctype.getSystemId());
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1688
                // Values are on NamedNodeMaps
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1689
                NamedNodeMap smap = srcdoctype.getEntities();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1690
                NamedNodeMap tmap = newdoctype.getEntities();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1691
                if(smap != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1692
                    for(int i = 0; i < smap.getLength(); i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1693
                        tmap.setNamedItem(importNode(smap.item(i), true, true,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1694
                                reversedIdentifiers));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1695
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1696
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1697
                smap = srcdoctype.getNotations();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1698
                tmap = newdoctype.getNotations();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1699
                if (smap != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1700
                    for(int i = 0; i < smap.getLength(); i++) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1701
                        tmap.setNamedItem(importNode(smap.item(i), true, true,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1702
                                reversedIdentifiers));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1703
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1704
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1705
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1706
                // NOTE: At this time, the DOM definition of DocumentType
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1707
                // doesn't cover Elements and their Attributes. domimpl's
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1708
                // extentions in that area will not be preserved, even if
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1709
                // copying from domimpl to domimpl. We could special-case
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1710
                // that here. Arguably we should. Consider. ?????
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1711
                newnode = newdoctype;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1712
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1713
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1714
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1715
            case DOCUMENT_FRAGMENT_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1716
                newnode = createDocumentFragment();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1717
                // No name, kids carry value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1718
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1719
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1720
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1721
            case NOTATION_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1722
                Notation srcnotation = (Notation)source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1723
                NotationImpl newnotation =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1724
                (NotationImpl)createNotation(source.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1725
                newnotation.setPublicId(srcnotation.getPublicId());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1726
                newnotation.setSystemId(srcnotation.getSystemId());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1727
                // Kids carry additional value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1728
                newnode = newnotation;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1729
                // No name, no value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1730
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1731
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1732
            case DOCUMENT_NODE : // Can't import document nodes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1733
            default: {           // Unknown node type
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1734
                String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1735
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1736
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1737
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1738
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1739
                if(userData != null)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1740
                        callUserDataHandlers(source, newnode, UserDataHandler.NODE_IMPORTED,userData);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1741
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1742
        // If deep, replicate and attach the kids.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1743
        if (deep) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1744
            for (Node srckid = source.getFirstChild();
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1745
                    srckid != null;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1746
                    srckid = srckid.getNextSibling()) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1747
                newnode.appendChild(importNode(srckid, true, cloningDoc,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1748
                        reversedIdentifiers));
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1749
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1750
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1751
        if (newnode.getNodeType() == Node.ENTITY_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1752
            ((NodeImpl)newnode).setReadOnly(true, true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1753
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1754
        return newnode;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1755
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1756
    } // importNode(Node,boolean,boolean,Map):Node
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1757
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1758
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1759
     * DOM Level 3 WD - Experimental
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1760
     * Change the node's ownerDocument, and its subtree, to this Document
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1761
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1762
     * @param source The node to adopt.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1763
     * @see #importNode
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1764
     **/
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1765
    public Node adoptNode(Node source) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1766
        NodeImpl node;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1767
        Map<String, UserDataRecord> userData;
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1768
        try {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1769
            node = (NodeImpl) source;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1770
        } catch (ClassCastException e) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1771
            // source node comes from a different DOMImplementation
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1772
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1773
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1774
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1775
        // Return null if the source is null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1776
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1777
        if (source == null ) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1778
            return null;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1779
        } else if (source.getOwnerDocument() != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1780
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1781
            DOMImplementation thisImpl = this.getImplementation();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1782
            DOMImplementation otherImpl = source.getOwnerDocument().getImplementation();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1783
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1784
            // when the source node comes from a different implementation.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1785
            if (thisImpl != otherImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1786
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1787
                // Adopting from a DefferedDOM to DOM
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1788
                if (thisImpl instanceof com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1789
                        otherImpl instanceof com.sun.org.apache.xerces.internal.dom.DeferredDOMImplementationImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1790
                    // traverse the DOM and expand deffered nodes and then allow adoption
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1791
                    undeferChildren (node);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1792
                } else if ( thisImpl instanceof com.sun.org.apache.xerces.internal.dom.DeferredDOMImplementationImpl
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1793
                        && otherImpl instanceof com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1794
                    // Adopting from a DOM into a DefferedDOM, this should be okay
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1795
                } else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1796
                    // Adopting between two dissimilar DOM's is not allowed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1797
                    return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1798
                }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1799
            }
52721
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
  1800
            // Adopting from a deferred DOM into another deferred DOM
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
  1801
            else if (otherImpl instanceof DeferredDOMImplementationImpl) {
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
  1802
                // traverse the DOM and expand deferred nodes and then allow adoption
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
  1803
                undeferChildren (node);
732bec44c89e 8213117: adoptNode corrupts attribute values
joehw
parents: 48409
diff changeset
  1804
            }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1805
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1806
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1807
        switch (node.getNodeType()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1808
            case ATTRIBUTE_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1809
                AttrImpl attr = (AttrImpl) node;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1810
                // remove node from wherever it is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1811
                if( attr.getOwnerElement() != null){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1812
                    //1. owner element attribute is set to null
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1813
                    attr.getOwnerElement().removeAttributeNode(attr);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1814
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1815
                //2. specified flag is set to true
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1816
                attr.isSpecified(true);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1817
                userData = node.getUserDataRecord();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1818
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1819
                //3. change ownership
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1820
                attr.setOwnerDocument(this);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1821
                if (userData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1822
                    setUserDataTable(node, userData);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1823
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1824
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1825
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1826
            //entity, notation nodes are read only nodes.. so they can't be adopted.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1827
            //runtime will fall through to NOTATION_NODE
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1828
            case ENTITY_NODE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1829
            case NOTATION_NODE:{
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1830
                String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1831
                throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1832
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1833
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1834
            //document, documentype nodes can't be adopted.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1835
            //runtime will fall through to DocumentTypeNode
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1836
            case DOCUMENT_NODE:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1837
            case DOCUMENT_TYPE_NODE: {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1838
                String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1839
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1840
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1841
            case ENTITY_REFERENCE_NODE: {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1842
                userData = node.getUserDataRecord();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1843
                // remove node from wherever it is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1844
                Node parent = node.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1845
                if (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1846
                    parent.removeChild(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1847
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1848
                // discard its replacement value
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1849
                Node child;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1850
                while ((child = node.getFirstChild()) != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1851
                    node.removeChild(child);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1852
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1853
                // change ownership
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1854
                node.setOwnerDocument(this);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1855
                if (userData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1856
                    setUserDataTable(node, userData);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1857
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1858
                // set its new replacement value if any
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1859
                if (docType == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1860
                    break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1861
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1862
                NamedNodeMap entities = docType.getEntities();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1863
                Node entityNode = entities.getNamedItem(node.getNodeName());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1864
                if (entityNode == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1865
                    break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1866
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1867
                for (child = entityNode.getFirstChild();
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1868
                        child != null; child = child.getNextSibling()) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1869
                    Node childClone = child.cloneNode(true);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1870
                    node.appendChild(childClone);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1871
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1872
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1873
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1874
            case ELEMENT_NODE: {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1875
                userData = node.getUserDataRecord();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1876
                // remove node from wherever it is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1877
                Node parent = node.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1878
                if (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1879
                    parent.removeChild(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1880
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1881
                // change ownership
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1882
                node.setOwnerDocument(this);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1883
                if (userData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1884
                    setUserDataTable(node, userData);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1885
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1886
                // reconcile default attributes
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1887
                ((ElementImpl)node).reconcileDefaultAttributes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1888
                break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1889
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1890
            default: {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1891
                userData = node.getUserDataRecord();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1892
                // remove node from wherever it is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1893
                Node parent = node.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1894
                if (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1895
                    parent.removeChild(source);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1896
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1897
                // change ownership
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1898
                node.setOwnerDocument(this);
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1899
                if (userData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1900
                    setUserDataTable(node, userData);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1901
                }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1902
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1903
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1904
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1905
                //DOM L3 Core CR
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1906
        //http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core.html#UserDataHandler-ADOPTED
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1907
        if (userData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1908
            callUserDataHandlers(source, null, UserDataHandler.NODE_ADOPTED, userData);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  1909
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1910
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1911
        return node;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1912
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1913
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1914
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1915
     * Traverses the DOM Tree and expands deferred nodes and their
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1916
     * children.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1917
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1918
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1919
    protected void undeferChildren(Node node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1920
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1921
        Node top = node;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1922
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1923
        while (null != node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1924
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1925
            if (((NodeImpl)node).needsSyncData()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1926
                ((NodeImpl)node).synchronizeData();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1927
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1928
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1929
            NamedNodeMap attributes = node.getAttributes();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1930
            if (attributes != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1931
                int length = attributes.getLength();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1932
                for (int i = 0; i < length; ++i) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1933
                    undeferChildren(attributes.item(i));
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1934
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1935
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1936
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1937
            Node nextNode = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1938
            nextNode = node.getFirstChild();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1939
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1940
            while (null == nextNode) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1941
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1942
                if (top.equals(node))
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1943
                    break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1944
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1945
                nextNode = node.getNextSibling();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1946
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1947
                if (null == nextNode) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1948
                    node = node.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1949
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1950
                    if ((null == node) || (top.equals(node))) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1951
                        nextNode = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1952
                        break;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1953
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1954
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1955
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1956
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1957
            node = nextNode;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1958
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1959
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1960
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1961
    // identifier maintenence
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1962
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1963
     * Introduced in DOM Level 2
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1964
     * Returns the Element whose ID is given by elementId. If no such element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1965
     * exists, returns null. Behavior is not defined if more than one element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1966
     * has this ID.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1967
     * <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1968
     * Note: The DOM implementation must have information that says which
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1969
     * attributes are of type ID. Attributes with the name "ID" are not of type
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1970
     * ID unless so defined. Implementations that do not know whether
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1971
     * attributes are of type ID or not are expected to return null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1972
     * @see #getIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1973
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1974
    public Element getElementById(String elementId) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1975
        return getIdentifier(elementId);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1976
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1977
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1978
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1979
     * Remove all identifiers from the ID table
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1980
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1981
    protected final void clearIdentifiers(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1982
        if (identifiers != null){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1983
            identifiers.clear();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1984
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1985
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1986
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1987
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1988
     * Registers an identifier name with a specified element node.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1989
     * If the identifier is already registered, the new element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1990
     * node replaces the previous node. If the specified element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1991
     * node is null, removeIdentifier() is called.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1992
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1993
     * @see #getIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1994
     * @see #removeIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1995
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1996
    public void putIdentifier(String idName, Element element) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1997
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1998
        if (element == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  1999
            removeIdentifier(idName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2000
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2001
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2002
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2003
        if (needsSyncData()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2004
            synchronizeData();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2005
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2006
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2007
        if (identifiers == null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2008
            identifiers = new HashMap<>();
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2009
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2010
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2011
        identifiers.put(idName, element);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2012
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2013
    } // putIdentifier(String,Element)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2014
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2015
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2016
     * Returns a previously registered element with the specified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2017
     * identifier name, or null if no element is registered.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2018
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2019
     * @see #putIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2020
     * @see #removeIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2021
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2022
    public Element getIdentifier(String idName) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2023
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2024
        if (needsSyncData()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2025
            synchronizeData();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2026
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2027
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2028
        if (identifiers == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2029
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2030
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2031
        Element elem = (Element) identifiers.get(idName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2032
        if (elem != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2033
            // check that the element is in the tree
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2034
            Node parent = elem.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2035
            while (parent != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2036
                if (parent == this) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2037
                    return elem;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2038
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2039
                parent = parent.getParentNode();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2040
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2041
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2042
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2043
    } // getIdentifier(String):Element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2044
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2045
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2046
     * Removes a previously registered element with the specified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2047
     * identifier name.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2048
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2049
     * @see #putIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2050
     * @see #getIdentifier
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2051
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2052
    public void removeIdentifier(String idName) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2053
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2054
        if (needsSyncData()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2055
            synchronizeData();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2056
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2057
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2058
        if (identifiers == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2059
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2060
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2061
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2062
        identifiers.remove(idName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2063
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2064
    } // removeIdentifier(String)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2065
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2066
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2067
    // DOM2: Namespace methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2068
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2069
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2070
     * Introduced in DOM Level 2. <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2071
     * Creates an element of the given qualified name and namespace URI.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2072
     * If the given namespaceURI is null or an empty string and the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2073
     * qualifiedName has a prefix that is "xml", the created element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2074
     * is bound to the predefined namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2075
     * "http://www.w3.org/XML/1998/namespace" [Namespaces].
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2076
     * @param namespaceURI The namespace URI of the element to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2077
     *                     create.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2078
     * @param qualifiedName The qualified name of the element type to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2079
     *                      instantiate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2080
     * @return Element A new Element object with the following attributes:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2081
     * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2082
     * name contains an invalid character.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2083
     * @throws DOMException NAMESPACE_ERR: Raised if the qualifiedName has a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2084
     *                      prefix that is "xml" and the namespaceURI is
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2085
     *                      neither null nor an empty string nor
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2086
     *                      "http://www.w3.org/XML/1998/namespace", or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2087
     *                      if the qualifiedName has a prefix different
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2088
     *                      from "xml" and the namespaceURI is null or an
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2089
     *                      empty string.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2090
     * @since WD-DOM-Level-2-19990923
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2091
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2092
    public Element createElementNS(String namespaceURI, String qualifiedName)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2093
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2094
        return new ElementNSImpl(this, namespaceURI, qualifiedName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2095
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2096
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2097
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2098
     * NON-DOM: a factory method used by the Xerces DOM parser
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2099
     * to create an element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2100
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2101
     * @param namespaceURI The namespace URI of the element to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2102
     *                     create.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2103
     * @param qualifiedName The qualified name of the element type to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2104
     *                      instantiate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2105
     * @param localpart  The local name of the attribute to instantiate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2106
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2107
     * @return Element A new Element object with the following attributes:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2108
     * @exception DOMException INVALID_CHARACTER_ERR: Raised if the specified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2109
     *                   name contains an invalid character.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2110
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2111
    public Element createElementNS(String namespaceURI, String qualifiedName,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2112
            String localpart)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2113
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2114
        return new ElementNSImpl(this, namespaceURI, qualifiedName, localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2115
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2116
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2117
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2118
     * Introduced in DOM Level 2. <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2119
     * Creates an attribute of the given qualified name and namespace URI.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2120
     * If the given namespaceURI is null or an empty string and the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2121
     * qualifiedName has a prefix that is "xml", the created element
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2122
     * is bound to the predefined namespace
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2123
     * "http://www.w3.org/XML/1998/namespace" [Namespaces].
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2124
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2125
     * @param namespaceURI  The namespace URI of the attribute to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2126
     *                      create. When it is null or an empty string,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2127
     *                      this method behaves like createAttribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2128
     * @param qualifiedName The qualified name of the attribute to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2129
     *                      instantiate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2130
     * @return Attr         A new Attr object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2131
     * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2132
     * name contains an invalid character.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2133
     * @since WD-DOM-Level-2-19990923
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2134
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2135
    public Attr createAttributeNS(String namespaceURI, String qualifiedName)
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2136
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2137
        return new AttrNSImpl(this, namespaceURI, qualifiedName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2138
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2139
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2140
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2141
     * NON-DOM: a factory method used by the Xerces DOM parser
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2142
     * to create an element.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2143
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2144
     * @param namespaceURI  The namespace URI of the attribute to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2145
     *                      create. When it is null or an empty string,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2146
     *                      this method behaves like createAttribute.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2147
     * @param qualifiedName The qualified name of the attribute to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2148
     *                      instantiate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2149
     * @param localpart     The local name of the attribute to instantiate.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2150
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2151
     * @return Attr         A new Attr object.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2152
     * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2153
     * name contains an invalid character.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2154
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2155
    public Attr createAttributeNS(String namespaceURI, String qualifiedName,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2156
            String localpart)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2157
            throws DOMException {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2158
        return new AttrNSImpl(this, namespaceURI, qualifiedName, localpart);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2159
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2160
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2161
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2162
     * Introduced in DOM Level 2. <p>
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2163
     * Returns a NodeList of all the Elements with a given local name and
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2164
     * namespace URI in the order in which they would be encountered in a
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2165
     * preorder traversal of the Document tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2166
     * @param namespaceURI  The namespace URI of the elements to match
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2167
     *                      on. The special value "*" matches all
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2168
     *                      namespaces. When it is null or an empty
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2169
     *                      string, this method behaves like
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2170
     *                      getElementsByTagName.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2171
     * @param localName     The local name of the elements to match on.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2172
     *                      The special value "*" matches all local names.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2173
     * @return NodeList     A new NodeList object containing all the matched
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2174
     *                      Elements.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2175
     * @since WD-DOM-Level-2-19990923
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2176
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2177
    public NodeList getElementsByTagNameNS(String namespaceURI,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2178
            String localName) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2179
        return new DeepNodeListImpl(this, namespaceURI, localName);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2180
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2181
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2182
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2183
    // Object methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2184
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2185
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2186
    /** Clone. */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2187
    public Object clone() throws CloneNotSupportedException {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2188
        CoreDocumentImpl newdoc = (CoreDocumentImpl) super.clone();
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2189
        newdoc.docType = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2190
        newdoc.docElement = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2191
        return newdoc;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2192
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2193
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2194
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2195
    // Public static methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2196
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2197
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2198
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2199
     * Check the string against XML's definition of acceptable names for
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2200
     * elements and attributes and so on using the XMLCharacterProperties
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2201
     * utility class
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2202
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2203
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2204
    public static final boolean isXMLName(String s, boolean xml11Version) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2205
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2206
        if (s == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2207
            return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2208
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2209
        if(!xml11Version)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2210
            return XMLChar.isValidName(s);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2211
        else
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2212
            return XML11Char.isXML11ValidName(s);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2213
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2214
    } // isXMLName(String):boolean
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2215
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2216
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2217
     * Checks if the given qualified name is legal with respect
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2218
     * to the version of XML to which this document must conform.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2219
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2220
     * @param prefix prefix of qualified name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2221
     * @param local local part of qualified name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2222
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2223
    public static final boolean isValidQName(String prefix, String local, boolean xml11Version) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2224
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2225
        // check that both prefix and local part match NCName
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2226
        if (local == null) return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2227
        boolean validNCName = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2228
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2229
        if (!xml11Version) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2230
            validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2231
                    && XMLChar.isValidNCName(local);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2232
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2233
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2234
            validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2235
                    && XML11Char.isXML11ValidNCName(local);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2236
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2237
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2238
        return validNCName;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2239
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2240
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2241
    // Protected methods
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2242
    //
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2243
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2244
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2245
     * Uses the kidOK lookup table to check whether the proposed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2246
     * tree structure is legal.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2247
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2248
    protected boolean isKidOK(Node parent, Node child) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2249
        if (allowGrammarAccess &&
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2250
        parent.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2251
            return child.getNodeType() == Node.ELEMENT_NODE;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2252
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2253
        return 0 != (kidOK[parent.getNodeType()] & 1 << child.getNodeType());
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2254
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2255
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2256
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2257
     * Denotes that this node has changed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2258
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2259
    protected void changed() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2260
        changes++;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2261
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2262
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2263
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2264
     * Returns the number of changes to this node.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2265
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2266
    protected int changes() {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2267
        return changes;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2268
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2269
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2270
    //  NodeListCache pool
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2271
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2272
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2273
     * Returns a NodeListCache for the given node.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2274
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2275
    NodeListCache getNodeListCache(ParentNode owner) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2276
        if (fFreeNLCache == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2277
            return new NodeListCache(owner);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2278
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2279
        NodeListCache c = fFreeNLCache;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2280
        fFreeNLCache = fFreeNLCache.next;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2281
        c.fChild = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2282
        c.fChildIndex = -1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2283
        c.fLength = -1;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2284
        // revoke previous ownership
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2285
        if (c.fOwner != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2286
            c.fOwner.fNodeListCache = null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2287
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2288
        c.fOwner = owner;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2289
        // c.next = null; not necessary, except for confused people...
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2290
        return c;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2291
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2292
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2293
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2294
     * Puts the given NodeListCache in the free list.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2295
     * Note: The owner node can keep using it until we reuse it
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2296
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2297
    void freeNodeListCache(NodeListCache c) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2298
        c.next = fFreeNLCache;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2299
        fFreeNLCache = c;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2300
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2301
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2302
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2303
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2304
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2305
     * Associate an object to a key on this node. The object can later be
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2306
     * retrieved from this node by calling <code>getUserData</code> with the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2307
     * same key.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2308
     * @param n The node to associate the object to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2309
     * @param key The key to associate the object to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2310
     * @param data The object to associate to the given key, or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2311
     *   <code>null</code> to remove any existing association to that key.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2312
     * @param handler The handler to associate to that key, or
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2313
     *   <code>null</code>.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2314
     * @return Returns the <code>DOMObject</code> previously associated to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2315
     *   the given key on this node, or <code>null</code> if there was none.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2316
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2317
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2318
     * REVISIT: we could use a free list of UserDataRecord here
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2319
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2320
    public Object setUserData(Node n, String key,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2321
            Object data, UserDataHandler handler) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2322
        if (data == null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2323
            if (nodeUserData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2324
                Map<String, UserDataRecord> t = nodeUserData.get(n);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2325
                if (t != null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2326
                    UserDataRecord r = t.remove(key);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2327
                    if (r != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2328
                        return r.fData;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2329
                    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2330
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2331
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2332
            return null;
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2333
        } else {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2334
            Map<String, UserDataRecord> t;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2335
            if (nodeUserData == null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2336
                nodeUserData = new HashMap<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2337
                t = new HashMap<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2338
                nodeUserData.put(n, t);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2339
            } else {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2340
                t = nodeUserData.get(n);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2341
                if (t == null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2342
                    t = new HashMap<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2343
                    nodeUserData.put(n, t);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2344
                }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2345
            }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2346
            UserDataRecord r = t.put(key, new UserDataRecord(data, handler));
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2347
            if (r != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2348
                return r.fData;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2349
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2350
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2351
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2352
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2353
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2354
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2355
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2356
     * Retrieves the object associated to a key on a this node. The object
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2357
     * must first have been set to this node by calling
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2358
     * <code>setUserData</code> with the same key.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2359
     * @param n The node the object is associated to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2360
     * @param key The key the object is associated to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2361
     * @return Returns the <code>DOMObject</code> associated to the given key
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2362
     *   on this node, or <code>null</code> if there was none.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2363
     * @since DOM Level 3
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2364
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2365
    public Object getUserData(Node n, String key) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2366
        if (nodeUserData == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2367
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2368
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2369
        Map<String, UserDataRecord> t = nodeUserData.get(n);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2370
        if (t == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2371
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2372
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2373
        UserDataRecord r = t.get(key);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2374
        if (r != null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2375
            return r.fData;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2376
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2377
        return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2378
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2379
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2380
    protected Map<String, UserDataRecord> getUserDataRecord(Node n) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2381
        if (nodeUserData == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2382
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2383
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2384
        Map<String, UserDataRecord> t = nodeUserData.get(n);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2385
        if (t == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2386
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2387
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2388
        return t;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2389
    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2390
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2391
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2392
     * Remove user data table for the given node.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2393
     * @param n The node this operation applies to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2394
     * @return The removed table.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2395
     */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2396
    Map<String, UserDataRecord> removeUserDataTable(Node n) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2397
        if (nodeUserData == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2398
            return null;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2399
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2400
        return nodeUserData.get(n);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2401
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2402
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2403
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2404
     * Set user data table for the given node.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2405
     * @param n The node this operation applies to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2406
     * @param data The user data table.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2407
     */
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2408
    void setUserDataTable(Node n, Map<String, UserDataRecord> data) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2409
        if (nodeUserData == null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2410
            nodeUserData = new HashMap<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2411
        }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2412
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2413
        if (data != null) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2414
            nodeUserData.put(n, data);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2415
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2416
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2417
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2418
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2419
     * Call user data handlers when a node is deleted (finalized)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2420
     * @param n The node this operation applies to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2421
     * @param c The copy node or null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2422
     * @param operation The operation - import, clone, or delete.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2423
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2424
    void callUserDataHandlers(Node n, Node c, short operation) {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2425
        if (nodeUserData == null) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2426
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2427
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2428
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2429
        if (n instanceof NodeImpl) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2430
            Map<String, UserDataRecord> t = ((NodeImpl) n).getUserDataRecord();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2431
            if (t == null || t.isEmpty()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2432
                return;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2433
            }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2434
            callUserDataHandlers(n, c, operation, t);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2435
        }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2436
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2437
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2438
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2439
     * Call user data handlers when a node is deleted (finalized)
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2440
     * @param n The node this operation applies to.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2441
     * @param c The copy node or null.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2442
     * @param operation The operation - import, clone, or delete.
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2443
     * @param handlers Data associated with n.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2444
     */
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2445
    void callUserDataHandlers(Node n, Node c, short operation, Map<String, UserDataRecord> userData) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2446
        if (userData == null || userData.isEmpty()) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2447
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2448
        }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2449
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2450
        userData.keySet().stream().forEach((key) -> {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2451
            UserDataRecord r = userData.get(key);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2452
            if (r.fHandler != null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2453
                r.fHandler.handle(operation, key, r.fData, n, c);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2454
            }
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2455
        });
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2456
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2457
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2458
    /**
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2459
     * Call user data handlers to let them know the nodes they are related to
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2460
     * are being deleted. The alternative would be to do that on Node but
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2461
     * because the nodes are used as the keys we have a reference to them that
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2462
     * prevents them from being gc'ed until the document is. At the same time,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2463
     * doing it here has the advantage of avoiding a finalize() method on Node,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2464
     * which would affect all nodes and not just the ones that have a user
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2465
     * data.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2466
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2467
    // Temporarily comment out this method, because
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2468
    // 1. It seems that finalizers are not guaranteed to be called, so the
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2469
    //    functionality is not implemented.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2470
    // 2. It affects the performance greatly in multi-thread environment.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2471
    // -SG
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2472
    /*public void finalize() {
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2473
     if (userData == null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2474
     return;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2475
     }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2476
     Enumeration nodes = userData.keys();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2477
     while (nodes.hasMoreElements()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2478
     Object node = nodes.nextElement();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2479
     Hashtable t = (Hashtable) userData.get(node);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2480
     if (t != null && !t.isEmpty()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2481
     Enumeration keys = t.keys();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2482
     while (keys.hasMoreElements()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2483
     String key = (String) keys.nextElement();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2484
     UserDataRecord r = (UserDataRecord) t.get(key);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2485
     if (r.fHandler != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2486
     r.fHandler.handle(UserDataHandler.NODE_DELETED,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2487
     key, r.fData, null, null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2488
     }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2489
     }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2490
     }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2491
     }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2492
     }*/
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2493
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2494
    protected final void checkNamespaceWF( String qname, int colon1,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2495
            int colon2) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2496
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2497
        if (!errorChecking) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2498
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2499
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2500
        // it is an error for NCName to have more than one ':'
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2501
        // check if it is valid QName [Namespace in XML production 6]
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2502
        // :camera , nikon:camera:minolta, camera:
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2503
        if (colon1 == 0 || colon1 == qname.length() - 1 || colon2 != colon1) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2504
            String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2505
            DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2506
                            DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2507
                            "NAMESPACE_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2508
                            null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2509
            throw new DOMException(DOMException.NAMESPACE_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2510
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2511
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2512
    protected final void checkDOMNSErr(String prefix,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2513
            String namespace) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2514
        if (errorChecking) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2515
            if (namespace == null) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2516
                String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2517
                DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2518
                                DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2519
                                "NAMESPACE_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2520
                                null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2521
                throw new DOMException(DOMException.NAMESPACE_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2522
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2523
            else if (prefix.equals("xml")
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2524
                    && !namespace.equals(NamespaceContext.XML_URI)) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2525
                String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2526
                DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2527
                                DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2528
                                "NAMESPACE_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2529
                                null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2530
                throw new DOMException(DOMException.NAMESPACE_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2531
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2532
            else if (
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2533
            prefix.equals("xmlns")
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2534
                    && !namespace.equals(NamespaceContext.XMLNS_URI)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2535
                    || (!prefix.equals("xmlns")
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2536
                    && namespace.equals(NamespaceContext.XMLNS_URI))) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2537
                String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2538
                DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2539
                                DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2540
                                "NAMESPACE_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2541
                                null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2542
                throw new DOMException(DOMException.NAMESPACE_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2543
            }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2544
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2545
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2546
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2547
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2548
     * Checks if the given qualified name is legal with respect
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2549
     * to the version of XML to which this document must conform.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2550
     *
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2551
     * @param prefix prefix of qualified name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2552
     * @param local local part of qualified name
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2553
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2554
    protected final void checkQName(String prefix, String local) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2555
        if (!errorChecking) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2556
            return;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2557
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2558
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2559
        // check that both prefix and local part match NCName
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2560
        boolean validNCName = false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2561
        if (!xml11Version) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2562
            validNCName = (prefix == null || XMLChar.isValidNCName(prefix))
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2563
                    && XMLChar.isValidNCName(local);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2564
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2565
        else {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2566
            validNCName = (prefix == null || XML11Char.isXML11ValidNCName(prefix))
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2567
                    && XML11Char.isXML11ValidNCName(local);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2568
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2569
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2570
        if (!validNCName) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2571
            // REVISIT: add qname parameter to the message
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2572
            String msg =
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2573
            DOMMessageFormatter.formatMessage(
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2574
                            DOMMessageFormatter.DOM_DOMAIN,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2575
                            "INVALID_CHARACTER_ERR",
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2576
                            null);
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2577
            throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2578
        }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2579
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2580
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2581
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2582
     * We could have more xml versions in future , but for now we could
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2583
     * do with this to handle XML 1.0 and 1.1
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2584
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2585
    boolean isXML11Version(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2586
        return xml11Version;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2587
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2588
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2589
    boolean isNormalizeDocRequired(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2590
        // REVISIT: Implement to optimize when normalization
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2591
        // is required
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2592
        return true;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2593
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2594
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2595
    //we should be checking the (elements, attribute, entity etc.) names only when
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2596
    //version of the document is changed.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2597
    boolean isXMLVersionChanged(){
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2598
        return xmlVersionChanged ;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2599
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2600
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2601
     * NON-DOM: kept for backward compatibility
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2602
     * Store user data related to a given node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2603
     * This is a place where we could use weak references! Indeed, the node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2604
     * here won't be GC'ed as long as some user data is attached to it, since
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2605
     * the userData table will have a reference to the node.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2606
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2607
    protected void setUserData(NodeImpl n, Object data) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2608
        setUserData(n, "XERCES1DOMUSERDATA", data, null);
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2609
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2610
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2611
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2612
     * NON-DOM: kept for backward compatibility
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2613
     * Retreive user data related to a given node
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2614
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2615
    protected Object getUserData(NodeImpl n) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2616
        return getUserData(n, "XERCES1DOMUSERDATA");
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2617
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2618
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2619
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2620
    // Event related methods overidden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2621
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2622
    protected void addEventListener(NodeImpl node, String type,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2623
            EventListener listener,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2624
            boolean useCapture) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2625
        // does nothing by default - overidden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2626
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2627
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2628
    protected void removeEventListener(NodeImpl node, String type,
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2629
            EventListener listener,
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2630
            boolean useCapture) {
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2631
        // does nothing by default - overidden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2632
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2633
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2634
    protected void copyEventListeners(NodeImpl src, NodeImpl tgt) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2635
        // does nothing by default - overidden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2636
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2637
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2638
    protected boolean dispatchEvent(NodeImpl node, Event event) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2639
        // does nothing by default - overidden in subclass
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2640
        return false;
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2641
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2642
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2643
    // Notification methods overidden in subclasses
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2644
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2645
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2646
     * A method to be called when some text was changed in a text node,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2647
     * so that live objects can be notified.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2648
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2649
    void replacedText(NodeImpl node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2650
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2651
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2652
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2653
     * A method to be called when some text was deleted from a text node,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2654
     * so that live objects can be notified.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2655
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2656
    void deletedText(NodeImpl node, int offset, int count) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2657
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2658
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2659
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2660
     * A method to be called when some text was inserted into a text node,
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2661
     * so that live objects can be notified.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2662
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2663
    void insertedText(NodeImpl node, int offset, int count) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2664
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2665
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2666
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2667
     * A method to be called when a character data node is about to be modified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2668
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2669
    void modifyingCharacterData(NodeImpl node, boolean replace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2670
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2671
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2672
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2673
     * A method to be called when a character data node has been modified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2674
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2675
    void modifiedCharacterData(NodeImpl node, String oldvalue, String value, boolean replace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2676
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2677
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2678
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2679
     * A method to be called when a node is about to be inserted in the tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2680
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2681
    void insertingNode(NodeImpl node, boolean replace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2682
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2683
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2684
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2685
     * A method to be called when a node has been inserted in the tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2686
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2687
    void insertedNode(NodeImpl node, NodeImpl newInternal, boolean replace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2688
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2689
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2690
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2691
     * A method to be called when a node is about to be removed from the tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2692
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2693
    void removingNode(NodeImpl node, NodeImpl oldChild, boolean replace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2694
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2695
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2696
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2697
     * A method to be called when a node has been removed from the tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2698
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2699
    void removedNode(NodeImpl node, boolean replace) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2700
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2701
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2702
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2703
     * A method to be called when a node is about to be replaced in the tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2704
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2705
    void replacingNode(NodeImpl node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2706
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2707
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2708
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2709
     * A method to be called when a node has been replaced in the tree.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2710
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2711
    void replacedNode(NodeImpl node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2712
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2713
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2714
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2715
     * A method to be called when a character data node is about to be replaced
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2716
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2717
    void replacingData(NodeImpl node) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2718
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2719
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2720
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2721
     *  method to be called when a character data node has been replaced.
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2722
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2723
    void replacedCharacterData(NodeImpl node, String oldvalue, String value) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2724
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2725
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2726
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2727
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2728
     * A method to be called when an attribute value has been modified
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2729
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2730
    void modifiedAttrValue(AttrImpl attr, String oldvalue) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2731
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2732
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2733
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2734
     * A method to be called when an attribute node has been set
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2735
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2736
    void setAttrNode(AttrImpl attr, AttrImpl previous) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2737
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2738
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2739
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2740
     * A method to be called when an attribute node has been removed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2741
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2742
    void removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String name) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2743
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2744
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2745
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2746
     * A method to be called when an attribute node has been renamed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2747
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2748
    void renamedAttrNode(Attr oldAt, Attr newAt) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2749
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2750
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2751
    /**
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2752
     * A method to be called when an element has been renamed
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2753
     */
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2754
    void renamedElement(Element oldEl, Element newEl) {
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2755
    }
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2756
33349
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2757
    /**
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2758
     * @serialData Serialized fields. Convert Maps to Hashtables for backward
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2759
     * compatibility.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2760
     */
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2761
    private void writeObject(ObjectOutputStream out) throws IOException {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2762
        // Convert Maps to Hashtables
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2763
        Hashtable<Node, Hashtable<String, UserDataRecord>> nud = null;
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2764
        if (nodeUserData != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2765
            nud = new Hashtable<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2766
            for (Map.Entry<Node, Map<String, UserDataRecord>> e : nodeUserData.entrySet()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2767
                //e.getValue() will not be null since an entry is always put with a non-null value
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2768
                nud.put(e.getKey(), new Hashtable<>(e.getValue()));
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2769
            }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2770
        }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2771
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2772
        Hashtable<String, Node> ids = (identifiers == null)? null : new Hashtable<>(identifiers);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2773
        Hashtable<Node, Integer> nt = (nodeTable == null)? null : new Hashtable<>(nodeTable);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2774
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2775
        // Write serialized fields
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2776
        ObjectOutputStream.PutField pf = out.putFields();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2777
        pf.put("docType", docType);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2778
        pf.put("docElement", docElement);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2779
        pf.put("fFreeNLCache", fFreeNLCache);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2780
        pf.put("encoding", encoding);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2781
        pf.put("actualEncoding", actualEncoding);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2782
        pf.put("version", version);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2783
        pf.put("standalone", standalone);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2784
        pf.put("fDocumentURI", fDocumentURI);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2785
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2786
        //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2787
        pf.put("userData", nud);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2788
        pf.put("identifiers", ids);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2789
        pf.put("changes", changes);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2790
        pf.put("allowGrammarAccess", allowGrammarAccess);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2791
        pf.put("errorChecking", errorChecking);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2792
        pf.put("ancestorChecking", ancestorChecking);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2793
        pf.put("xmlVersionChanged", xmlVersionChanged);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2794
        pf.put("documentNumber", documentNumber);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2795
        pf.put("nodeCounter", nodeCounter);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2796
        pf.put("nodeTable", nt);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2797
        pf.put("xml11Version", xml11Version);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2798
        out.writeFields();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2799
    }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2800
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2801
    @SuppressWarnings("unchecked")
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2802
    private void readObject(ObjectInputStream in)
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2803
                        throws IOException, ClassNotFoundException {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2804
        // We have to read serialized fields first.
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2805
        ObjectInputStream.GetField gf = in.readFields();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2806
        docType = (DocumentTypeImpl)gf.get("docType", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2807
        docElement = (ElementImpl)gf.get("docElement", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2808
        fFreeNLCache = (NodeListCache)gf.get("fFreeNLCache", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2809
        encoding = (String)gf.get("encoding", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2810
        actualEncoding = (String)gf.get("actualEncoding", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2811
        version = (String)gf.get("version", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2812
        standalone = gf.get("standalone", false);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2813
        fDocumentURI = (String)gf.get("fDocumentURI", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2814
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2815
        //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2816
        Hashtable<Node, Hashtable<String, UserDataRecord>> nud =
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2817
                (Hashtable<Node, Hashtable<String, UserDataRecord>>)gf.get("userData", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2818
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2819
        Hashtable<String, Node> ids = (Hashtable<String, Node>)gf.get("identifiers", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2820
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2821
        changes = gf.get("changes", 0);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2822
        allowGrammarAccess = gf.get("allowGrammarAccess", false);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2823
        errorChecking = gf.get("errorChecking", true);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2824
        ancestorChecking = gf.get("ancestorChecking", true);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2825
        xmlVersionChanged = gf.get("xmlVersionChanged", false);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2826
        documentNumber = gf.get("documentNumber", 0);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2827
        nodeCounter = gf.get("nodeCounter", 0);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2828
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2829
        Hashtable<Node, Integer> nt = (Hashtable<Node, Integer>)gf.get("nodeTable", null);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2830
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2831
        xml11Version = gf.get("xml11Version", false);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2832
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2833
        //convert Hashtables back to HashMaps
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2834
        if (nud != null) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2835
            nodeUserData = new HashMap<>();
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2836
            for (Map.Entry<Node, Hashtable<String, UserDataRecord>> e : nud.entrySet()) {
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2837
                nodeUserData.put(e.getKey(), new HashMap<>(e.getValue()));
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2838
            }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2839
        }
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2840
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2841
        if (ids != null) identifiers = new HashMap<>(ids);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2842
        if (nt != null) nodeTable = new HashMap<>(nt);
975138b77cff 8068842: Better JAXP data handling
joehw
parents: 29948
diff changeset
  2843
    }
12005
a754d69d5e60 7150324: Stop using drop bundles in jaxp
ohair
parents:
diff changeset
  2844
} // class CoreDocumentImpl