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/A
286N/A/*
286N/A * WARNING: because java doesn't support multi-inheritance some code is
286N/A * duplicated. If you're changing this file you probably want to change
286N/A * DeferredElementImpl.java at the same time.
286N/A *
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.dom;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.NamespaceContext;
286N/Aimport com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
286N/Aimport org.w3c.dom.NamedNodeMap;
286N/A
286N/A
286N/A/**
286N/A * DeferredElementNSImpl is to ElementNSImpl, what DeferredElementImpl is to
286N/A * ElementImpl.
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @see DeferredElementImpl
286N/A */
286N/Apublic class DeferredElementNSImpl
286N/A extends ElementNSImpl
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 = -5001885145370927385L;
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. All
286N/A * other data, can be requested from the ownerDocument via the index.
286N/A */
286N/A DeferredElementNSImpl(DeferredDocumentImpl ownerDoc, int nodeIndex) {
286N/A super(ownerDoc, null);
286N/A
286N/A fNodeIndex = nodeIndex;
286N/A needsSyncChildren(true);
286N/A
286N/A } // <init>(DocumentImpl,int)
286N/A
286N/A //
286N/A // DeferredNode methods
286N/A //
286N/A
286N/A /** Returns the node index. */
286N/A public final 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 final 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
286N/A // we don't want to generate any event for this so turn them off
286N/A boolean orig = ownerDocument.mutationEvents;
286N/A ownerDocument.mutationEvents = false;
286N/A
286N/A name = ownerDocument.getNodeName(fNodeIndex);
286N/A
286N/A // extract local part from QName
286N/A int index = name.indexOf(':');
286N/A if (index < 0) {
286N/A localName = name;
286N/A }
286N/A else {
286N/A localName = name.substring(index + 1);
286N/A }
286N/A
286N/A namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
286N/A type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex);
286N/A
286N/A // attributes
286N/A setupDefaultAttributes();
286N/A int attrIndex = ownerDocument.getNodeExtra(fNodeIndex);
286N/A if (attrIndex != -1) {
286N/A NamedNodeMap attrs = getAttributes();
286N/A boolean seenSchemaDefault = false;
286N/A do {
286N/A AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex);
286N/A // Take special care of schema defaulted attributes. Calling the
286N/A // non-namespace aware setAttributeNode() method could overwrite
286N/A // another attribute with the same local name.
286N/A if (!attr.getSpecified() && (seenSchemaDefault ||
286N/A (attr.getNamespaceURI() != null &&
286N/A attr.getNamespaceURI() != NamespaceContext.XMLNS_URI &&
286N/A attr.getName().indexOf(':') < 0))) {
286N/A seenSchemaDefault = true;
286N/A attrs.setNamedItemNS(attr);
286N/A }
286N/A else {
286N/A attrs.setNamedItem(attr);
286N/A }
286N/A attrIndex = ownerDocument.getPrevSibling(attrIndex);
286N/A } while (attrIndex != -1);
286N/A }
286N/A
286N/A // set mutation events flag back to its original value
286N/A ownerDocument.mutationEvents = orig;
286N/A
286N/A } // synchronizeData()
286N/A
286N/A /**
286N/A * Synchronizes the node's children with the internal structure.
286N/A * Fluffing the children at once solves a lot of work to keep
286N/A * the two structures in sync. The problem gets worse when
286N/A * editing the tree -- this makes it a lot easier.
286N/A */
286N/A protected final void synchronizeChildren() {
286N/A DeferredDocumentImpl ownerDocument =
286N/A (DeferredDocumentImpl) ownerDocument();
286N/A ownerDocument.synchronizeChildren(this, fNodeIndex);
286N/A } // synchronizeChildren()
286N/A
286N/A} // class DeferredElementImpl