286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2002,2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.dom;
286N/A
286N/Aimport org.w3c.dom.Node;
286N/A
286N/A/**
286N/A * NON-DOM CLASS: Describe one of the Elements (and its associated
286N/A * Attributes) defined in this Document Type.
286N/A * <p>
286N/A * I've included this in Level 1 purely as an anchor point for default
286N/A * attributes. In Level 2 it should enable the ChildRule support.
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A */
286N/Apublic class DeferredElementDefinitionImpl
286N/A extends ElementDefinitionImpl
286N/A implements DeferredNode {
286N/A
286N/A //
286N/A // Constants
286N/A //
286N/A
286N/A /** Serialization version. */
286N/A static final long serialVersionUID = 6703238199538041591L;
286N/A
286N/A //
286N/A // Data
286N/A //
286N/A
286N/A /** Node index. */
286N/A protected transient int fNodeIndex;
286N/A
286N/A //
286N/A // Constructors
286N/A //
286N/A
286N/A /**
286N/A * This is the deferred constructor. Only the fNodeIndex is given here.
286N/A * All other data, can be requested from the ownerDocument via the index.
286N/A */
286N/A DeferredElementDefinitionImpl(DeferredDocumentImpl ownerDocument,
286N/A int nodeIndex) {
286N/A super(ownerDocument, null);
286N/A
286N/A fNodeIndex = nodeIndex;
286N/A needsSyncData(true);
286N/A needsSyncChildren(true);
286N/A
286N/A } // <init>(DeferredDocumentImpl,int)
286N/A
286N/A //
286N/A // DeferredNode methods
286N/A //
286N/A
286N/A /** Returns the node index. */
286N/A public int getNodeIndex() {
286N/A return fNodeIndex;
286N/A }
286N/A
286N/A //
286N/A // Protected methods
286N/A //
286N/A
286N/A /** Synchronizes the data (name and value) for fast nodes. */
286N/A protected void synchronizeData() {
286N/A
286N/A // no need to sync in the future
286N/A needsSyncData(false);
286N/A
286N/A // fluff data
286N/A DeferredDocumentImpl ownerDocument =
286N/A (DeferredDocumentImpl)this.ownerDocument;
286N/A name = ownerDocument.getNodeName(fNodeIndex);
286N/A
286N/A } // synchronizeData()
286N/A
286N/A /** Synchronizes the default attribute values. */
286N/A protected void synchronizeChildren() {
286N/A
286N/A // we don't want to generate any event for this so turn them off
286N/A boolean orig = ownerDocument.getMutationEvents();
286N/A ownerDocument.setMutationEvents(false);
286N/A
286N/A // attributes are now synced
286N/A needsSyncChildren(false);
286N/A
286N/A // create attributes node map
286N/A DeferredDocumentImpl ownerDocument =
286N/A (DeferredDocumentImpl)this.ownerDocument;
286N/A attributes = new NamedNodeMapImpl(ownerDocument);
286N/A
286N/A // Default attributes dangle as children of the element
286N/A // definition "node" in the internal fast table.
286N/A for (int nodeIndex = ownerDocument.getLastChild(fNodeIndex);
286N/A nodeIndex != -1;
286N/A nodeIndex = ownerDocument.getPrevSibling(nodeIndex)) {
286N/A Node attr = ownerDocument.getNodeObject(nodeIndex);
286N/A attributes.setNamedItem(attr);
286N/A }
286N/A
286N/A // set mutation events flag back to its original value
286N/A ownerDocument.setMutationEvents(orig);
286N/A
286N/A } // synchronizeChildren()
286N/A
286N/A} // class DeferredElementDefinitionImpl