2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.xerces.dom;
20
import org.w3c.dom.Node;
23
* This class represents a Document Type <em>declaraction</em> in
24
* the document itself, <em>not</em> a Document Type Definition (DTD).
25
* An XML document may (or may not) have such a reference.
27
* DocumentType is an Extended DOM feature, used in XML documents but
30
* Note that Entities and Notations are no longer children of the
31
* DocumentType, but are parentless nodes hung only in their
32
* appropriate NamedNodeMaps.
34
* This area is UNDERSPECIFIED IN REC-DOM-Level-1-19981001
35
* Most notably, absolutely no provision was made for storing
36
* and using Element and Attribute information. Nor was the linkage
37
* between Entities and Entity References nailed down solidly.
41
* @version $Id: DeferredDocumentTypeImpl.java,v 1.2 2009/12/10 03:18:32 matthewoliver Exp $
42
* @since PR-DOM-Level-1-19980818.
44
public class DeferredDocumentTypeImpl
45
extends DocumentTypeImpl
46
implements DeferredNode {
52
/** Serialization version. */
53
static final long serialVersionUID = -2172579663227313509L;
60
protected transient int fNodeIndex;
67
* This is the deferred constructor. Only the fNodeIndex is given here.
68
* All other data, can be requested from the ownerDocument via the index.
70
DeferredDocumentTypeImpl(DeferredDocumentImpl ownerDocument, int nodeIndex) {
71
super(ownerDocument, null);
73
fNodeIndex = nodeIndex;
75
needsSyncChildren(true);
77
} // <init>(DeferredDocumentImpl,int)
80
// DeferredNode methods
83
/** Returns the node index. */
84
public int getNodeIndex() {
92
/** Synchronizes the data (name and value) for fast nodes. */
93
protected void synchronizeData() {
95
// no need to sync in the future
99
DeferredDocumentImpl ownerDocument =
100
(DeferredDocumentImpl)this.ownerDocument;
101
name = ownerDocument.getNodeName(fNodeIndex);
103
// public and system ids
104
publicID = ownerDocument.getNodeValue(fNodeIndex);
105
systemID = ownerDocument.getNodeURI(fNodeIndex);
106
int extraDataIndex = ownerDocument.getNodeExtra(fNodeIndex);
107
internalSubset = ownerDocument.getNodeValue(extraDataIndex);
108
} // synchronizeData()
110
/** Synchronizes the entities, notations, and elements. */
111
protected void synchronizeChildren() {
113
// we don't want to generate any event for this so turn them off
114
boolean orig = ownerDocument().getMutationEvents();
115
ownerDocument().setMutationEvents(false);
117
// no need to synchronize again
118
needsSyncChildren(false);
120
// create new node maps
121
DeferredDocumentImpl ownerDocument =
122
(DeferredDocumentImpl)this.ownerDocument;
124
entities = new NamedNodeMapImpl(this);
125
notations = new NamedNodeMapImpl(this);
126
elements = new NamedNodeMapImpl(this);
129
DeferredNode last = null;
130
for (int index = ownerDocument.getLastChild(fNodeIndex);
132
index = ownerDocument.getPrevSibling(index)) {
134
DeferredNode node = ownerDocument.getNodeObject(index);
135
int type = node.getNodeType();
138
// internal, external, and unparsed entities
139
case Node.ENTITY_NODE: {
140
entities.setNamedItem(node);
145
case Node.NOTATION_NODE: {
146
notations.setNamedItem(node);
150
// element definitions
151
case NodeImpl.ELEMENT_DEFINITION_NODE: {
152
elements.setNamedItem(node);
157
case Node.ELEMENT_NODE: {
158
if (((DocumentImpl)getOwnerDocument()).allowGrammarAccess){
159
insertBefore(node, last);
165
// NOTE: Should never get here! -Ac
167
System.out.println("DeferredDocumentTypeImpl" +
168
"#synchronizeInfo: " +
169
"node.getNodeType() = " +
172
node.getClass().getName());
177
// set mutation events flag back to its original value
178
ownerDocument().setMutationEvents(orig);
180
// set entities and notations read_only per DOM spec
181
setReadOnly(true, false);
183
} // synchronizeChildren()
185
} // class DeferredDocumentTypeImpl