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